#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*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
char *optarg;
char optopt;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int getargs(char **ip, char **pass, int argc, char **argv) {
  int c;
  while ((c = getopt(argc, argv, "i:p:")) != -1)
    switch (c) {
    case 'i':
      *ip = optarg;
      break;
    case 'p':
      *pass = optarg;
      break;
    case '?':
      if (optopt == 'i' || optopt == 'p')
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      return -1;
    default:
      usage(argv[0]);
    }
  return (pass != NULL && ip != NULL) ? 0 : -1;
}


x86 assembly (clang, -O0):
<getargs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rsi
lea    0xeab(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     122a <getargs+0xfa>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x3f,%eax
je     11c8 <getargs+0x98>
jmp    117a <getargs+0x4a>
mov    -0x30(%rbp),%eax
sub    $0x69,%eax
je     119c <getargs+0x6c>
jmp    118b <getargs+0x5b>
mov    -0x30(%rbp),%eax
sub    $0x70,%eax
je     11b2 <getargs+0x82>
jmp    1219 <getargs+0xe9>
mov    0x2e55(%rip),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    1225 <getargs+0xf5>
mov    0x2e3f(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1225 <getargs+0xf5>
mov    0x2e11(%rip),%rax
movsbl (%rax),%eax
cmp    $0x69,%eax
je     11ee <getargs+0xbe>
mov    0x2dfe(%rip),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
jne    120d <getargs+0xdd>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
mov    0x2ddb(%rip),%rax
movsbl (%rax),%edx
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1258 <getargs+0x128>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
jmp    1147 <getargs+0x17>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x31(%rbp)
je     1245 <getargs+0x115>
cmpq   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%dl
mov    $0xffffffff,%eax
xor    %ecx,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getargs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xeb3(%rip),%r12
mov    0x2ea4(%rip),%r13
jmp    1168 <getargs+0x38>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%rdi
call   1040 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1050 <getopt@plt>
cmp    $0x6f,%eax
jg     1190 <getargs+0x60>
cmp    $0x69,%eax
jne    119e <getargs+0x6e>
mov    0x0(%r13),%rax
mov    %rax,(%r14)
jmp    1168 <getargs+0x38>
nopl   0x0(%rax,%rax,1)
cmp    $0x70,%eax
jne    1160 <getargs+0x30>
mov    0x0(%r13),%rax
mov    %rax,(%r15)
jmp    1168 <getargs+0x38>
cmp    $0xffffffff,%eax
je     11d8 <getargs+0xa8>
cmp    $0x3f,%eax
jne    1160 <getargs+0x30>
mov    0x2e31(%rip),%rax
mov    (%rax),%al
mov    $0xffffffff,%ebx
cmp    $0x70,%al
je     11be <getargs+0x8e>
cmp    $0x69,%al
jne    11eb <getargs+0xbb>
mov    0x2e0b(%rip),%rcx
mov    (%rcx),%edi
movsbl %al,%edx
lea    0xe34(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11eb <getargs+0xbb>
test   %r15,%r15
sete   %al
test   %r14,%r14
sete   %cl
or     %al,%cl
movzbl %cl,%ebx
neg    %ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"i:p:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
define i32 @getargs(i8** %0, i8** %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
store i8** %0, i8*** %6
store i8** %1, i8*** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
br label %11
11: ; preds = %42, %4
%12 = load i32, i32* %8
%13 = load i8**, i8*** %9
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %10
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %43
16: ; preds = %11
%17 = load i32, i32* %10
switch i32 %17, label %37 [
i32 105, label %18
i32 112, label %21
i32 63, label %24
]
18: ; preds = %16
%19 = load i8*, i8** @optarg
%20 = load i8**, i8*** %6
store i8* %19, i8** %20
br label %42
21: ; preds = %16
%22 = load i8*, i8** @optarg
%23 = load i8**, i8*** %7
store i8* %22, i8** %23
br label %42
24: ; preds = %16
%25 = load i8, i8* @optopt
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 105
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i8, i8* @optopt
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 112
br i1 %31, label %32, label %36
32: ; preds = %28, %24
%33 = load i32, i32* @stderr
%34 = load i8, i8* @optopt
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %34)
br label %36
36: ; preds = %32, %28
store i32 -1, i32* %5
br label %53
37: ; preds = %16
%38 = load i8**, i8*** %9
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @usage(i8* %40)
br label %42
42: ; preds = %37, %21, %18
br label %11
43: ; preds = %11
%44 = load i8**, i8*** %7
%45 = icmp ne i8** %44, null
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i8**, i8*** %6
%48 = icmp ne i8** %47, null
br label %49
49: ; preds = %46, %43
%50 = phi i1 [ false, %43 ], [ %48, %46 ]
%51 = zext i1 %50 to i64
%52 = select i1 %50, i32 0, i32 -1
store i32 %52, i32* %5
br label %53
53: ; preds = %49, %36
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@.str = [5 x i8] c"i:p:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
define i32 @getargs(i8** writeonly %0, i8** writeonly %1, i32 %2, i8** %3) {
br label %5
5: ; preds = %19, %4
%6 = tail call i32 @getopt(i32 %2, i8** %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %16 [
i32 -1, label %20
i32 105, label %7
i32 112, label %9
i32 63, label %11
]
7: ; preds = %5
%8 = load i8*, i8** @optarg
store i8* %8, i8** %0
br label %19
9: ; preds = %5
%10 = load i8*, i8** @optarg
store i8* %10, i8** %1
br label %19
11: ; preds = %5
%12 = load i8, i8* @optopt
switch i8 %12, label %25 [
i8 112, label %13
i8 105, label %13
]
13: ; preds = %11, %11
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8 signext %12)
br label %25
16: ; preds = %5
%17 = load i8*, i8** %3
%18 = tail call i32 @usage(i8* %17)
br label %19
19: ; preds = %16, %9, %7
br label %5
20: ; preds = %5
%21 = icmp eq i8** %1, null
%22 = icmp eq i8** %0, null
%23 = or i1 %22, %21
%24 = sext i1 %23 to i32
br label %25
25: ; preds = %13, %11, %20
%26 = phi i32 [ %24, %20 ], [ -1, %11 ], [ -1, %13 ]
ret i32 %26
}