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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ bf_compile(int /*<<< orphan*/, char *);
char *bf_read(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  if (argc != 2) {
    puts("usage: bf2c <bf-file>");
    exit(EXIT_FAILURE);
  }
  char *text = bf_read(argv[1]);
  if (!text) {
    perror("bf2c");
    exit(EXIT_FAILURE);
  }
  bf_compile(stdout, text);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118a <main+0x3a>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <bf_read@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c0 <main+0x70>
lea    0xe69(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <bf_compile@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1179 <main+0x29>
mov    0x8(%rsi),%rdi
call   1050 <bf_read@plt>
test   %rax,%rax
je     1187 <main+0x37>
mov    0x2e6d(%rip),%rcx
mov    (%rcx),%edi
mov    %rax,%rsi
call   1030 <bf_compile@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe80(%rip),%rdi
call   1040 <puts@plt>
jmp    1193 <main+0x43>
lea    0xe88(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"usage: bf2c <bf-file>\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"bf2c\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i8* @bf_read(i8* %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %13
%25 = load i32, i32* @stdout
%26 = load i8*, i8** %6
%27 = call i32 @bf_compile(i32 %25, i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"usage: bf2c <bf-file>\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"bf2c\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @bf_read(i8* %10)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %8
%18 = load i32, i32* @stdout
%19 = tail call i32 @bf_compile(i32 %18, i8* %11)
ret i32 0
}