#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_IROTH;
int S_IWGRP;
int S_IWOTH;
int S_IXOTH;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ umask(int);
int main() {
  int fd;
  umask(S_IWGRP | S_IROTH | S_IWOTH | S_IXOTH);
  fd = open("./ejercicio5_prueba", O_CREAT);
  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    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    0x2e79(%rip),%rax
or     (%rax),%edi
mov    0x2e60(%rip),%rax
or     (%rax),%edi
mov    0x2e7f(%rip),%rax
or     (%rax),%edi
call   1030 <umask@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xe88(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1196 <main+0x66>
lea    0xe83(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    0x2e89(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
mov    0x2e6e(%rip),%rax
or     (%rax),%edi
mov    0x2e8d(%rip),%rax
or     (%rax),%edi
call   1030 <umask@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     1178 <main+0x48>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe95(%rip),%rdi
call   1050 <perror@plt>
jmp    1174 <main+0x44>

LLVM IR (-O0):
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str = [20 x i8] c"./ejercicio5_prueba\00"
@O_CREAT = 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* @S_IWGRP
%4 = load i32, i32* @S_IROTH
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IWOTH
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IXOTH
%9 = or i32 %7, %8
%10 = call i32 @umask(i32 %9)
%11 = load i32, i32* @O_CREAT
%12 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %0
ret i32 0
}

LLVM IR (-O2):
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str = [20 x i8] c"./ejercicio5_prueba\00"
@O_CREAT = global i32 0
@.str.1 = [11 x i8] c"Error open\00"
define i32 @main() {
%1 = load i32, i32* @S_IWGRP
%2 = load i32, i32* @S_IROTH
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IWOTH
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IXOTH
%7 = or i32 %5, %6
%8 = tail call i32 @umask(i32 %7)
%9 = load i32, i32* @O_CREAT
%10 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
ret i32 0
}