#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 */
int /*<<< orphan*/ SEEK_END;
scalar_t__ checkSyntax(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int compile(FILE *inputFile, FILE *outputFile) {
  long len;
  char *inputCode;
  fseek(inputFile, 0, SEEK_END);
  len = ftell(inputFile);
  rewind(inputFile);
  inputCode = malloc(len + 1 * sizeof(char));
  fread(inputCode, sizeof(char), len, inputFile);
  if (checkSyntax(inputCode) == 0) {
    fprintf(outputFile, ",[>,]<%s[.>]\n", inputCode);
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<compile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x28(%rbp),%rdi
call   1050 <checkSyntax@plt>
cmp    $0x0,%rax
jne    1204 <compile+0x94>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe0d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120b <compile+0x9b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbp
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbp,%rdi
call   1070 <ftell@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <rewind@plt>
lea    0x1(%rbx),%rdi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    $0x1,%r15d
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
call   1050 <checkSyntax@plt>
test   %rax,%rax
jne    11e8 <compile+0x78>
lea    0xe26(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
call   1060 <fprintf@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
@.str = [14 x i8] c",[>,]<%s[.>]\0A\00"
define i32 @compile(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = load i32*, i32** %4
%9 = load i32, i32* @SEEK_END
%10 = call i32 @fseek(i32* %8, i32 0, i32 %9)
%11 = load i32*, i32** %4
%12 = call i64 @ftell(i32* %11)
store i64 %12, i64* %6
%13 = load i32*, i32** %4
%14 = call i32 @rewind(i32* %13)
%15 = load i64, i64* %6
%16 = add i64 %15, 1
%17 = call i8* @malloc(i64 %16)
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = load i64, i64* %6
%20 = load i32*, i32** %4
%21 = call i32 @fread(i8* %18, i32 1, i64 %19, i32* %20)
%22 = load i8*, i8** %7
%23 = call i64 @checkSyntax(i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = load i32*, i32** %5
%27 = load i8*, i8** %7
%28 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 0, i32* %3
br label %30
29: ; preds = %2
store i32 1, i32* %3
br label %30
30: ; preds = %29, %25
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@.str = [14 x i8] c",[>,]<%s[.>]\0A\00"
define i32 @compile(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %0, i32 0, i32 %3)
%5 = tail call i64 @ftell(i32* %0)
%6 = tail call i32 @rewind(i32* %0)
%7 = add i64 %5, 1
%8 = tail call i8* @malloc(i64 %7)
%9 = tail call i32 @fread(i8* %8, i32 1, i64 %5, i32* %0)
%10 = tail call i64 @checkSyntax(i8* %8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %14
14: ; preds = %2, %12
%15 = phi i32 [ 0, %12 ], [ 1, %2 ]
ret i32 %15
}