#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ remove_comment(char *, int);
int main() {
  int fd, n;
  char buf[102400];
  fd = open("fuckyou.c", O_RDONLY, 0);
  if (fd == -1)
    return -1;
  n = read(fd, buf, sizeof(buf));
  if (n == -1 || n == 0) {
    close(fd);
    return -1;
  }
  remove_comment(buf, n);
  *(buf + n) = '\0';
  printf("%s", buf);
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x19010,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
xor    %edx,%edx
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1192 <main+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <main+0xb7>
mov    -0x8(%rbp),%edi
lea    -0x19010(%rbp),%rsi
mov    $0x19000,%edx
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     11bd <main+0x6d>
cmpl   $0x0,-0xc(%rbp)
jne    11d1 <main+0x81>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1207 <main+0xb7>
lea    -0x19010(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <remove_comment@plt>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x19010(%rbp,%rax,1)
lea    -0x19010(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x19010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x19000,%rsp
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
lea    0xe95(%rip),%rdi
xor    %edx,%edx
call   1070 <open@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     11ce <main+0x7e>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x19000,%edx
call   1060 <read@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%eax
cmp    $0x1,%eax
ja     11a1 <main+0x51>
mov    %ebx,%edi
call   1050 <close@plt>
jmp    11ce <main+0x7e>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <remove_comment@plt>
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
lea    0xe4e(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x19000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"fuckyou.c\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [102400 x i8]
store i32 0, i32* %1
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5, i32 0)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %34
10: ; preds = %0
%11 = load i32, i32* %2
%12 = getelementptr inbounds [102400 x i8], [102400 x i8]* %4, i64 0, i64 0
%13 = call i32 @read(i32 %11, i8* %12, i32 102400)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, -1
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16, %10
%20 = load i32, i32* %2
%21 = call i32 @close(i32 %20)
store i32 -1, i32* %1
br label %34
22: ; preds = %16
%23 = getelementptr inbounds [102400 x i8], [102400 x i8]* %4, i64 0, i64 0
%24 = load i32, i32* %3
%25 = call i32 @remove_comment(i8* %23, i32 %24)
%26 = getelementptr inbounds [102400 x i8], [102400 x i8]* %4, i64 0, i64 0
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
%30 = getelementptr inbounds [102400 x i8], [102400 x i8]* %4, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %2
%33 = call i32 @close(i32 %32)
br label %34
34: ; preds = %22, %19, %9
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [10 x i8] c"fuckyou.c\00"
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [102400 x i8]
%2 = getelementptr inbounds [102400 x i8], [102400 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %18, label %6
6: ; preds = %0
%7 = call i32 @read(i32 %4, i8* %2, i32 102400)
%8 = add i32 %7, 1
%9 = icmp ult i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @close(i32 %4)
br label %18
12: ; preds = %6
%13 = call i32 @remove_comment(i8* %2, i32 %7)
%14 = sext i32 %7 to i64
%15 = getelementptr inbounds [102400 x i8], [102400 x i8]* %1, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%17 = call i32 @close(i32 %4)
br label %18
18: ; preds = %0, %12, %10
%19 = phi i32 [ -1, %10 ], [ 0, %12 ], [ -1, %0 ]
ret i32 %19
}