#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 EXIT_SUCCESS;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
scalar_t__ creat(char *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ umask(int);
int main(void) {
  umask(0);
  if (creat("foo",
            (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
    fprintf(stderr, "Unable to create foo\n");
    exit(EXIT_FAILURE);
  }
  umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
  if (creat("bar",
            (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
    fprintf(stderr, "creat error for bar");
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <umask@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
mov    0x2e7a(%rip),%rax
or     (%rax),%esi
mov    0x2e59(%rip),%rax
or     (%rax),%esi
mov    0x2e70(%rip),%rax
or     (%rax),%esi
mov    0x2e3f(%rip),%rax
or     (%rax),%esi
mov    0x2e0e(%rip),%rax
or     (%rax),%esi
lea    0xe6d(%rip),%rdi
call   1050 <creat@plt>
cmp    $0x0,%rax
jge    11c5 <main+0x85>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
mov    0x2e13(%rip),%rax
or     (%rax),%edi
mov    0x2de2(%rip),%rax
or     (%rax),%edi
mov    0x2db1(%rip),%rax
or     (%rax),%edi
call   1040 <umask@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
mov    0x2de2(%rip),%rax
or     (%rax),%esi
mov    0x2dc1(%rip),%rax
or     (%rax),%esi
mov    0x2dd8(%rip),%rax
or     (%rax),%esi
mov    0x2da7(%rip),%rax
or     (%rax),%esi
mov    0x2d76(%rip),%rax
or     (%rax),%esi
lea    0xdff(%rip),%rdi
call   1050 <creat@plt>
cmp    $0x0,%rax
jge    125d <main+0x11d>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdd0(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <umask@plt>
mov    0x2e57(%rip),%r14
mov    0x2e80(%rip),%r15
mov    (%r15),%esi
or     (%r14),%esi
mov    0x2e5b(%rip),%r12
or     (%r12),%esi
mov    0x2e70(%rip),%r13
or     0x0(%r13),%esi
mov    0x2e3d(%rip),%rbx
or     (%rbx),%esi
mov    0x2e0c(%rip),%rbp
or     0x0(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1050 <creat@plt>
test   %rax,%rax
js     11ee <main+0xae>
mov    0x0(%r13),%edi
or     (%r12),%edi
or     (%rbx),%edi
or     0x0(%rbp),%edi
call   1040 <umask@plt>
mov    (%r15),%esi
or     (%r14),%esi
or     (%r12),%esi
or     0x0(%r13),%esi
or     (%rbx),%esi
or     0x0(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1050 <creat@plt>
test   %rax,%rax
js     1200 <main+0xc0>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
jmp    1210 <main+0xd0>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@stderr = global i32 0
@.str.1 = [22 x i8] c"Unable to create foo\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"bar\00"
@.str.3 = [20 x i8] c"creat error for bar\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @umask(i32 0)
%3 = load i32, i32* @S_IRUSR
%4 = load i32, i32* @S_IWUSR
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IRGRP
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IWGRP
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IROTH
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IWOTH
%13 = or i32 %11, %12
%14 = call i64 @creat(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %0
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %0
%22 = load i32, i32* @S_IRGRP
%23 = load i32, i32* @S_IWGRP
%24 = or i32 %22, %23
%25 = load i32, i32* @S_IROTH
%26 = or i32 %24, %25
%27 = load i32, i32* @S_IWOTH
%28 = or i32 %26, %27
%29 = call i32 @umask(i32 %28)
%30 = load i32, i32* @S_IRUSR
%31 = load i32, i32* @S_IWUSR
%32 = or i32 %30, %31
%33 = load i32, i32* @S_IRGRP
%34 = or i32 %32, %33
%35 = load i32, i32* @S_IWGRP
%36 = or i32 %34, %35
%37 = load i32, i32* @S_IROTH
%38 = or i32 %36, %37
%39 = load i32, i32* @S_IWOTH
%40 = or i32 %38, %39
%41 = call i64 @creat(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %21
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %21
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@stderr = global i32 0
@.str.1 = [22 x i8] c"Unable to create foo\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"bar\00"
@.str.3 = [20 x i8] c"creat error for bar\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @umask(i32 0)
%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_IWGRP
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IROTH
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IWOTH
%12 = or i32 %10, %11
%13 = tail call i64 @creat(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %0
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %0
%21 = load i32, i32* @S_IRGRP
%22 = load i32, i32* @S_IWGRP
%23 = or i32 %22, %21
%24 = load i32, i32* @S_IROTH
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IWOTH
%27 = or i32 %25, %26
%28 = tail call i32 @umask(i32 %27)
%29 = load i32, i32* @S_IRUSR
%30 = load i32, i32* @S_IWUSR
%31 = or i32 %30, %29
%32 = load i32, i32* @S_IRGRP
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IWGRP
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IROTH
%37 = or i32 %35, %36
%38 = load i32, i32* @S_IWOTH
%39 = or i32 %37, %38
%40 = tail call i64 @creat(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %20
%43 = load i32, i32* @stderr
%44 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = tail call i32 @exit(i32 %45)
unreachable
47: ; preds = %20
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}