int input = fgetc(datafile);
int pushed = 0;
while (input != EOF) {
__asm__(
"push %0"
: // No outputs
: "r" ((long long)input) // Input value. "push" requires an 8 byte value
:
);
++pushed;
// For the next loop iteration
input = fgetc(datafile);
}
* `input` at -24(%rbp)
* `pushed` at -20(%rbp)
* `datafile` at -16(%rbp)
```asm
call fgetc@PLT
movl %eax, -24(%rbp)
movl $0, -20(%rbp)
jmp .L5
.L6:
movl -24(%rbp), %eax
cltq
#APP
# 24 "blub.c" 1
push %rax
# 0 "" 2
#NO_APP
addl $1, -20(%rbp)
movq -16(%rbp), %rax
movq %rax, %rdi
call fgetc@PLT
movl %eax, -24(%rbp)
.L5:
cmpl $-1, -24(%rbp)
jne .L6
```
---
## Printing Loop
// Finished with the file
fclose(datafile);
// Reverse
long long out = 0;
while (pushed > 0) {
__asm__(
"pop %0"
: "=r" (out) // Output into the out variable.
:
:
);
putchar(out);
--pushed;
}
putchar('\n');
* `pushed` at -20(%rbp)
* `datafile` at -16(%rbp)
* `out` at -8(%rbp)
* The value of '\n' is 10
```asm
movq -16(%rbp), %rax
movq %rax, %rdi
call fclose@PLT
movq $0, -8(%rbp)
jmp .L7
.L8:
#APP
# 47 "blub.c" 1
pop %rax
# 0 "" 2
#NO_APP
movq %rax, -8(%rbp)
movq -8(%rbp), %rax
movl %eax, %edi
call putchar@PLT
subl $1, -20(%rbp)
.L7:
cmpl $0, -20(%rbp)
jg .L8
movl $10, %edi
call putchar@PLT
```
---
## Checking Status
```c
#include