#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*/ compile(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ parse(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int system(char *);
int main(int argc, char *argv[]) {
  char *cmd;
  FILE *in, *out;
  if (argc < 2 || argc > 3) {
    printf("Usage: screw <brainprog.bf> [<output_executable>]\n");
    return 1;
  }
  in = fopen(argv[1], "r+");
  out = fopen("temp.c", "w+");
  parse(in, out);
  cmd = argv[2];
  compile("temp.c", cmd);
  return system(cmd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     117a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jle    1192 <main+0x42>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe85(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <parse@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1050 <compile@plt>
mov    -0x18(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
add    $0xfffffffc,%edi
cmp    $0xfffffffd,%edi
ja     1174 <main+0x24>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe72(%rip),%r15
lea    0xe72(%rip),%rsi
mov    %r15,%rdi
call   1060 <fopen@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <parse@plt>
mov    0x10(%rbx),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <compile@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <system@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"Usage: screw <brainprog.bf> [<output_executable>]\0A\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [7 x i8] c"temp.c\00"
@.str.3 = [3 x i8] c"w+\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %32
16: ; preds = %11
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
%21 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %21, i32** %8
%22 = load i32*, i32** %7
%23 = load i32*, i32** %8
%24 = call i32 @parse(i32* %22, i32* %23)
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = call i32 @compile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %6
%31 = call i32 @system(i8* %30)
store i32 %31, i32* %3
br label %32
32: ; preds = %16, %14
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [7 x i8] c"temp.c\00"
@.str.3 = [3 x i8] c"w+\00"
@str = [50 x i8] c"Usage: screw <brainprog.bf> [<output_executable>]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -4
%4 = icmp ult i32 %3, -2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
br label %17
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @parse(i32* %10, i32* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @compile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = tail call i32 @system(i8* %14)
br label %17
17: ; preds = %7, %5
%18 = phi i32 [ 1, %5 ], [ %16, %7 ]
ret i32 %18
}