#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 */
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ printf(char *, char, char);
int main(int argc, char const *argv[]) {
  FILE *file;
  file = fopen(argv[1], "r");
  char c = fgetc(file);
  while (c != '\0' && c != -1) {
    printf("%d %c\n", c, c);
    c = fgetc(file);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1a(%rbp)
je     1189 <main+0x59>
movsbl -0x19(%rbp),%eax
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    1199 <main+0x69>
jmp    11c0 <main+0x90>
mov    -0x19(%rbp),%al
lea    0xe5f(%rip),%rdi
movsbl %al,%esi
movsbl -0x19(%rbp),%edx
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x19(%rbp)
jmp    116a <main+0x3a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xec1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fgetc@plt>
lea    -0x1(%rax),%ecx
cmp    $0xfd,%cl
ja     117f <main+0x4f>
lea    0xea4(%rip),%r14
xchg   %ax,%ax
movsbl %al,%edx
mov    %r14,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
add    $0xff,%cl
cmp    $0xfe,%cl
jb     1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%d %c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = call signext i8 @fgetc(i32* %12)
store i8 %13, i8* %7
br label %14
14: ; preds = %24, %2
%15 = load i8, i8* %7
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, -1
br label %22
22: ; preds = %18, %14
%23 = phi i1 [ false, %14 ], [ %21, %18 ]
br i1 %23, label %24, label %30
24: ; preds = %22
%25 = load i8, i8* %7
%26 = load i8, i8* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %25, i8 signext %26)
%28 = load i32*, i32** %6
%29 = call signext i8 @fgetc(i32* %28)
store i8 %29, i8* %7
br label %14
30: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%d %c\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call signext i8 @fgetc(i32* %5)
%7 = add i8 %6, -1
%8 = icmp ult i8 %7, -2
br i1 %8, label %9, label %15
9: ; preds = %2, %9
%10 = phi i8 [ %12, %9 ], [ %6, %2 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 signext %10, i8 signext %10)
%12 = tail call signext i8 @fgetc(i32* %5)
%13 = add i8 %12, -1
%14 = icmp ult i8 %13, -2
br i1 %14, label %9, label %15
15: ; preds = %9, %2
ret i32 0
}