#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ hexDumpFileContentsToFile(char const *,
                                             int /*<<< orphan*/ *);
scalar_t__ rtxFileOpen(int /*<<< orphan*/ **, char const *, char *);
int rtxHexDumpFileContentsToFile(const char *inFilePath,
                                 const char *outFilePath) {
  FILE *fp;
  if (rtxFileOpen(&fp, outFilePath, "w") == 0) {
    hexDumpFileContentsToFile(inFilePath, fp);
    fclose(fp);
  } else {
    return -30;
  }
  return 0;
}


x86 assembly (clang, -O0):
<rtxHexDumpFileContentsToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdi
lea    0xeb1(%rip),%rdx
call   1050 <rtxFileOpen@plt>
cmp    $0x0,%rax
jne    1179 <rtxHexDumpFileContentsToFile+0x49>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <hexDumpFileContentsToFile@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1185 <rtxHexDumpFileContentsToFile+0x55>
movl   $0xffffffe2,-0x4(%rbp)
jmp    118c <rtxHexDumpFileContentsToFile+0x5c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtxHexDumpFileContentsToFile>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdx
lea    0x8(%rsp),%rdi
call   1050 <rtxFileOpen@plt>
mov    %rax,%rcx
mov    $0xffffffe2,%eax
test   %rcx,%rcx
jne    116f <rtxHexDumpFileContentsToFile+0x3f>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <hexDumpFileContentsToFile@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
define i32 @rtxHexDumpFileContentsToFile(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i64 @rtxFileOpen(i32** %6, i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i32*, i32** %6
%13 = call i32 @hexDumpFileContentsToFile(i8* %11, i32* %12)
%14 = load i32*, i32** %6
%15 = call i32 @fclose(i32* %14)
br label %17
16: ; preds = %2
store i32 -30, i32* %3
br label %18
17: ; preds = %10
store i32 0, i32* %3
br label %18
18: ; preds = %17, %16
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
define i32 @rtxHexDumpFileContentsToFile(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
%5 = call i64 @rtxFileOpen(i32** %3, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32*, i32** %3
%9 = call i32 @hexDumpFileContentsToFile(i8* %0, i32* %8)
%10 = load i32*, i32** %3
%11 = call i32 @fclose(i32* %10)
br label %12
12: ; preds = %2, %7
%13 = phi i32 [ 0, %7 ], [ -30, %2 ]
ret i32 %13
}