#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 *, ...);
int getopt(int, char **, char *);
char *optarg;
scalar_t__ opterr;
char optopt;
int /*<<< orphan*/ stderr;
int parse_args(int argc, char *argv[], char **p_in, char **p_out) {
  int c;
  if (argc != 4 + 1) {
    return 1;
  }
  opterr = 0;
  while ((c = getopt(argc, argv, "i:o:")) != -1) {
    switch (c) {
    case 'i':
      *p_in = optarg;
      break;
    case 'o':
      *p_out = optarg;
      break;
    case '?':
      if (optopt == 'i' || optopt == 'o')
        fprintf(stderr, "Option -%c requires a value\n", optopt);
      else
        fprintf(stderr, "Unknown option character '\\x%x'\n", optopt);
    default:
      return 1;
    }
  }
  if ((NULL == *p_in) || (NULL == *p_out)) {
    fprintf(stderr, "Invalid inputs\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     114d <parse_args+0x2d>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <parse_args+0x187>
mov    0x2e74(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     125f <parse_args+0x13f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     11dc <parse_args+0xbc>
jmp    118e <parse_args+0x6e>
mov    -0x28(%rbp),%eax
sub    $0x69,%eax
je     11b0 <parse_args+0x90>
jmp    119f <parse_args+0x7f>
mov    -0x28(%rbp),%eax
sub    $0x6f,%eax
je     11c6 <parse_args+0xa6>
jmp    124e <parse_args+0x12e>
mov    0x2e41(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    125a <parse_args+0x13a>
mov    0x2e2b(%rip),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    125a <parse_args+0x13a>
mov    0x2dfd(%rip),%rax
movsbl (%rax),%eax
cmp    $0x69,%eax
je     1202 <parse_args+0xe2>
mov    0x2dea(%rip),%rax
movsbl (%rax),%eax
cmp    $0x6f,%eax
jne    1228 <parse_args+0x108>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x2dce(%rip),%rax
movsbl (%rax),%edx
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1249 <parse_args+0x129>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
mov    0x2da8(%rip),%rax
movsbl (%rax),%edx
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    124e <parse_args+0x12e>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <parse_args+0x187>
jmp    115b <parse_args+0x3b>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%rax
je     127d <parse_args+0x15d>
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%rax
jne    12a0 <parse_args+0x180>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a7 <parse_args+0x187>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r14d
cmp    $0x5,%edi
jne    1223 <parse_args+0x103>
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    0x2e7e(%rip),%rax
movq   $0x0,(%rax)
lea    0xea8(%rip),%rbp
mov    0x2e99(%rip),%r13
jmp    1183 <parse_args+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rcx
cmp    $0x6f,%eax
jne    1223 <parse_args+0x103>
mov    0x0(%r13),%rax
mov    %rax,(%rcx)
mov    $0x5,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <getopt@plt>
cmp    $0x6e,%eax
jg     1170 <parse_args+0x50>
mov    %r12,%rcx
cmp    $0x69,%eax
je     117c <parse_args+0x5c>
cmp    $0xffffffff,%eax
je     11dd <parse_args+0xbd>
cmp    $0x3f,%eax
jne    1223 <parse_args+0x103>
mov    0x2e2f(%rip),%rax
movsbl (%rax),%edx
cmp    $0x6f,%edx
je     11be <parse_args+0x9e>
cmp    $0x69,%dl
jne    120c <parse_args+0xec>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe37(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%r14d
jmp    1223 <parse_args+0x103>
cmpq   $0x0,(%r12)
je     11ed <parse_args+0xcd>
xor    %r14d,%r14d
cmpq   $0x0,(%r15)
jne    1223 <parse_args+0x103>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%r14d
jmp    1223 <parse_args+0x103>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@.str = [5 x i8] c"i:o:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [29 x i8] c"Option -%c requires a value\0A\00"
@.str.2 = [33 x i8] c"Unknown option character '\\x%x'\0A\00"
@.str.3 = [16 x i8] c"Invalid inputs\0A\00"
define i32 @parse_args(i32 %0, i8** %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 5
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 1, i32* %5
br label %61
14: ; preds = %4
store i64 0, i64* @opterr
br label %15
15: ; preds = %48, %14
%16 = load i32, i32* %6
%17 = load i8**, i8*** %7
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %10
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %49
20: ; preds = %15
%21 = load i32, i32* %10
switch i32 %21, label %47 [
i32 105, label %22
i32 111, label %25
i32 63, label %28
]
22: ; preds = %20
%23 = load i8*, i8** @optarg
%24 = load i8**, i8*** %8
store i8* %23, i8** %24
br label %48
25: ; preds = %20
%26 = load i8*, i8** @optarg
%27 = load i8**, i8*** %9
store i8* %26, i8** %27
br label %48
28: ; preds = %20
%29 = load i8, i8* @optopt
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 105
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8, i8* @optopt
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 111
br i1 %35, label %36, label %41
36: ; preds = %32, %28
%37 = load i32, i32* @stderr
%38 = load i8, i8* @optopt
%39 = sext i8 %38 to i32
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %46
41: ; preds = %32
%42 = load i32, i32* @stderr
%43 = load i8, i8* @optopt
%44 = sext i8 %43 to i32
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %41, %36
br label %47
47: ; preds = %20, %46
store i32 1, i32* %5
br label %61
48: ; preds = %25, %22
br label %15
49: ; preds = %15
%50 = load i8**, i8*** %8
%51 = load i8*, i8** %50
%52 = icmp eq i8* null, %51
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8**, i8*** %9
%55 = load i8*, i8** %54
%56 = icmp eq i8* null, %55
br i1 %56, label %57, label %60
57: ; preds = %53, %49
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %5
br label %61
60: ; preds = %53
store i32 0, i32* %5
br label %61
61: ; preds = %60, %57, %47, %13
%62 = load i32, i32* %5
ret i32 %62
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [5 x i8] c"i:o:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [29 x i8] c"Option -%c requires a value\0A\00"
@.str.2 = [33 x i8] c"Unknown option character '\\x%x'\0A\00"
@.str.3 = [16 x i8] c"Invalid inputs\0A\00"
define i32 @parse_args(i32 %0, i8** %1, i8** nocapture %2, i8** nocapture %3) {
%5 = icmp eq i32 %0, 5
br i1 %5, label %6, label %31
6: ; preds = %4
store i64 0, i64* @opterr
br label %7
7: ; preds = %19, %6
%8 = tail call i32 @getopt(i32 5, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %31 [
i32 -1, label %22
i32 105, label %19
i32 111, label %9
i32 63, label %10
]
9: ; preds = %7
br label %19
10: ; preds = %7
%11 = load i8, i8* @optopt
%12 = sext i8 %11 to i32
switch i8 %11, label %16 [
i8 111, label %13
i8 105, label %13
]
13: ; preds = %10, %10
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %31
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %31
19: ; preds = %7, %9
%20 = phi i8** [ %3, %9 ], [ %2, %7 ]
%21 = load i8*, i8** @optarg
store i8* %21, i8** %20
br label %7
22: ; preds = %7
%23 = load i8*, i8** %2
%24 = icmp eq i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i8*, i8** %3
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %25, %22
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %31
31: ; preds = %7, %25, %16, %13, %4, %28
%32 = phi i32 [ 1, %28 ], [ 1, %4 ], [ 1, %13 ], [ 1, %16 ], [ 0, %25 ], [ 1, %7 ]
ret i32 %32
}