#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ catch_objects(char *, unsigned short);
int /*<<< orphan*/ display_help(char **);
int /*<<< orphan*/ display_usage(char **, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ get_ip_port(char **, unsigned short *, int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ stderr;
char *strdup(char *);
int main(int argc, char *argv[]) {
  int opt;
  char *hostname = strdup("127.0.0.1");
  unsigned short port = 7070;
  while ((opt = getopt(argc, argv, "hw:")) != -1)
    switch (opt) {
    case 'h':
      display_help(argv);
      break;
    case 'w':
      free(hostname);
      get_ip_port(&hostname, &port, optarg);
      break;
    default:
      display_usage(argv, stderr);
      return EXIT_FAILURE;
    }
  catch_objects(hostname, port);
  free(hostname);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x20(%rbp)
movw   $0x1b9e,-0x22(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     123a <main+0xca>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x68,%eax
je     11e0 <main+0x70>
jmp    11cf <main+0x5f>
mov    -0x28(%rbp),%eax
sub    $0x77,%eax
je     11ee <main+0x7e>
jmp    1212 <main+0xa2>
mov    -0x10(%rbp),%rdi
call   1060 <display_help@plt>
jmp    1235 <main+0xc5>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x22(%rbp),%rsi
call   1070 <get_ip_port@plt>
jmp    1235 <main+0xc5>
mov    -0x10(%rbp),%rdi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
call   1050 <display_usage@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125c <main+0xec>
jmp    119c <main+0x2c>
mov    -0x20(%rbp),%rdi
movzwl -0x22(%rbp),%esi
call   1040 <catch_objects@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe76(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,0x10(%rsp)
movw   $0x1b9e,0xe(%rsp)
lea    0xe68(%rip),%r14
mov    0x2e4f(%rip),%r13
lea    0x10(%rsp),%r15
lea    0xe(%rsp),%r12
jmp    11c8 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1060 <display_help@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
cmp    $0x68,%eax
je     11c0 <main+0x50>
cmp    $0x77,%eax
jne    11fa <main+0x8a>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <get_ip_port@plt>
jmp    11c8 <main+0x58>
cmp    $0xffffffff,%eax
jne    1221 <main+0xb1>
mov    0x10(%rsp),%rdi
movzwl 0xe(%rsp),%esi
call   1040 <catch_objects@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x2da9(%rip),%rax
jmp    1239 <main+0xc9>
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1050 <display_usage@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [4 x i8] c"hw:\00"
@optarg = global i32 0
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i8* @strdup(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %7
store i16 7070, i16* %8
br label %10
10: ; preds = %30, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %31
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %25 [
i32 104, label %17
i32 119, label %20
]
17: ; preds = %15
%18 = load i8**, i8*** %5
%19 = call i32 @display_help(i8** %18)
br label %30
20: ; preds = %15
%21 = load i8*, i8** %7
%22 = call i32 @free(i8* %21)
%23 = load i32, i32* @optarg
%24 = call i32 @get_ip_port(i8** %7, i16* %8, i32 %23)
br label %30
25: ; preds = %15
%26 = load i8**, i8*** %5
%27 = load i32, i32* @stderr
%28 = call i32 @display_usage(i8** %26, i32 %27)
%29 = load i32, i32* @EXIT_FAILURE
store i32 %29, i32* %3
br label %38
30: ; preds = %20, %17
br label %10
31: ; preds = %10
%32 = load i8*, i8** %7
%33 = load i16, i16* %8
%34 = call i32 @catch_objects(i8* %32, i16 zeroext %33)
%35 = load i8*, i8** %7
%36 = call i32 @free(i8* %35)
%37 = load i32, i32* @EXIT_SUCCESS
store i32 %37, i32* %3
br label %38
38: ; preds = %31, %25
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [4 x i8] c"hw:\00"
@optarg = global i32 0
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = bitcast i8** %3 to i8*
%6 = tail call dereferenceable_or_null(10) i8* @strdup(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = bitcast i16* %4 to i8*
store i16 7070, i16* %4
br label %8
8: ; preds = %17, %2
%9 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
switch i32 %9, label %18 [
i32 -1, label %21
i32 104, label %10
i32 119, label %12
]
10: ; preds = %8
%11 = call i32 @display_help(i8** %1)
br label %17
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
%15 = load i32, i32* @optarg
%16 = call i32 @get_ip_port(i8** %3, i16* %4, i32 %15)
br label %17
17: ; preds = %12, %10
br label %8
18: ; preds = %8
%19 = load i32, i32* @stderr
%20 = call i32 @display_usage(i8** %1, i32 %19)
br label %27
21: ; preds = %8
%22 = load i8*, i8** %3
%23 = load i16, i16* %4
%24 = call i32 @catch_objects(i8* %22, i16 zeroext %23)
%25 = load i8*, i8** %3
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %21, %18
%28 = phi i32* [ @EXIT_FAILURE, %18 ], [ @EXIT_SUCCESS, %21 ]
%29 = load i32, i32* %28
ret i32 %29
}