#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 */
typedef int mode_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int strtol(char *, int /*<<< orphan*/ *, int);
int umask(int);
int main(int argc, char *argv[]) {
  if (argc != 1) {
    mode_t umode;
    umode = strtol(argv[2], NULL, 8);
    umask(umode);
  } else {
    mode_t umode;
    umode = umask(0);
    printf("%04o\n", umode);
    umask(umode);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1176 <main+0x46>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <umask@plt>
jmp    1197 <main+0x67>
xor    %edi,%edi
call   1040 <umask@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1040 <umask@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jne    114f <main+0x1f>
xor    %edi,%edi
call   1040 <umask@plt>
mov    %eax,%ebx
lea    0xeba(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
jmp    1161 <main+0x31>
mov    0x10(%rsi),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
mov    %eax,%ebx
mov    %ebx,%edi
call   1040 <umask@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%04o\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @strtol(i8* %13, i32* null, i32 8)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = call i32 @umask(i32 %15)
br label %23
17: ; preds = %2
%18 = call i32 @umask(i32 0)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %7
%22 = call i32 @umask(i32 %21)
br label %23
23: ; preds = %17, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%04o\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @strtol(i8* nocapture %6, i32* null, i32 8)
br label %11
8: ; preds = %2
%9 = tail call i32 @umask(i32 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %8, %4
%12 = phi i32 [ %9, %8 ], [ %7, %4 ]
%13 = tail call i32 @umask(i32 %12)
ret i32 0
}