#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 O_CREAT;
int O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ my_putstr(char *);
int open(char *, int, int);
int create_file(char *str) {
  int fd;
  if ((fd = open(str, O_CREAT | O_WRONLY | O_RDONLY | O_TRUNC,
                 S_IRUSR | S_IWUSR)) == -1)
    my_putstr("Error Open New File\n");
  return (fd);
}


x86 assembly (clang, -O0):
<create_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ec1(%rip),%rax
mov    (%rax),%esi
mov    0x2e70(%rip),%rax
or     (%rax),%esi
mov    0x2e8f(%rip),%rax
or     (%rax),%esi
mov    0x2e9e(%rip),%rax
or     (%rax),%esi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
mov    0x2e6c(%rip),%rax
or     (%rax),%edx
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    1183 <create_file+0x63>
lea    0xe82(%rip),%rdi
call   1030 <my_putstr@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_file>:
push   %rbx
mov    0x2ed0(%rip),%rax
mov    0x2e81(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e9e(%rip),%rax
or     (%rax),%esi
mov    0x2ead(%rip),%rax
or     (%rax),%esi
mov    0x2e74(%rip),%rax
mov    0x2e7d(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
call   1040 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    116f <create_file+0x4f>
lea    0xe96(%rip),%rdi
call   1030 <my_putstr@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_RDONLY = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str = [21 x i8] c"Error Open New File\0A\00"
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_CREAT
%6 = load i32, i32* @O_WRONLY
%7 = or i32 %5, %6
%8 = load i32, i32* @O_RDONLY
%9 = or i32 %7, %8
%10 = load i32, i32* @O_TRUNC
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IRUSR
%13 = load i32, i32* @S_IWUSR
%14 = or i32 %12, %13
%15 = call i32 @open(i8* %4, i32 %11, i32 %14)
store i32 %15, i32* %3
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i32 @my_putstr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %1
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_RDONLY = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str = [21 x i8] c"Error Open New File\0A\00"
define i32 @create_file(i8* nocapture %0) {
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_WRONLY
%4 = or i32 %3, %2
%5 = load i32, i32* @O_RDONLY
%6 = or i32 %4, %5
%7 = load i32, i32* @O_TRUNC
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IRUSR
%10 = load i32, i32* @S_IWUSR
%11 = or i32 %10, %9
%12 = tail call i32 @open(i8* %0, i32 %8, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = tail call i32 @my_putstr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %1
ret i32 %12
}