#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int asm_dsp_load_program(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int loadDspBinary(const char *sPath) {
  static char buf[32768 * 3];
  FILE *f = fopen(sPath, "rb");
  if (f == NULL) {
    return 0;
  }
  int len = fread(buf, 1, sizeof(buf), f);
  fclose(f);
  return asm_dsp_load_program(buf, len / 3);
}


x86 assembly (clang, -O0):
<loadDspBinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1177 <loadDspBinary+0x37>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <loadDspBinary+0x79>
mov    -0x18(%rbp),%rcx
lea    0x2ece(%rip),%rdi
mov    $0x1,%esi
mov    $0x18000,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0x2e9f(%rip),%rdi
call   1050 <asm_dsp_load_program@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadDspBinary>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a1 <loadDspBinary+0x61>
mov    %rax,%rbx
lea    0x2ef1(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x18000,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
movslq %ebp,%rax
imul   $0x55555556,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <asm_dsp_load_program@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@loadDspBinary.buf = internal global [98304 x i8] zeroinitializer
@.str = [3 x i8] c"rb\00"
define i32 @loadDspBinary(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %19
11: ; preds = %1
%12 = load i32*, i32** %4
%13 = call i32 @fread(i8* getelementptr inbounds ([98304 x i8], [98304 x i8]* @loadDspBinary.buf, i64 0, i64 0), i32 1, i32 98304, i32* %12)
store i32 %13, i32* %5
%14 = load i32*, i32** %4
%15 = call i32 @fclose(i32* %14)
%16 = load i32, i32* %5
%17 = sdiv i32 %16, 3
%18 = call i32 @asm_dsp_load_program(i8* getelementptr inbounds ([98304 x i8], [98304 x i8]* @loadDspBinary.buf, i64 0, i64 0), i32 %17)
store i32 %18, i32* %2
br label %19
19: ; preds = %11, %10
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@loadDspBinary.buf = internal global [98304 x i8] zeroinitializer
@.str = [3 x i8] c"rb\00"
define i32 @loadDspBinary(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 @fread(i8* getelementptr inbounds ([98304 x i8], [98304 x i8]* @loadDspBinary.buf, i64 0, i64 0), i32 1, i32 98304, i32* %2)
%6 = tail call i32 @fclose(i32* %2)
%7 = sdiv i32 %5, 3
%8 = tail call i32 @asm_dsp_load_program(i8* getelementptr inbounds ([98304 x i8], [98304 x i8]* @loadDspBinary.buf, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %1, %4
%10 = phi i32 [ %8, %4 ], [ 0, %1 ]
ret i32 %10
}