#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ stderr;
void parse_args(int argc, char **argv, int *daemon, int *port, char **pidfile) {
  int opt;
  while ((opt = getopt(argc, argv, "dl:p:v")) != -1) {
    switch (opt) {
    case 'd':
      *daemon = 1;
      break;
    case 'l':
      *port = atoi(optarg);
      break;
    case 'p':
      *pidfile = optarg;
      break;
    case 'v':
      print_usage(*argv);
      exit(EXIT_SUCCESS);
    default:
      print_usage(*argv);
      exit(EXIT_FAILURE);
    }
  }
  if (*port < 0 || *port > 65535) {
    fprintf(stderr, "Port out of range <0-65535>.\n");
    print_usage(*argv);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<parse_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xed3(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     122d <parse_args+0xdd>
mov    -0x2c(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x12,%eax
ja     120e <parse_args+0xbe>
mov    -0x38(%rbp),%rax
lea    0xe56(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1228 <parse_args+0xd8>
mov    0x2e2f(%rip),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    1228 <parse_args+0xd8>
mov    0x2e13(%rip),%rax
mov    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    1228 <parse_args+0xd8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    116b <parse_args+0x1b>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jl     124a <parse_args+0xfa>
mov    -0x20(%rbp),%rax
cmpl   $0xffff,(%rax)
jle    1279 <parse_args+0x129>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <print_usage@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%r14
mov    %rdx,0x8(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xeb1(%rip),%rdx
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     11ee <parse_args+0x9e>
lea    0xe78(%rip),%r15
lea    0xe99(%rip),%r13
mov    0x2e62(%rip),%r12
jmp    11bd <parse_args+0x6d>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
movl   $0x1,(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
je     11ee <parse_args+0x9e>
add    $0xffffff9c,%eax
ror    %eax
cmp    $0x9,%eax
ja     1231 <parse_args+0xe1>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    (%r12),%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14)
jmp    11ab <parse_args+0x5b>
xchg   %ax,%ax
mov    (%r12),%rax
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
jmp    11ab <parse_args+0x5b>
cmpl   $0x10000,(%r14)
jae    121c <parse_args+0xcc>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rdi
call   1070 <print_usage@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%rdi
call   1070 <print_usage@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"dl:p:v\00"
@optarg = global i8* null
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"Port out of range <0-65535>.\0A\00"
define void @parse_args(i32 %0, i8** %1, i32* %2, i32* %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8**
%11 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i8** %4, i8*** %10
br label %12
12: ; preds = %40, %5
%13 = load i32, i32* %6
%14 = load i8**, i8*** %7
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %11
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %41
17: ; preds = %12
%18 = load i32, i32* %11
switch i32 %18, label %34 [
i32 100, label %19
i32 108, label %21
i32 112, label %25
i32 118, label %28
]
19: ; preds = %17
%20 = load i32*, i32** %8
store i32 1, i32* %20
br label %40
21: ; preds = %17
%22 = load i8*, i8** @optarg
%23 = call i32 @atoi(i8* %22)
%24 = load i32*, i32** %9
store i32 %23, i32* %24
br label %40
25: ; preds = %17
%26 = load i8*, i8** @optarg
%27 = load i8**, i8*** %10
store i8* %26, i8** %27
br label %40
28: ; preds = %17
%29 = load i8**, i8*** %7
%30 = load i8*, i8** %29
%31 = call i32 @print_usage(i8* %30)
%32 = load i32, i32* @EXIT_SUCCESS
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %17
%35 = load i8**, i8*** %7
%36 = load i8*, i8** %35
%37 = call i32 @print_usage(i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %25, %21, %19
br label %12
41: ; preds = %12
%42 = load i32*, i32** %9
%43 = load i32, i32* %42
%44 = icmp slt i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %41
%46 = load i32*, i32** %9
%47 = load i32, i32* %46
%48 = icmp sgt i32 %47, 65535
br i1 %48, label %49, label %57
49: ; preds = %45, %41
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%52 = load i8**, i8*** %7
%53 = load i8*, i8** %52
%54 = call i32 @print_usage(i8* %53)
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %45
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"dl:p:v\00"
@optarg = global i8* null
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"Port out of range <0-65535>.\0A\00"
define void @parse_args(i32 %0, i8** %1, i32* nocapture writeonly %2, i32* nocapture %3, i8** nocapture writeonly %4) {
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, -1
br i1 %7, label %31, label %8
8: ; preds = %5, %28
%9 = phi i32 [ %29, %28 ], [ %6, %5 ]
%10 = add i32 %9, -100
%11 = tail call i32 @llvm.fshl.i32(i32 %10, i32 %10, i32 31)
switch i32 %11, label %23 [
i32 0, label %12
i32 4, label %13
i32 6, label %16
i32 9, label %18
]
12: ; preds = %8
store i32 1, i32* %2
br label %28
13: ; preds = %8
%14 = load i8*, i8** @optarg
%15 = tail call i32 @atoi(i8* %14)
store i32 %15, i32* %3
br label %28
16: ; preds = %8
%17 = load i8*, i8** @optarg
store i8* %17, i8** %4
br label %28
18: ; preds = %8
%19 = load i8*, i8** %1
%20 = tail call i32 @print_usage(i8* %19)
%21 = load i32, i32* @EXIT_SUCCESS
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %8
%24 = load i8*, i8** %1
%25 = tail call i32 @print_usage(i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = tail call i32 @exit(i32 %26)
unreachable
28: ; preds = %16, %13, %12
%29 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %8
31: ; preds = %28, %5
%32 = load i32, i32* %3
%33 = icmp ugt i32 %32, 65535
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%37 = load i8*, i8** %1
%38 = tail call i32 @print_usage(i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = tail call i32 @exit(i32 %39)
unreachable
41: ; preds = %31
ret void
}