#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  FILE *arquivo;
  int c;
  int cont;
  arquivo = fopen("lerbyte", "r");
  for (cont = 0; cont < 10; cont++) {
    c = getc(arquivo);
    printf("%i %c\n", c, c);
  }
  fclose(arquivo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    11a3 <main+0x63>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116d <main+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
lea    0xea1(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"lerbyte\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%i %c\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @getc(i32* %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %2, i32 %2)
%4 = tail call i32 @getc(i32* %1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %4)
%6 = tail call i32 @getc(i32* %1)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %6)
%8 = tail call i32 @getc(i32* %1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %8)
%10 = tail call i32 @getc(i32* %1)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %10)
%12 = tail call i32 @getc(i32* %1)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %12)
%14 = tail call i32 @getc(i32* %1)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %14)
%16 = tail call i32 @getc(i32* %1)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %16)
%18 = tail call i32 @getc(i32* %1)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %18)
%20 = tail call i32 @getc(i32* %1)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %20)
%22 = tail call i32 @fclose(i32* %1)
ret i32 0
}