#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 */
struct bfvm {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ bfvm_destroy(struct bfvm *);
struct bfvm *bfvm_init();
int /*<<< orphan*/ bfvm_load(struct bfvm *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bfvm_run(struct bfvm *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *stdin;
int main(int argc, char *argv[]) {
  FILE *fp;
  if (argc == 1) {
    fp = stdin;
  } else {
    fp = fopen(argv[1], "rb");
  }
  if (fp == NULL)
    return 0;
  struct bfvm *bv = bfvm_init();
  bfvm_load(bv, fp);
  bfvm_run(bv);
  bfvm_destroy(bv);
  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   $0x1,-0x8(%rbp)
jne    1183 <main+0x33>
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    119b <main+0x4b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b2 <main+0x62>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <main+0x93>
mov    $0x0,%al
call   1060 <bfvm_init@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <bfvm_load@plt>
mov    -0x20(%rbp),%rdi
call   1040 <bfvm_run@plt>
mov    -0x20(%rbp),%rdi
call   1050 <bfvm_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    116a <main+0x1a>
mov    0x2e88(%rip),%rax
mov    (%rax),%r14
test   %r14,%r14
jne    1182 <main+0x32>
jmp    11a7 <main+0x57>
mov    0x8(%rsi),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %r14,%r14
je     11a7 <main+0x57>
xor    %eax,%eax
call   1060 <bfvm_init@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <bfvm_load@plt>
mov    %rbx,%rdi
call   1040 <bfvm_run@plt>
mov    %rbx,%rdi
call   1050 <bfvm_destroy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.bfvm = type { i32 }
@stdin = global i32* null
@.str = [3 x i8] c"rb\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.bfvm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32*, i32** @stdin
store i32* %11, i32** %6
br label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
br label %17
17: ; preds = %12, %10
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %17
store i32 0, i32* %3
br label %30
21: ; preds = %17
%22 = call %struct.bfvm* (...) @bfvm_init()
store %struct.bfvm* %22, %struct.bfvm** %7
%23 = load %struct.bfvm*, %struct.bfvm** %7
%24 = load i32*, i32** %6
%25 = call i32 @bfvm_load(%struct.bfvm* %23, i32* %24)
%26 = load %struct.bfvm*, %struct.bfvm** %7
%27 = call i32 @bfvm_run(%struct.bfvm* %26)
%28 = load %struct.bfvm*, %struct.bfvm** %7
%29 = call i32 @bfvm_destroy(%struct.bfvm* %28)
store i32 0, i32* %3
br label %30
30: ; preds = %21, %20
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.bfvm = type { i32 }
@stdin = global i32* null
@.str = [3 x i8] c"rb\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = load i32*, i32** @stdin
br label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %6, %4
%11 = phi i32* [ %5, %4 ], [ %9, %6 ]
%12 = icmp eq i32* %11, null
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = tail call %struct.bfvm* (...) @bfvm_init()
%15 = tail call i32 @bfvm_load(%struct.bfvm* %14, i32* %11)
%16 = tail call i32 @bfvm_run(%struct.bfvm* %14)
%17 = tail call i32 @bfvm_destroy(%struct.bfvm* %14)
br label %18
18: ; preds = %10, %13
ret i32 0
}