#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 *);
short int createFile(char *filePath, short int overwrite) {
  if (!filePath)
    return 0;
  FILE *myFile = 0;
  if (!overwrite)
    myFile = fopen(filePath, "w");
  else
    myFile = fopen(filePath, "w+");
  if (myFile != NULL) {
    fclose(myFile);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<createFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1149 <createFile+0x29>
movw   $0x0,-0x2(%rbp)
jmp    11ae <createFile+0x8e>
movq   $0x0,-0x20(%rbp)
cmpw   $0x0,-0x12(%rbp)
jne    1175 <createFile+0x55>
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    1189 <createFile+0x69>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a8 <createFile+0x88>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movw   $0x1,-0x2(%rbp)
jmp    11ae <createFile+0x8e>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createFile>:
push   %rax
test   %rdi,%rdi
je     1153 <createFile+0x33>
test   %si,%si
lea    0xed0(%rip),%rax
lea    0xecb(%rip),%rsi
cmove  %rax,%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1153 <createFile+0x33>
mov    %rax,%rdi
call   1030 <fclose@plt>
mov    $0x1,%ax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"w+\00"
define signext i16 @createFile(i8* %0, i16 signext %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i32*
store i8* %0, i8** %4
store i16 %1, i16* %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i16 0, i16* %3
br label %26
10: ; preds = %2
store i32* null, i32** %6
%11 = load i16, i16* %5
%12 = icmp ne i16 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
br label %19
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
br label %19
19: ; preds = %16, %13
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32*, i32** %6
%24 = call i32 @fclose(i32* %23)
store i16 1, i16* %3
br label %26
25: ; preds = %19
store i16 0, i16* %3
br label %26
26: ; preds = %25, %22, %9
%27 = load i16, i16* %3
ret i16 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [3 x i8] c"w+\00"
define signext i16 @createFile(i8* %0, i16 signext %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp eq i16 %1, 0
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%7 = tail call i32* @fopen(i8* %0, i8* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @fclose(i32* %7)
br label %11
11: ; preds = %9, %4, %2
%12 = phi i16 [ 0, %2 ], [ 1, %9 ], [ 0, %4 ]
ret i16 %12
}