#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int S_IREAD;
int S_IWRITE;
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int open(char *, int, int);
int create_file(char *filename) {
  int fp_bkplog;
  fp_bkplog = open(filename, O_RDWR | O_TRUNC | O_CREAT, S_IREAD | S_IWRITE);
  if (fp_bkplog == -1) {
    error("Could not open output log file");
    exit(EXIT_FAILURE);
  }
  return fp_bkplog;
}


x86 assembly (clang, -O0):
<create_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2ea0(%rip),%rax
or     (%rax),%esi
mov    0x2e9f(%rip),%rax
or     (%rax),%esi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    0x2e65(%rip),%rax
or     (%rax),%edx
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1199 <create_file+0x69>
lea    0xe7a(%rip),%rdi
call   1030 <error@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_file>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    0x2eb1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2eae(%rip),%rax
or     (%rax),%esi
mov    0x2e65(%rip),%rax
mov    0x2e76(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     116a <create_file+0x3a>
pop    %rcx
ret
lea    0xe8f(%rip),%rdi
call   1030 <error@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@.str = [31 x i8] c"Could not open output log file\00"
@EXIT_FAILURE = global i32 0
define i32 @create_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = load i32, i32* @O_CREAT
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IREAD
%11 = load i32, i32* @S_IWRITE
%12 = or i32 %10, %11
%13 = call i32 @open(i8* %4, i32 %9, i32 %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = call i32 @error(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %1
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@.str = [31 x i8] c"Could not open output log file\00"
@EXIT_FAILURE = global i32 0
define i32 @create_file(i8* nocapture %0) {
%2 = load i32, i32* @O_RDWR
%3 = load i32, i32* @O_TRUNC
%4 = or i32 %3, %2
%5 = load i32, i32* @O_CREAT
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IREAD
%8 = load i32, i32* @S_IWRITE
%9 = or i32 %8, %7
%10 = tail call i32 @open(i8* %0, i32 %6, i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = tail call i32 @error(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %1
ret i32 %10
}