#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*/ putchar(char);
int main() {
  FILE *ifp = fopen(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/odeke-em/utils/refs/heads/master/self_print.c",
      "r");
  if (ifp == NULL)
    return -1;
  char c;
  while ((c = getc(ifp)) != EOF)
    putchar(c);
  fclose(ifp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xf2b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117d <main+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <main+0x7a>
jmp    1182 <main+0x42>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e50(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11b1 <main+0x71>
movsbl -0x11(%rbp),%edi
call   1030 <putchar@plt>
jmp    1182 <main+0x42>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
lea    0xf36(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11a1 <main+0x61>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <getc@plt>
mov    0x2e7a(%rip),%r14
cmp    (%r14),%al
je     1195 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r14),%al
jne    1180 <main+0x40>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11a6 <main+0x66>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/odeke-em/utils/refs/heads/master/self_print.c\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([136 x i8], [136 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
%5 = load i32*, i32** %2
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %22
8: ; preds = %0
br label %9
9: ; preds = %16, %8
%10 = load i32*, i32** %2
%11 = call signext i8 @getc(i32* %10)
store i8 %11, i8* %3
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i8, i8* %3
%18 = call i32 @putchar(i8 signext %17)
br label %9
19: ; preds = %9
%20 = load i32*, i32** %2
%21 = call i32 @fclose(i32* %20)
br label %22
22: ; preds = %19, %7
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [136 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/odeke-em/utils/refs/heads/master/self_print.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 ([136 x i8], [136 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call signext i8 @getc(i32* %1)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %13, label %7
7: ; preds = %3, %7
%8 = phi i8 [ %10, %7 ], [ %4, %3 ]
%9 = tail call i32 @putchar(i8 signext %8)
%10 = tail call signext i8 @getc(i32* %1)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %13, label %7
13: ; preds = %7, %3
%14 = tail call i32 @fclose(i32* %1)
br label %15
15: ; preds = %0, %13
%16 = phi i32 [ 0, %13 ], [ -1, %0 ]
ret i32 %16
}