#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*/ *fopen(char *, char *);
int outEx(unsigned char *, int, int, int, int, int /*<<< orphan*/ *,
          int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
bool out(unsigned char *data, int inOffset, int size, int intSize, bool swap,
         char *out) {
  int result;
  FILE *fout;
  fout = fopen(out, "wb");
  if (!fout) {
    printf("Error: couldn't create output file %s\n", out);
    return false;
  }
  result = outEx(data, inOffset, size, intSize, swap, fout, 0);
  fclose(fout);
  return result;
}


x86 assembly (clang, -O0):
<out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1198 <out+0x58>
mov    -0x28(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cd <out+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x38(%rbp),%r9
xor    %eax,%eax
movl   $0x0,(%rsp)
call   1040 <outEx@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<out>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbp
mov    %r8d,0x14(%rsp)
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%r13d
mov    %rdi,%r14
lea    0xe97(%rip),%rsi
mov    %r9,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a7 <out+0x67>
mov    %rax,%rbx
movl   $0x0,(%rsp)
mov    %r14,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
mov    0x14(%rsp),%r8d
mov    %rax,%r9
call   1040 <outEx@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %ebp,%eax
jmp    11b8 <out+0x78>
lea    0xe55(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [39 x i8] c"Error: couldn't create output file %s\0A\00"
define i32 @out(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i8* %5, i8** %13
%16 = load i8*, i8** %13
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %15
%18 = load i32*, i32** %15
%19 = icmp ne i32* %18, null
br i1 %19, label %23, label %20
20: ; preds = %6
%21 = load i8*, i8** %13
%22 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 0, i32* %7
br label %34
23: ; preds = %6
%24 = load i8*, i8** %8
%25 = load i32, i32* %9
%26 = load i32, i32* %10
%27 = load i32, i32* %11
%28 = load i32, i32* %12
%29 = load i32*, i32** %15
%30 = call i32 @outEx(i8* %24, i32 %25, i32 %26, i32 %27, i32 %28, i32* %29, i32 0)
store i32 %30, i32* %14
%31 = load i32*, i32** %15
%32 = call i32 @fclose(i32* %31)
%33 = load i32, i32* %14
store i32 %33, i32* %7
br label %34
34: ; preds = %23, %20
%35 = load i32, i32* %7
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.1 = [39 x i8] c"Error: couldn't create output file %s\0A\00"
define i32 @out(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5) {
%7 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %14
11: ; preds = %6
%12 = tail call i32 @outEx(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %7, i32 0)
%13 = tail call i32 @fclose(i32* %7)
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %12, %11 ], [ 0, %9 ]
ret i32 %15
}