#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 brainfuck(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ warn(char *, char const *);
int main(int argc, char **argv) {
  const char *filename;
  FILE *fin;
  int status = 0;
  if (argc > 1) {
    while (--argc) {
      filename = *++argv;
      if ((fin = fopen(filename, "r")) == NULL) {
        warn("couldn't open %s:", filename);
        status = 1;
        continue;
      }
      status |= brainfuck(fin, filename);
    }
  } else {
    status |= brainfuck(stdin, "<stdin>");
  }
  return status;
}


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)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11dc <main+0xac>
jmp    115c <main+0x2c>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11d7 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11bf <main+0x8f>
mov    -0x18(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1030 <warn@plt>
movl   $0x1,-0x24(%rbp)
jmp    115c <main+0x2c>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <brainfuck@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    115c <main+0x2c>
jmp    11f8 <main+0xc8>
mov    0x2e05(%rip),%rax
mov    (%rax),%rdi
lea    0xe27(%rip),%rsi
call   1040 <brainfuck@plt>
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11a0 <main+0x70>
mov    %rsi,%r12
mov    %edi,%r13d
xor    %ebp,%ebp
mov    $0x1,%r15d
lea    0xeab(%rip),%r14
jmp    117d <main+0x4d>
nopw   0x0(%rax,%rax,1)
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <warn@plt>
mov    $0x1,%ebp
add    $0x1,%r15
cmp    %r15d,%r13d
je     11c4 <main+0x94>
mov    (%r12,%r15,8),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1160 <main+0x30>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <brainfuck@plt>
or     %eax,%ebp
jmp    1174 <main+0x44>
mov    0x2e41(%rip),%rax
mov    (%rax),%rdi
lea    0xe63(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <brainfuck@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"couldn't open %s:\00"
@stdin = global i32* null
@.str.2 = [8 x i8] c"<stdin>\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
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %33
11: ; preds = %2
br label %12
12: ; preds = %26, %23, %11
%13 = load i32, i32* %4
%14 = add nsw i32 %13, -1
store i32 %14, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i32 1
store i8** %18, i8*** %5
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %7
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i8*, i8** %6
%25 = call i32 @warn(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %24)
store i32 1, i32* %8
br label %12
26: ; preds = %16
%27 = load i32*, i32** %7
%28 = load i8*, i8** %6
%29 = call i32 @brainfuck(i32* %27, i8* %28)
%30 = load i32, i32* %8
%31 = or i32 %30, %29
store i32 %31, i32* %8
br label %12
32: ; preds = %12
br label %38
33: ; preds = %2
%34 = load i32*, i32** @stdin
%35 = call i32 @brainfuck(i32* %34, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* %8
%37 = or i32 %36, %35
store i32 %37, i32* %8
br label %38
38: ; preds = %33, %32
%39 = load i32, i32* %8
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"couldn't open %s:\00"
@stdin = global i32* null
@.str.2 = [8 x i8] c"<stdin>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = add nsw i32 %0, -1
br label %6
6: ; preds = %4, %16
%7 = phi i32 [ %18, %16 ], [ %5, %4 ]
%8 = phi i32 [ %17, %16 ], [ 0, %4 ]
%9 = phi i8** [ %10, %16 ], [ %1, %4 ]
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %20
14: ; preds = %6
%15 = tail call i32 @warn(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %16
16: ; preds = %14, %20
%17 = phi i32 [ 1, %14 ], [ %22, %20 ]
%18 = add nsw i32 %7, -1
%19 = icmp eq i32 %18, 0
br i1 %19, label %26, label %6
20: ; preds = %6
%21 = tail call i32 @brainfuck(i32* %12, i8* %11)
%22 = or i32 %21, %8
br label %16
23: ; preds = %2
%24 = load i32*, i32** @stdin
%25 = tail call i32 @brainfuck(i32* %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %16, %23
%27 = phi i32 [ %25, %23 ], [ %17, %16 ]
ret i32 %27
}