#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int main() {
  FILE *f;
  char c;
  f = fopen("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/derwilly/c-examples/refs/heads/master/"
            "040-file-print-source/main.c",
            "r");
  while (c != EOF) {
    c = getc(f);
    if ((int)c != -1) {
      putchar(c);
    }
  }
  printf("\n");
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xf30(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e67(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11b3 <main+0x63>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xffffffff,%eax
je     11ae <main+0x5e>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
jmp    1176 <main+0x26>
lea    0xee5(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
lea    0xf4a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    0x2e86(%rip),%r15
jmp    1175 <main+0x35>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    (%r15),%bl
je     118d <main+0x4d>
mov    %r14,%rdi
call   1060 <getc@plt>
mov    %eax,%ebx
cmp    $0xff,%al
je     1170 <main+0x30>
movsbl %bl,%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/derwilly/c-examples/refs/heads/master/040-file-print-source/main.c\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
br label %5
5: ; preds = %20, %0
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = load i8, i8* @EOF
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %21
11: ; preds = %5
%12 = load i32*, i32** %2
%13 = call signext i8 @getc(i32* %12)
store i8 %13, i8* %3
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8, i8* %3
%19 = call i32 @putchar(i8 signext %18)
br label %20
20: ; preds = %17, %11
br label %5
21: ; preds = %5
%22 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/derwilly/c-examples/refs/heads/master/040-file-print-source/main.c\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %7
%3 = tail call signext i8 @getc(i32* %1)
%4 = icmp eq i8 %3, -1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @putchar(i8 signext %3)
br label %7
7: ; preds = %5, %2
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %3, %8
br i1 %9, label %10, label %2
10: ; preds = %7
%11 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
%12 = tail call i32 @fclose(i32* %1)
ret i32 0
}