#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 S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ chmod(char *, int);
int /*<<< orphan*/ creat(char *, int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ umask(int);
void main() {
  umask(0);
  creat("f1", 0755);
  umask(007);
  creat("f2", 0755);
  creat("f3", 0);
  chmod("f3", S_IRUSR | S_IWUSR);
  system("ls -l f?");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1040 <umask@plt>
lea    0xeae(%rip),%rdi
mov    $0x1ed,%esi
call   1060 <creat@plt>
mov    $0x7,%edi
call   1040 <umask@plt>
lea    0xe96(%rip),%rdi
mov    $0x1ed,%esi
call   1060 <creat@plt>
lea    0xe88(%rip),%rdi
xor    %esi,%esi
call   1060 <creat@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
mov    0x2e53(%rip),%rax
or     (%rax),%esi
lea    0xe68(%rip),%rdi
call   1050 <chmod@plt>
lea    0xe5f(%rip),%rdi
call   1030 <system@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1040 <umask@plt>
lea    0xeb1(%rip),%rdi
mov    $0x1ed,%esi
call   1060 <creat@plt>
mov    $0x7,%edi
call   1040 <umask@plt>
lea    0xe99(%rip),%rdi
mov    $0x1ed,%esi
call   1060 <creat@plt>
lea    0xe8b(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <creat@plt>
mov    0x2e4c(%rip),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
call   1050 <chmod@plt>
lea    0xe63(%rip),%rdi
pop    %rbx
jmp    1030 <system@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"f1\00"
@.str.1 = [3 x i8] c"f2\00"
@.str.2 = [3 x i8] c"f3\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [9 x i8] c"ls -l f?\00"
define void @main() {
%1 = call i32 @umask(i32 0)
%2 = call i32 @creat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 493)
%3 = call i32 @umask(i32 7)
%4 = call i32 @creat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 493)
%5 = call i32 @creat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 0)
%6 = load i32, i32* @S_IRUSR
%7 = load i32, i32* @S_IWUSR
%8 = or i32 %6, %7
%9 = call i32 @chmod(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"f1\00"
@.str.1 = [3 x i8] c"f2\00"
@.str.2 = [3 x i8] c"f3\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [9 x i8] c"ls -l f?\00"
define void @main() {
%1 = tail call i32 @umask(i32 0)
%2 = tail call i32 @creat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 493)
%3 = tail call i32 @umask(i32 7)
%4 = tail call i32 @creat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 493)
%5 = tail call i32 @creat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 0)
%6 = load i32, i32* @S_IRUSR
%7 = load i32, i32* @S_IWUSR
%8 = or i32 %7, %6
%9 = tail call i32 @chmod(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
ret void
}