#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 MYSOFA_HRTF {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ mysofa_free(struct MYSOFA_HRTF *);
struct MYSOFA_HRTF *mysofa_load(char *, int *);
int /*<<< orphan*/ printJson(int /*<<< orphan*/, struct MYSOFA_HRTF *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  struct MYSOFA_HRTF *hrtf = NULL;
  int err = 0;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <FILE.SOFA>\n", argv[0]);
    return 1;
  }
  hrtf = mysofa_load(argv[1], &err);
  if (!hrtf) {
    fprintf(stderr, "Error reading file %s. Error code: %d\n", argv[1], err);
    return err;
  }
  printJson(stdout, hrtf);
  mysofa_free(hrtf);
  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)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1199 <main+0x59>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1208 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <mysofa_load@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e6 <main+0xa6>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1208 <main+0xc8>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1040 <printJson@plt>
mov    -0x18(%rbp),%rdi
call   1050 <mysofa_free@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
mov    %rsi,%rbx
movl   $0x0,0x4(%rsp)
cmp    $0x2,%edi
jne    1187 <main+0x47>
mov    0x8(%rbx),%rdi
lea    0x4(%rsp),%rsi
call   1030 <mysofa_load@plt>
test   %rax,%rax
je     11a8 <main+0x68>
mov    %rax,%r14
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <printJson@plt>
mov    %r14,%rdi
call   1050 <mysofa_free@plt>
xor    %eax,%eax
jmp    11cb <main+0x8b>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe66(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    11cb <main+0x8b>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
mov    0x4(%rsp),%ecx
lea    0xe57(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.MYSOFA_HRTF = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s <FILE.SOFA>\0A\00"
@.str.1 = [39 x i8] c"Error reading file %s. Error code: %d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.MYSOFA_HRTF*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.MYSOFA_HRTF* null, %struct.MYSOFA_HRTF** %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %37
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call %struct.MYSOFA_HRTF* @mysofa_load(i8* %19, i32* %7)
store %struct.MYSOFA_HRTF* %20, %struct.MYSOFA_HRTF** %6
%21 = load %struct.MYSOFA_HRTF*, %struct.MYSOFA_HRTF** %6
%22 = icmp ne %struct.MYSOFA_HRTF* %21, null
br i1 %22, label %31, label %23
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i32, i32* %7
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %27, i32 %28)
%30 = load i32, i32* %7
store i32 %30, i32* %3
br label %37
31: ; preds = %16
%32 = load i32, i32* @stdout
%33 = load %struct.MYSOFA_HRTF*, %struct.MYSOFA_HRTF** %6
%34 = call i32 @printJson(i32 %32, %struct.MYSOFA_HRTF* %33)
%35 = load %struct.MYSOFA_HRTF*, %struct.MYSOFA_HRTF** %6
%36 = call i32 @mysofa_free(%struct.MYSOFA_HRTF* %35)
store i32 0, i32* %3
br label %37
37: ; preds = %31, %23, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
%struct.MYSOFA_HRTF = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s <FILE.SOFA>\0A\00"
@.str.1 = [39 x i8] c"Error reading file %s. Error code: %d\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %25
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call %struct.MYSOFA_HRTF* @mysofa_load(i8* %12, i32* %3)
%14 = icmp eq %struct.MYSOFA_HRTF* %13, null
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = load i32, i32* %3
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i32, i32* %3
br label %25
21: ; preds = %10
%22 = load i32, i32* @stdout
%23 = call i32 @printJson(i32 %22, %struct.MYSOFA_HRTF* %13)
%24 = call i32 @mysofa_free(%struct.MYSOFA_HRTF* %13)
br label %25
25: ; preds = %21, %15, %6
%26 = phi i32 [ 1, %6 ], [ 0, %21 ], [ %20, %15 ]
ret i32 %26
}