#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 EOF;
int getopt(int, char **, char *);
int /*<<< orphan*/ makeMeLeader();
int /*<<< orphan*/ optarg;
int optopt;
int /*<<< orphan*/ printCore();
int /*<<< orphan*/ printCurrentDirectory();
int /*<<< orphan*/ printEviron();
int /*<<< orphan*/ printProcessId();
int /*<<< orphan*/ printRealAndEffectiveId();
int /*<<< orphan*/ printUlimit();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ setCore(int /*<<< orphan*/);
int /*<<< orphan*/ setEnviron(int /*<<< orphan*/);
int /*<<< orphan*/ setUlimit(int /*<<< orphan*/);
int main(int argc, char *argv[], char *envp[]) {
  char options[] = "pisuU:dvV:cC:";
  int c, dflg = 0, fflg = 0, gflg = 0;
  char *f_ptr, *g_ptr;
  while ((c = getopt(argc, argv, options)) != EOF) {
    switch (c) {
    case 'i':
      printRealAndEffectiveId();
      break;
    case 's':
      makeMeLeader();
      break;
    case 'p':
      printProcessId();
      break;
    case 'u':
      printUlimit();
      break;
    case 'U':
      setUlimit(optarg);
      break;
    case 'd':
      printCurrentDirectory();
      break;
    case 'v':
      printEviron();
      break;
    case 'V':
      setEnviron(optarg);
      break;
    case 'c':
      printCore();
      break;
    case 'C':
      setCore(optarg);
      break;
    case '?':
      printf("invalid option is %c\n", optopt);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xeff(%rip),%rax
mov    %rax,-0x26(%rbp)
mov    0xefd(%rip),%eax
mov    %eax,-0x1e(%rbp)
mov    0xef7(%rip),%ax
mov    %ax,-0x1a(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x26(%rbp),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2db0(%rip),%rcx
cmp    (%rcx),%eax
je     1300 <main+0x140>
mov    -0x2c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x37,%eax
ja     12fb <main+0x13b>
mov    -0x50(%rbp),%rax
lea    0xdb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10b0 <printRealAndEffectiveId@plt>
jmp    12fb <main+0x13b>
mov    $0x0,%al
call   1090 <makeMeLeader@plt>
jmp    12fb <main+0x13b>
mov    $0x0,%al
call   10d0 <printProcessId@plt>
jmp    12fb <main+0x13b>
mov    $0x0,%al
call   10e0 <printUlimit@plt>
jmp    12fb <main+0x13b>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
call   1070 <setUlimit@plt>
jmp    12fb <main+0x13b>
mov    $0x0,%al
call   10a0 <printCurrentDirectory@plt>
jmp    12fb <main+0x13b>
mov    $0x0,%al
call   1080 <printEviron@plt>
jmp    12fb <main+0x13b>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
call   1030 <setEnviron@plt>
jmp    12fb <main+0x13b>
mov    $0x0,%al
call   1060 <printCore@plt>
jmp    12fb <main+0x13b>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   1050 <setCore@plt>
jmp    12fb <main+0x13b>
mov    0x2cf3(%rip),%rax
mov    (%rax),%esi
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
jmp    120e <main+0x4e>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movabs $0x3a43633a567664,%rax
mov    %rax,0xe(%rsp)
movabs $0x76643a5575736970,%rax
3a 64 76
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdx
call   10c0 <getopt@plt>
mov    0x2dd6(%rip),%r12
cmp    (%r12),%eax
jne    1219 <main+0x59>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8(%rsp),%r14
lea    0xddb(%rip),%r13
mov    0x2dcc(%rip),%r15
jmp    1263 <main+0xa3>
mov    0x2dab(%rip),%rax
mov    (%rax),%esi
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10c0 <getopt@plt>
cmp    (%r12),%eax
je     1208 <main+0x48>
add    $0xffffffc1,%eax
cmp    $0x37,%eax
ja     1250 <main+0x90>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    (%r15),%edi
call   1050 <setCore@plt>
jmp    1250 <main+0x90>
mov    (%r15),%edi
call   1070 <setUlimit@plt>
jmp    1250 <main+0x90>
mov    (%r15),%edi
call   1030 <setEnviron@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   1060 <printCore@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   10a0 <printCurrentDirectory@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   10b0 <printRealAndEffectiveId@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   10d0 <printProcessId@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   1090 <makeMeLeader@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   10e0 <printUlimit@plt>
jmp    1250 <main+0x90>
xor    %eax,%eax
call   1080 <printEviron@plt>
jmp    1250 <main+0x90>

LLVM IR (-O0):
@__const.main.options = [14 x i8] c"pisuU:dvV:cC:\00"
@EOF = global i32 0
@optarg = global i32 0
@.str = [22 x i8] c"invalid option is %c\0A\00"
@optopt = global i32 0
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca [14 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%15 = bitcast [14 x i8]* %8 to i8*
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
br label %16
16: ; preds = %51, %3
%17 = load i32, i32* %5
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%20 = call i32 @getopt(i32 %17, i8** %18, i8* %19)
store i32 %20, i32* %9
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %52
23: ; preds = %16
%24 = load i32, i32* %9
switch i32 %24, label %51 [
i32 105, label %25
i32 115, label %27
i32 112, label %29
i32 117, label %31
i32 85, label %33
i32 100, label %36
i32 118, label %38
i32 86, label %40
i32 99, label %43
i32 67, label %45
i32 63, label %48
]
25: ; preds = %23
%26 = call i32 (...) @printRealAndEffectiveId()
br label %51
27: ; preds = %23
%28 = call i32 (...) @makeMeLeader()
br label %51
29: ; preds = %23
%30 = call i32 (...) @printProcessId()
br label %51
31: ; preds = %23
%32 = call i32 (...) @printUlimit()
br label %51
33: ; preds = %23
%34 = load i32, i32* @optarg
%35 = call i32 @setUlimit(i32 %34)
br label %51
36: ; preds = %23
%37 = call i32 (...) @printCurrentDirectory()
br label %51
38: ; preds = %23
%39 = call i32 (...) @printEviron()
br label %51
40: ; preds = %23
%41 = load i32, i32* @optarg
%42 = call i32 @setEnviron(i32 %41)
br label %51
43: ; preds = %23
%44 = call i32 (...) @printCore()
br label %51
45: ; preds = %23
%46 = load i32, i32* @optarg
%47 = call i32 @setCore(i32 %46)
br label %51
48: ; preds = %23
%49 = load i32, i32* @optopt
%50 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %48, %23, %45, %43, %40, %38, %36, %33, %31, %29, %27, %25
br label %16
52: ; preds = %16
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@__const.main.options = [14 x i8] c"pisuU:dvV:cC:\00"
@EOF = global i32 0
@optarg = global i32 0
@.str = [22 x i8] c"invalid option is %c\0A\00"
@optopt = global i32 0
define i32 @main(i32 %0, i8** %1, i8** nocapture readnone %2) {
%4 = alloca [14 x i8]
%5 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%6 = call i32 @getopt(i32 %0, i8** %1, i8* %5)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %41, label %9
9: ; preds = %3, %37
%10 = phi i32 [ %38, %37 ], [ %6, %3 ]
switch i32 %10, label %37 [
i32 105, label %11
i32 115, label %13
i32 112, label %15
i32 117, label %17
i32 85, label %19
i32 100, label %22
i32 118, label %24
i32 86, label %26
i32 99, label %29
i32 67, label %31
i32 63, label %34
]
11: ; preds = %9
%12 = call i32 (...) @printRealAndEffectiveId()
br label %37
13: ; preds = %9
%14 = call i32 (...) @makeMeLeader()
br label %37
15: ; preds = %9
%16 = call i32 (...) @printProcessId()
br label %37
17: ; preds = %9
%18 = call i32 (...) @printUlimit()
br label %37
19: ; preds = %9
%20 = load i32, i32* @optarg
%21 = call i32 @setUlimit(i32 %20)
br label %37
22: ; preds = %9
%23 = call i32 (...) @printCurrentDirectory()
br label %37
24: ; preds = %9
%25 = call i32 (...) @printEviron()
br label %37
26: ; preds = %9
%27 = load i32, i32* @optarg
%28 = call i32 @setEnviron(i32 %27)
br label %37
29: ; preds = %9
%30 = call i32 (...) @printCore()
br label %37
31: ; preds = %9
%32 = load i32, i32* @optarg
%33 = call i32 @setCore(i32 %32)
br label %37
34: ; preds = %9
%35 = load i32, i32* @optopt
%36 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %34, %9, %31, %29, %26, %24, %22, %19, %17, %15, %13, %11
%38 = call i32 @getopt(i32 %0, i8** %1, i8* %5)
%39 = load i32, i32* @EOF
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %9
41: ; preds = %37, %3
ret i32 0
}