#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct BufferedInputStream {
  int dummy;
};

/* Variables and functions */
struct BufferedInputStream *bufferedInputStream(unsigned long long);
int bufferedReadInt(struct BufferedInputStream *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  struct BufferedInputStream *bis = bufferedInputStream(786432ull / 20);
  int d, n;
  n = bufferedReadInt(bis);
  printf("%d\n", n);
  while (n--) {
    d = bufferedReadInt(bis);
    printf("%d\n", d);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x9999,%edi
call   1030 <bufferedInputStream@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <bufferedReadInt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     119c <main+0x6c>
mov    -0x10(%rbp),%rdi
call   1050 <bufferedReadInt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    1168 <main+0x38>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x9999,%edi
call   1030 <bufferedInputStream@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <bufferedReadInt@plt>
mov    %eax,%ebp
lea    0xeae(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
test   %ebp,%ebp
je     1187 <main+0x57>
lea    0xe9c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <bufferedReadInt@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1170 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.BufferedInputStream = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.BufferedInputStream*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call %struct.BufferedInputStream* @bufferedInputStream(i64 39321)
store %struct.BufferedInputStream* %5, %struct.BufferedInputStream** %2
%6 = load %struct.BufferedInputStream*, %struct.BufferedInputStream** %2
%7 = call i32 @bufferedReadInt(%struct.BufferedInputStream* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %4
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load %struct.BufferedInputStream*, %struct.BufferedInputStream** %2
%16 = call i32 @bufferedReadInt(%struct.BufferedInputStream* %15)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %10
19: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
%struct.BufferedInputStream = type { i32 }
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call %struct.BufferedInputStream* @bufferedInputStream(i64 39321)
%2 = tail call i32 @bufferedReadInt(%struct.BufferedInputStream* %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %2, 0
br i1 %4, label %11, label %5
5: ; preds = %0, %5
%6 = phi i32 [ %7, %5 ], [ %2, %0 ]
%7 = add nsw i32 %6, -1
%8 = tail call i32 @bufferedReadInt(%struct.BufferedInputStream* %1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %7, 0
br i1 %10, label %11, label %5
11: ; preds = %5, %0
ret i32 0
}