#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);
int main(void) {
  FILE *arquivo;
  int c, i;
  arquivo = fopen("file_in_byte", "r");
  for (i = 1; i <= 10; i++) {
    c = getc(arquivo);
    printf("\n%d %c %x\n", c, 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    0xeb0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jg     11a6 <main+0x66>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe7c(%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    0xebb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
lea    0xea6(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %eax,%edx
mov    %eax,%ecx
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 = [13 x i8] c"file_in_byte\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"\0A%d %c %x\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 ([13 x i8], [13 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 1, i32* %4
br label %6
6: ; preds = %16, %0
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %19
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 = load i32, i32* %3
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %13, i32 %14)
br label %16
16: ; preds = %9
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %6
19: ; preds = %6
%20 = load i32*, i32** %2
%21 = call i32 @fclose(i32* %20)
ret i32 0
}

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