#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;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main() {
  FILE *self = fopen("/examples/pseudoquine.c", "r");
  if (self == NULL) {
    return 1;
  }
  char c = fgetc(self);
  while (c != EOF) {
    if (fputc(c, stdout) == EOF) {
      return 1;
    }
    c = fgetc(self);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116d <main+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    11d5 <main+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e64(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d5 <main+0xa5>
mov    -0x11(%rbp),%al
mov    0x2e3f(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
movsbl %al,%eax
mov    0x2e3b(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11c4 <main+0x94>
movl   $0x1,-0x4(%rbp)
jmp    11d5 <main+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
jmp    1179 <main+0x49>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
lea    0xed3(%rip),%rsi
call   1050 <fopen@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     11a0 <main+0x70>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <fgetc@plt>
mov    0x2e81(%rip),%rbp
cmp    0x0(%rbp),%al
je     119d <main+0x6d>
mov    0x2e65(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%esi
movsbl %al,%edi
call   1040 <fputc@plt>
cmp    0x0(%rbp),%al
je     11a0 <main+0x70>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    0x0(%rbp),%al
jne    1180 <main+0x50>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"/examples/pseudoquine.c\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@stdout = global i32 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 ([24 x i8], [24 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 %29
8: ; preds = %0
%9 = load i32*, i32** %2
%10 = call signext i8 @fgetc(i32* %9)
store i8 %10, i8* %3
br label %11
11: ; preds = %26, %8
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %13, %15
br i1 %16, label %17, label %29
17: ; preds = %11
%18 = load i8, i8* %3
%19 = load i32, i32* @stdout
%20 = call signext i8 @fputc(i8 signext %18, i32 %19)
%21 = sext i8 %20 to i32
%22 = load i8, i8* @EOF
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %21, %23
br i1 %24, label %25, label %26
25: ; preds = %17
store i32 1, i32* %1
br label %29
26: ; preds = %17
%27 = load i32*, i32** %2
%28 = call signext i8 @fgetc(i32* %27)
store i8 %28, i8* %3
br label %11
29: ; preds = %7, %25, %11
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [24 x i8] c"/examples/pseudoquine.c\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 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 %17, label %3
3: ; preds = %0
%4 = tail call signext i8 @fgetc(i32* %1)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %17, label %7
7: ; preds = %3, %13
%8 = phi i8 [ %14, %13 ], [ %4, %3 ]
%9 = load i32, i32* @stdout
%10 = tail call signext i8 @fputc(i8 signext %8, i32 %9)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = tail call signext i8 @fgetc(i32* %1)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %7
17: ; preds = %13, %7, %3, %0
%18 = phi i32 [ 1, %0 ], [ 0, %3 ], [ 0, %13 ], [ 1, %7 ]
ret i32 %18
}