#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*/ _getopt_reset(int, char **);
int _umask_get();
int _umask_set(char *);
int _umask_usage();
int getopt(int, char **, char *);
int optind;
int builtin_umask(int argc, char *argv[]) {
  int o;
  _getopt_reset(argc, argv);
  while ((o = getopt(argc, argv, "S")) != -1)
    switch (o) {
    case 'S':
      break;
    default:
      return _umask_usage();
    }
  if (argc > optind + 1)
    return _umask_usage();
  if (optind == argc)
    return _umask_get();
  return _umask_set(argv[optind]);
}


x86 assembly (clang, -O0):
<builtin_umask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <_getopt_reset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe87(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11b4 <builtin_umask+0x64>
mov    -0x14(%rbp),%eax
sub    $0x53,%eax
jne    11a0 <builtin_umask+0x50>
jmp    119b <builtin_umask+0x4b>
jmp    11af <builtin_umask+0x5f>
mov    $0x0,%al
call   1030 <_umask_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1215 <builtin_umask+0xc5>
jmp    116b <builtin_umask+0x1b>
mov    -0x8(%rbp),%eax
mov    0x2e2a(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jle    11da <builtin_umask+0x8a>
mov    $0x0,%al
call   1030 <_umask_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1215 <builtin_umask+0xc5>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    11fb <builtin_umask+0xab>
mov    $0x0,%al
call   1040 <_umask_get@plt>
mov    %eax,-0x4(%rbp)
jmp    1215 <builtin_umask+0xc5>
mov    -0x10(%rbp),%rax
mov    0x2de2(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <_umask_set@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_umask>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1060 <_getopt_reset@plt>
lea    0xe9b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0x53,%eax
je     1170 <builtin_umask+0x20>
cmp    $0xffffffff,%eax
jne    1198 <builtin_umask+0x48>
mov    0x2e5a(%rip),%rax
movslq (%rax),%rax
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
jge    11a3 <builtin_umask+0x53>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <_umask_usage@plt>
cmp    %ebp,%eax
jne    11b2 <builtin_umask+0x62>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <_umask_get@plt>
mov    (%rbx,%rax,8),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <_umask_set@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"S\00"
@optind = global i32 0
define i32 @builtin_umask(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @_getopt_reset(i32 %7, i8** %8)
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %18 [
i32 83, label %17
]
17: ; preds = %15
br label %20
18: ; preds = %15
%19 = call i32 (...) @_umask_usage()
store i32 %19, i32* %3
br label %41
20: ; preds = %17
br label %10
21: ; preds = %10
%22 = load i32, i32* %4
%23 = load i32, i32* @optind
%24 = add nsw i32 %23, 1
%25 = icmp sgt i32 %22, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 (...) @_umask_usage()
store i32 %27, i32* %3
br label %41
28: ; preds = %21
%29 = load i32, i32* @optind
%30 = load i32, i32* %4
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (...) @_umask_get()
store i32 %33, i32* %3
br label %41
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = load i32, i32* @optind
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @_umask_set(i8* %39)
store i32 %40, i32* %3
br label %41
41: ; preds = %34, %32, %26, %18
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [2 x i8] c"S\00"
@optind = global i32 0
define i32 @builtin_umask(i32 %0, i8** %1) {
%3 = tail call i32 @_getopt_reset(i32 %0, i8** %1)
br label %4
4: ; preds = %4, %2
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %6 [
i32 -1, label %8
i32 83, label %4
]
6: ; preds = %4
%7 = tail call i32 (...) @_umask_usage()
br label %23
8: ; preds = %4
%9 = load i32, i32* @optind
%10 = add nsw i32 %9, 1
%11 = icmp slt i32 %10, %0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 (...) @_umask_usage()
br label %23
14: ; preds = %8
%15 = icmp eq i32 %9, %0
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 (...) @_umask_get()
br label %23
18: ; preds = %14
%19 = sext i32 %9 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @_umask_set(i8* %21)
br label %23
23: ; preds = %18, %16, %12, %6
%24 = phi i32 [ %7, %6 ], [ %13, %12 ], [ %17, %16 ], [ %22, %18 ]
ret i32 %24
}