#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*/ 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*/ perror(char *);
int main() {
  int fd;
  fd = open("./ejercicio3", O_CREAT,
            S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH | S_IXOTH);
  if (fd == -1) {
    perror("Error open");
  }
  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    0x2e79(%rip),%rax
mov    (%rax),%edx
mov    0x2e90(%rip),%rax
or     (%rax),%edx
mov    0x2e77(%rip),%rax
or     (%rax),%edx
mov    0x2e66(%rip),%rax
or     (%rax),%edx
mov    0x2e7d(%rip),%rax
or     (%rax),%edx
lea    0xe94(%rip),%rdi
call   1030 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    118a <main+0x6a>
lea    0xe88(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e90(%rip),%rax
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e8e(%rip),%rax
or     (%rax),%edx
mov    0x2eb5(%rip),%rax
mov    0x2e76(%rip),%rcx
or     (%rcx),%edx
mov    (%rax),%esi
mov    0x2e8b(%rip),%rax
or     (%rax),%edx
lea    0xea2(%rip),%rdi
call   1030 <open@plt>
cmp    $0xffffffff,%eax
je     116c <main+0x4c>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe9a(%rip),%rdi
call   1040 <perror@plt>
jmp    1168 <main+0x48>

LLVM IR (-O0):
@.str = [13 x i8] c"./ejercicio3\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
@.str.1 = [11 x i8] c"Error open\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 %18
16: ; preds = %0
%17 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"./ejercicio3\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
@.str.1 = [11 x i8] c"Error open\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 %15
13: ; preds = %0
%14 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
ret i32 0
}