#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_RDWR;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int open(char *, int, int);
int /*<<< orphan*/ umask(int);
int main() {
  int fd1, fd2;
  umask(0);
  fd1 = open("file1", O_CREAT | O_RDWR,
             (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
  umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
  fd2 = open("file2", O_CREAT | O_RDWR,
             (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1030 <umask@plt>
mov    0x2ebb(%rip),%rax
mov    (%rax),%esi
mov    0x2e9a(%rip),%rax
or     (%rax),%esi
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
mov    0x2e78(%rip),%rax
or     (%rax),%edx
mov    0x2e5f(%rip),%rax
or     (%rax),%edx
mov    0x2e6e(%rip),%rax
or     (%rax),%edx
mov    0x2e45(%rip),%rax
or     (%rax),%edx
mov    0x2e24(%rip),%rax
or     (%rax),%edx
lea    0xe7b(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    0x2e3b(%rip),%rax
or     (%rax),%edi
mov    0x2e12(%rip),%rax
or     (%rax),%edi
mov    0x2df1(%rip),%rax
or     (%rax),%edi
call   1030 <umask@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
mov    0x2e1a(%rip),%rax
or     (%rax),%esi
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
mov    0x2df8(%rip),%rax
or     (%rax),%edx
mov    0x2ddf(%rip),%rax
or     (%rax),%edx
mov    0x2dee(%rip),%rax
or     (%rax),%edx
mov    0x2dc5(%rip),%rax
or     (%rax),%edx
mov    0x2da4(%rip),%rax
or     (%rax),%edx
lea    0xe01(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%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   1030 <umask@plt>
mov    0x2ebf(%rip),%rax
mov    0x2ea0(%rip),%r12
mov    (%r12),%esi
or     (%rax),%esi
mov    0x2e63(%rip),%rax
mov    0x2e7c(%rip),%r13
mov    0x0(%r13),%edx
or     (%rax),%edx
mov    0x2e5f(%rip),%rbx
or     (%rbx),%edx
mov    0x2e6e(%rip),%rbp
or     0x0(%rbp),%edx
mov    0x2e44(%rip),%r14
or     (%r14),%edx
mov    0x2e22(%rip),%r15
or     (%r15),%edx
lea    0xe78(%rip),%rdi
call   1040 <open@plt>
mov    0x0(%rbp),%edi
or     (%rbx),%edi
or     (%r14),%edi
or     (%r15),%edi
call   1030 <umask@plt>
mov    (%r12),%esi
mov    0x2e50(%rip),%rax
or     (%rax),%esi
mov    0x0(%r13),%edx
mov    0x2dfb(%rip),%rax
or     (%rax),%edx
or     (%rbx),%edx
or     0x0(%rbp),%edx
or     (%r14),%edx
or     (%r15),%edx
lea    0xe3d(%rip),%rdi
call   1040 <open@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"file1\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@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
@.str.1 = [6 x i8] c"file2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @umask(i32 0)
%5 = load i32, i32* @O_CREAT
%6 = load i32, i32* @O_RDWR
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IRUSR
%9 = load i32, i32* @S_IWUSR
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IRGRP
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IWGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IWOTH
%18 = or i32 %16, %17
%19 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %18)
store i32 %19, i32* %2
%20 = load i32, i32* @S_IRGRP
%21 = load i32, i32* @S_IWGRP
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IROTH
%24 = or i32 %22, %23
%25 = load i32, i32* @S_IWOTH
%26 = or i32 %24, %25
%27 = call i32 @umask(i32 %26)
%28 = load i32, i32* @O_CREAT
%29 = load i32, i32* @O_RDWR
%30 = or i32 %28, %29
%31 = load i32, i32* @S_IRUSR
%32 = load i32, i32* @S_IWUSR
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IRGRP
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IWGRP
%37 = or i32 %35, %36
%38 = load i32, i32* @S_IROTH
%39 = or i32 %37, %38
%40 = load i32, i32* @S_IWOTH
%41 = or i32 %39, %40
%42 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %41)
store i32 %42, i32* %3
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"file1\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@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
@.str.1 = [6 x i8] c"file2\00"
define i32 @main() {
%1 = tail call i32 @umask(i32 0)
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_RDWR
%4 = or i32 %3, %2
%5 = load i32, i32* @S_IRUSR
%6 = load i32, i32* @S_IWUSR
%7 = or i32 %6, %5
%8 = load i32, i32* @S_IRGRP
%9 = or i32 %7, %8
%10 = load i32, i32* @S_IWGRP
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IROTH
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IWOTH
%15 = or i32 %13, %14
%16 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %15)
%17 = load i32, i32* @S_IRGRP
%18 = load i32, i32* @S_IWGRP
%19 = or i32 %18, %17
%20 = load i32, i32* @S_IROTH
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IWOTH
%23 = or i32 %21, %22
%24 = tail call i32 @umask(i32 %23)
%25 = load i32, i32* @O_CREAT
%26 = load i32, i32* @O_RDWR
%27 = or i32 %26, %25
%28 = load i32, i32* @S_IRUSR
%29 = load i32, i32* @S_IWUSR
%30 = or i32 %29, %28
%31 = load i32, i32* @S_IRGRP
%32 = or i32 %30, %31
%33 = load i32, i32* @S_IWGRP
%34 = or i32 %32, %33
%35 = load i32, i32* @S_IROTH
%36 = or i32 %34, %35
%37 = load i32, i32* @S_IWOTH
%38 = or i32 %36, %37
%39 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %38)
ret i32 0
}