#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*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int get_in(int mode, const char *input_file, FILE **in) {
  if (input_file == NULL && !(mode & (1 << 4))) {
    fprintf(stderr, "bfc: error: no input files\ncompilation terminated.\n");
    return -1;
  }
  if (mode & (1 << 4))
    *in = stdin;
  else {
    *in = fopen(input_file, "r");
    if (mode & (1 << 5))
      printf("opening file %s\n", input_file);
  }
  if (*in == NULL) {
    fprintf(stderr, "error: couldn't open file %s: ", input_file);
    perror(NULL);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1190 <get_in+0x50>
mov    -0x8(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
jne    1190 <get_in+0x50>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1238 <get_in+0xf8>
mov    -0x8(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11b5 <get_in+0x75>
mov    0x2e42(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11f3 <get_in+0xb3>
mov    -0x10(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11ee <get_in+0xae>
mov    -0x10(%rbp),%rsi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
jmp    11f3 <get_in+0xb3>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1231 <get_in+0xf1>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1238 <get_in+0xf8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_in>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
test   %rsi,%rsi
jne    1176 <get_in+0x36>
mov    %ebp,%eax
and    $0x10,%eax
jne    1176 <get_in+0x36>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%ecx
jmp    11bc <get_in+0x7c>
test   $0x10,%bpl
jne    11a8 <get_in+0x68>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,(%r14)
test   $0x20,%bpl
je     11b5 <get_in+0x75>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    (%r14),%rax
jmp    11b5 <get_in+0x75>
mov    0x2e39(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%r14)
xor    %ecx,%ecx
test   %rax,%rax
je     11c3 <get_in+0x83>
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1060 <perror@plt>
jmp    116f <get_in+0x2f>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"bfc: error: no input files\0Acompilation terminated.\0A\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"opening file %s\0A\00"
@.str.3 = [31 x i8] c"error: couldn't open file %s: \00"
define i32 @get_in(i32 %0, i8* %1, i32** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32**
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32** %2, i32*** %7
%8 = load i8*, i8** %6
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = load i32, i32* %5
%12 = and i32 %11, 16
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %45
17: ; preds = %10, %3
%18 = load i32, i32* %5
%19 = and i32 %18, 16
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32*, i32** @stdin
%23 = load i32**, i32*** %7
store i32* %22, i32** %23
br label %35
24: ; preds = %17
%25 = load i8*, i8** %6
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32**, i32*** %7
store i32* %26, i32** %27
%28 = load i32, i32* %5
%29 = and i32 %28, 32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i8*, i8** %6
%33 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %24
br label %35
35: ; preds = %34, %21
%36 = load i32**, i32*** %7
%37 = load i32*, i32** %36
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %6
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = call i32 @perror(i32* null)
store i32 -1, i32* %4
br label %45
44: ; preds = %35
store i32 0, i32* %4
br label %45
45: ; preds = %44, %39, %14
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"bfc: error: no input files\0Acompilation terminated.\0A\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"opening file %s\0A\00"
@.str.3 = [31 x i8] c"error: couldn't open file %s: \00"
define i32 @get_in(i32 %0, i8* %1, i32** nocapture %2) {
%4 = icmp eq i8* %1, null
%5 = and i32 %0, 16
%6 = icmp eq i32 %5, 0
%7 = and i1 %4, %6
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %28
11: ; preds = %3
br i1 %6, label %14, label %12
12: ; preds = %11
%13 = load i32*, i32** @stdin
store i32* %13, i32** %2
br label %21
14: ; preds = %11
%15 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %2
%16 = and i32 %0, 32
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%20 = load i32*, i32** %2
br label %21
21: ; preds = %14, %18, %12
%22 = phi i32* [ %15, %14 ], [ %20, %18 ], [ %13, %12 ]
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%27 = tail call i32 @perror(i32* null)
br label %28
28: ; preds = %21, %24, %8
%29 = phi i32 [ -1, %24 ], [ -1, %8 ], [ 0, %21 ]
ret i32 %29
}