#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ const member_1;
};

/* Variables and functions */
int /*<<< orphan*/ c_run(char *, char *);
int /*<<< orphan*/ c_usage();
int getopt_long(int, char **, char *, struct option *, int *);
int /*<<< orphan*/ optarg;
#define required_argument 128
char *strdup(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int ch, index = 0;
  char *server_ip;
  char *port;
  unsigned int ip_set = 0, port_set = 0;
  static struct option client_options[] = {
      {"server-ip", required_argument, NULL, 's'},
      {"server-port", required_argument, NULL, 'p'},
  };
  while ((ch = getopt_long(argc, argv, ":", client_options, &index)) != -1) {
    switch (ch) {
    case 's':
      if (optarg) {
        server_ip = strdup(optarg);
        ip_set = 1;
      } else {
        c_usage();
      }
      break;
    case 'p':
      if (optarg) {
        port = strdup(optarg);
        port_set = 1;
      } else {
        c_usage();
      }
      break;
    case '?':
    default:
      c_usage();
    }
  }
  if (!ip_set || !port_set) {
    c_usage();
  }
  c_run(server_ip, port);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe9d(%rip),%rdx
lea    0x2ed0(%rip),%rcx
lea    -0x18(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1250 <main+0x110>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x3f,%eax
je     123f <main+0xff>
jmp    11a9 <main+0x69>
mov    -0x34(%rbp),%eax
sub    $0x70,%eax
je     1205 <main+0xc5>
jmp    11ba <main+0x7a>
mov    -0x34(%rbp),%eax
sub    $0x73,%eax
jne    1244 <main+0x104>
jmp    11cb <main+0x8b>
mov    0x2e26(%rip),%rax
cmpl   $0x0,(%rax)
je     11f9 <main+0xb9>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1050 <strdup@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1200 <main+0xc0>
mov    $0x0,%al
call   1060 <c_usage@plt>
jmp    124b <main+0x10b>
mov    0x2dec(%rip),%rax
cmpl   $0x0,(%rax)
je     1233 <main+0xf3>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    123a <main+0xfa>
mov    $0x0,%al
call   1060 <c_usage@plt>
jmp    124b <main+0x10b>
jmp    1244 <main+0x104>
mov    $0x0,%al
call   1060 <c_usage@plt>
jmp    116b <main+0x2b>
cmpl   $0x0,-0x2c(%rbp)
je     1264 <main+0x124>
cmpl   $0x0,-0x30(%rbp)
jne    126b <main+0x12b>
mov    $0x0,%al
call   1060 <c_usage@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <c_run@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x14(%rsp)
lea    0xeb4(%rip),%r12
lea    0x2ee7(%rip),%r13
lea    0x14(%rsp),%r14
mov    0x2e83(%rip),%r15
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
jmp    119c <main+0x5c>
nopw   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     11fb <main+0xbb>
xor    %eax,%eax
call   1060 <c_usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1030 <getopt_long@plt>
cmp    $0x70,%eax
je     11e0 <main+0xa0>
cmp    $0x73,%eax
jne    1190 <main+0x50>
mov    (%r15),%edi
test   %edi,%edi
je     1195 <main+0x55>
call   1050 <strdup@plt>
mov    %rax,0x18(%rsp)
mov    $0x1,%al
mov    %eax,0x10(%rsp)
jmp    119c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%edi
test   %edi,%edi
je     1195 <main+0x55>
call   1050 <strdup@plt>
mov    %rax,0x20(%rsp)
movl   $0x1,0xc(%rsp)
jmp    119c <main+0x5c>
cmpl   $0x0,0xc(%rsp)
setne  %al
test   %al,0x10(%rsp)
jne    1210 <main+0xd0>
xor    %eax,%eax
call   1060 <c_usage@plt>
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
call   1040 <c_run@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@main.client_options = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 115 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 112 }]
@.str = [10 x i8] c"server-ip\00"
@.str.1 = [12 x i8] c"server-port\00"
@.str.2 = [2 x i8] c":\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %40, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt_long(i32 %13, i8** %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.client_options, i64 0, i64 0), i32* %7)
store i32 %15, i32* %6
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %41
17: ; preds = %12
%18 = load i32, i32* %6
switch i32 %18, label %38 [
i32 115, label %19
i32 112, label %28
i32 63, label %37
]
19: ; preds = %17
%20 = load i32, i32* @optarg
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* @optarg
%24 = call i8* @strdup(i32 %23)
store i8* %24, i8** %8
store i32 1, i32* %10
br label %27
25: ; preds = %19
%26 = call i32 (...) @c_usage()
br label %27
27: ; preds = %25, %22
br label %40
28: ; preds = %17
%29 = load i32, i32* @optarg
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @optarg
%33 = call i8* @strdup(i32 %32)
store i8* %33, i8** %9
store i32 1, i32* %11
br label %36
34: ; preds = %28
%35 = call i32 (...) @c_usage()
br label %36
36: ; preds = %34, %31
br label %40
37: ; preds = %17
br label %38
38: ; preds = %17, %37
%39 = call i32 (...) @c_usage()
br label %40
40: ; preds = %38, %36, %27
br label %12
41: ; preds = %12
%42 = load i32, i32* %10
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* %11
%46 = icmp ne i32 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %44, %41
%48 = call i32 (...) @c_usage()
br label %49
49: ; preds = %47, %44
%50 = load i8*, i8** %8
%51 = load i8*, i8** %9
%52 = call i32 @c_run(i8* %50, i8* %51)
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@main.client_options = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 115 }, %struct.option { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 112 }]
@.str = [10 x i8] c"server-ip\00"
@.str.1 = [12 x i8] c"server-port\00"
@.str.2 = [2 x i8] c":\00"
@optarg = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %18, %2
%6 = phi i8* [ %19, %18 ], [ undef, %2 ]
%7 = phi i8* [ %11, %18 ], [ undef, %2 ]
%8 = phi i1 [ true, %18 ], [ false, %2 ]
%9 = phi i32 [ %12, %18 ], [ 0, %2 ]
br label %10
10: ; preds = %5, %25
%11 = phi i8* [ %7, %5 ], [ %26, %25 ]
%12 = phi i32 [ %9, %5 ], [ 1, %25 ]
br label %13
13: ; preds = %29, %10
%14 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.client_options, i64 0, i64 0), i32* %3)
switch i32 %14, label %30 [
i32 -1, label %32
i32 115, label %15
i32 112, label %22
]
15: ; preds = %13
%16 = load i32, i32* @optarg
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i8* @strdup(i32 %16)
br label %5
20: ; preds = %15
%21 = call i32 (...) @c_usage()
br label %29
22: ; preds = %13
%23 = load i32, i32* @optarg
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i8* @strdup(i32 %23)
br label %10
27: ; preds = %22
%28 = call i32 (...) @c_usage()
br label %29
29: ; preds = %27, %20, %30
br label %13
30: ; preds = %13
%31 = call i32 (...) @c_usage()
br label %29
32: ; preds = %13
%33 = icmp ne i32 %12, 0
%34 = select i1 %8, i1 %33, i1 false
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 (...) @c_usage()
br label %37
37: ; preds = %32, %35
%38 = call i32 @c_run(i8* %6, i8* %11)
ret i32 0
}