#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*/ debugMsg(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int createFile(char *file) {
  debugMsg("createFile() ...");
  FILE *fptr;
  if ((fptr = fopen(file, "w")) == NULL) {
    return 1;
  }
  fclose(fptr);
  debugMsg("createFile() ... ok ...");
  return 0;
}


x86 assembly (clang, -O0):
<createFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rdi
call   1040 <debugMsg@plt>
mov    -0x10(%rbp),%rdi
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1172 <createFile+0x42>
movl   $0x1,-0x4(%rbp)
jmp    118e <createFile+0x5e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe91(%rip),%rdi
call   1040 <debugMsg@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createFile>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rdi
call   1040 <debugMsg@plt>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
test   %rax,%rax
je     116c <createFile+0x3c>
mov    %rax,%rdi
call   1030 <fclose@plt>
lea    0xeb0(%rip),%rdi
call   1040 <debugMsg@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

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

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