#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fwrite(char const *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ lex(int /*<<< orphan*/ *, int);
int main() {
  const char buffer[] = "int buffer [1024]";
  const char fn[] = "input.txt";
  FILE *f = fopen(fn, "w");
  fwrite(buffer, 1, sizeof(buffer), f);
  fclose(f);
  f = fopen(fn, "rb");
  int result = !lex(f, sizeof(buffer));
  fclose(f);
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea4(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x2a(%rbp)
mov    0xe98(%rip),%ax
mov    %ax,-0x22(%rbp)
lea    -0x2a(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
mov    $0x12,%edx
call   1060 <fwrite@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x2a(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x12,%esi
call   1030 <lex@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x5d,0x20(%rsp)
movabs $0x78742e7475706e69,%rax
2e 74 78
mov    %rax,(%rsp)
movw   $0x74,0x8(%rsp)
lea    0xea5(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x12,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe73(%rip),%rsi
mov    %r14,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x12,%esi
call   1030 <lex@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.buffer = [18 x i8] c"int buffer [1024]\00"
@__const.main.fn = [10 x i8] c"input.txt\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [18 x i8]* %2 to i8*
%7 = bitcast [10 x i8]* %3 to i8*
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %4
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i32 @fwrite(i8* %10, i32 1, i32 18, i32* %11)
%13 = load i32*, i32** %4
%14 = call i32 @fclose(i32* %13)
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %4
%17 = load i32*, i32** %4
%18 = call i32 @lex(i32* %17, i32 18)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
store i32 %21, i32* %5
%22 = load i32*, i32** %4
%23 = call i32 @fclose(i32* %22)
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
@__const.main.buffer = [18 x i8] c"int buffer [1024]\00"
@__const.main.fn = [10 x i8] c"input.txt\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"rb\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @fwrite(i8* %3, i32 1, i32 18, i32* %5)
%7 = tail call i32 @fclose(i32* %5)
%8 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @lex(i32* %8, i32 18)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @fclose(i32* %8)
ret i32 %11
}