#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 EACCES;
int /*<<< orphan*/ O_CREAT;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int S_IXOTH;
int open(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main() {
  int fichero;
  fichero = open("./ej_fichero", O_CREAT,
                 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | S_IXOTH);
  if (fichero == -1) {
    return -EACCES;
  }
  printf("Fichero creado con éxito.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%esi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
mov    0x2e90(%rip),%rax
or     (%rax),%edx
mov    0x2e6f(%rip),%rax
or     (%rax),%edx
mov    0x2e5e(%rip),%rax
or     (%rax),%edx
mov    0x2e7d(%rip),%rax
or     (%rax),%edx
lea    0xe94(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1191 <main+0x71>
xor    %eax,%eax
mov    0x2e49(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <main+0x84>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e88(%rip),%rax
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e86(%rip),%rax
or     (%rax),%edx
mov    0x2eb5(%rip),%rax
mov    0x2e6e(%rip),%rcx
or     (%rcx),%edx
mov    (%rax),%esi
mov    0x2e8b(%rip),%rax
or     (%rax),%edx
lea    0xea2(%rip),%rdi
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     1178 <main+0x58>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2e51(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"./ej_fichero\00"
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@EACCES = global i32 0
@.str.1 = [28 x i8] c"Fichero creado con \C3\A9xito.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @O_CREAT
%4 = load i32, i32* @S_IRUSR
%5 = load i32, i32* @S_IWUSR
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IRGRP
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IROTH
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IXOTH
%12 = or i32 %10, %11
%13 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %12)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = load i32, i32* @EACCES
%18 = sub nsw i32 0, %17
store i32 %18, i32* %1
br label %21
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %21
21: ; preds = %19, %16
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [13 x i8] c"./ej_fichero\00"
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@S_IXOTH = global i32 0
@EACCES = global i32 0
@str = [27 x i8] c"Fichero creado con \C3\A9xito.\00"
define i32 @main() {
%1 = load i32, i32* @O_CREAT
%2 = load i32, i32* @S_IRUSR
%3 = load i32, i32* @S_IWUSR
%4 = or i32 %3, %2
%5 = load i32, i32* @S_IRGRP
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IROTH
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IXOTH
%10 = or i32 %8, %9
%11 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* @EACCES
%15 = sub nsw i32 0, %14
br label %18
16: ; preds = %0
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ %15, %13 ], [ 0, %16 ]
ret i32 %19
}