#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 atoi(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int c;
  char interface[64];
  int listen_port;
  usage(argv[0]);
  printf("You have input %d params\n", argc - 1);
  while ((c = getopt(argc, argv, "i:p:h?")) != -1) {
    switch (c) {
    case 'i':
      strcpy(interface, optarg);
      printf("interface %s \n", interface);
      break;
    case 'p':
      listen_port = atoi(optarg);
      printf("listen_port %d \n", listen_port);
      break;
    case 'h':
    case '?':
      printf("Need help ?\n");
      break;
    default:
      usage(argv[0]);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe86(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     126c <main+0x11c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x68(%rbp)
sub    $0x3f,%eax
je     123c <main+0xec>
jmp    11b9 <main+0x69>
mov    -0x68(%rbp),%eax
sub    $0x68,%eax
je     123c <main+0xec>
jmp    11ca <main+0x7a>
mov    -0x68(%rbp),%eax
sub    $0x69,%eax
je     11ec <main+0x9c>
jmp    11db <main+0x8b>
mov    -0x68(%rbp),%eax
sub    $0x70,%eax
je     1215 <main+0xc5>
jmp    124f <main+0xff>
lea    -0x60(%rbp),%rdi
mov    0x2e01(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1267 <main+0x117>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1267 <main+0x117>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1267 <main+0x117>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1273 <main+0x123>
jmp    1186 <main+0x36>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
mov    (%rsi),%rdi
call   1060 <usage@plt>
lea    -0x1(%rbx),%esi
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe87(%rip),%r15
lea    0xea7(%rip),%r12
mov    0x2e57(%rip),%r13
mov    %rsp,%rbp
jmp    11b8 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    $0x68,%eax
jg     11e0 <main+0x80>
cmp    $0x3f,%eax
je     11b0 <main+0x50>
cmp    $0x68,%eax
je     11b0 <main+0x50>
jmp    122b <main+0xcb>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x70,%eax
je     1210 <main+0xb0>
cmp    $0x69,%eax
jne    1234 <main+0xd4>
mov    0x0(%r13),%esi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xe24(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b8 <main+0x58>
nopl   0x0(%rax)
mov    0x0(%r13),%edi
call   1080 <atoi@plt>
lea    0xe10(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b8 <main+0x58>
cmp    $0xffffffff,%eax
jne    1234 <main+0xd4>
xor    %eax,%eax
jmp    1241 <main+0xe1>
mov    (%r14),%rdi
call   1060 <usage@plt>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"You have input %d params\0A\00"
@.str.1 = [7 x i8] c"i:p:h?\00"
@optarg = global i32 0
@.str.2 = [15 x i8] c"interface %s \0A\00"
@.str.3 = [17 x i8] c"listen_port %d \0A\00"
@.str.4 = [13 x i8] c"Need help ?\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [64 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 @usage(i8* %11)
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %41, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 %19, i32* %6
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %42
21: ; preds = %16
%22 = load i32, i32* %6
switch i32 %22, label %36 [
i32 105, label %23
i32 112, label %29
i32 104, label %34
i32 63, label %34
]
23: ; preds = %21
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%25 = load i32, i32* @optarg
%26 = call i32 @strcpy(i8* %24, i32 %25)
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %41
29: ; preds = %21
%30 = load i32, i32* @optarg
%31 = call i32 @atoi(i32 %30)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %41
34: ; preds = %21, %21
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %41
36: ; preds = %21
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @usage(i8* %39)
store i32 1, i32* %3
br label %43
41: ; preds = %34, %29, %23
br label %16
42: ; preds = %16
store i32 0, i32* %3
br label %43
43: ; preds = %42, %36
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [26 x i8] c"You have input %d params\0A\00"
@.str.1 = [7 x i8] c"i:p:h?\00"
@optarg = global i32 0
@.str.2 = [15 x i8] c"interface %s \0A\00"
@.str.3 = [17 x i8] c"listen_port %d \0A\00"
@str = [12 x i8] c"Need help ?\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
%7 = add nsw i32 %0, -1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %21, %2
%10 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
switch i32 %10, label %22 [
i32 -1, label %25
i32 105, label %11
i32 112, label %15
i32 104, label %19
i32 63, label %19
]
11: ; preds = %9
%12 = load i32, i32* @optarg
%13 = call i32 @strcpy(i8* %4, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %21
15: ; preds = %9
%16 = load i32, i32* @optarg
%17 = call i32 @atoi(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %9, %9
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15, %11
br label %9
22: ; preds = %9
%23 = load i8*, i8** %1
%24 = call i32 @usage(i8* %23)
br label %25
25: ; preds = %9, %22
%26 = phi i32 [ 1, %22 ], [ 0, %9 ]
ret i32 %26
}