#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 getopt(int, char **, char *);
char *optarg;
int optind;
int parse_args(int argc, char *argv[], char **saved_posns_path,
               char **sockets_dir) {
  int opt = -1;
  while ((opt = getopt(argc, argv, "w:")) != -1) {
    switch (opt) {
    case 'w':
      *saved_posns_path = optarg;
      break;
    default:
      return 1;
    }
  }
  if (optind != argc - 1) {
    return 1;
  }
  *sockets_dir = argv[optind];
  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)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xec4(%rip),%rdx
call   1030 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1185 <parse_args+0x75>
mov    -0x24(%rbp),%eax
sub    $0x77,%eax
jne    1174 <parse_args+0x64>
jmp    115e <parse_args+0x4e>
mov    0x2e93(%rip),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1180 <parse_args+0x70>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <parse_args+0xb8>
jmp    112e <parse_args+0x1e>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11a8 <parse_args+0x98>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <parse_args+0xb8>
mov    -0x10(%rbp),%rax
mov    0x2e2d(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
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    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xed3(%rip),%r12
mov    0x2ec4(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <getopt@plt>
cmp    $0x77,%eax
jne    115b <parse_args+0x4b>
mov    0x0(%r13),%rax
mov    %rax,(%rbx)
jmp    1140 <parse_args+0x30>
cmp    $0xffffffff,%eax
jne    1181 <parse_args+0x71>
mov    0x2e79(%rip),%rax
movslq (%rax),%rcx
add    $0xffffffff,%ebp
mov    $0x1,%eax
cmp    %ebp,%ecx
jne    1186 <parse_args+0x76>
mov    (%r15,%rcx,8),%rax
mov    %rax,(%r14)
xor    %eax,%eax
jmp    1186 <parse_args+0x76>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"w:\00"
@optarg = global i8* null
@optind = global i32 0
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
store i32 -1, i32* %10
br label %11
11: ; preds = %22, %4
%12 = load i32, i32* %6
%13 = load i8**, i8*** %7
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %10
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* %10
switch i32 %17, label %21 [
i32 119, label %18
]
18: ; preds = %16
%19 = load i8*, i8** @optarg
%20 = load i8**, i8*** %8
store i8* %19, i8** %20
br label %22
21: ; preds = %16
store i32 1, i32* %5
br label %36
22: ; preds = %18
br label %11
23: ; preds = %11
%24 = load i32, i32* @optind
%25 = load i32, i32* %6
%26 = sub nsw i32 %25, 1
%27 = icmp ne i32 %24, %26
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 1, i32* %5
br label %36
29: ; preds = %23
%30 = load i8**, i8*** %7
%31 = load i32, i32* @optind
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %9
store i8* %34, i8** %35
store i32 0, i32* %5
br label %36
36: ; preds = %29, %28, %21
%37 = load i32, i32* %5
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"w:\00"
@optarg = global i8* null
@optind = global i32 0
define i32 @parse_args(i32 %0, i8** %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3) {
br label %5
5: ; preds = %7, %4
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %17 [
i32 -1, label %9
i32 119, label %7
]
7: ; preds = %5
%8 = load i8*, i8** @optarg
store i8* %8, i8** %2
br label %5
9: ; preds = %5
%10 = load i32, i32* @optind
%11 = add nsw i32 %0, -1
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = sext i32 %10 to i64
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
store i8* %16, i8** %3
br label %17
17: ; preds = %5, %9, %13
%18 = phi i32 [ 0, %13 ], [ 1, %9 ], [ 1, %5 ]
ret i32 %18
}