#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*/ member_1;
};

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
int /*<<< orphan*/ handle(int, char const *);
int open_socket(char const *, char const *);
char *optarg;
int optind;
#define required_argument 128
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char const *);
int main(int argc, char *argv[]) {
  const char *progname = argv[0];
  const char *host;
  const char *port = "8053";
  const char *msg;
  static struct option longopts[] = {{"port", required_argument, NULL, 'p'},
                                     {NULL, 0, NULL, 0}};
  int opt;
  while ((opt = getopt_long(argc, argv, "p:", longopts, NULL)) != -1) {
    switch (opt) {
    case 'p':
      port = optarg;
      break;
    case ':':
    case '?':
    default:
      usage(argv[0]);
      return EXIT_FAILURE;
    }
  }
  if (argc < optind) {
    fprintf(stderr, "%s: missing argument -- <server>\n", progname);
    usage(progname);
  }
  host = argv[optind++];
  if (argc < optind) {
    fprintf(stderr, "%s: missing argument -- <message>\n", progname);
    usage(progname);
  }
  msg = argv[optind];
  int s = open_socket(host, port);
  if (s == -1) {
    fprintf(stderr, "Cannot contact %s:%s\n", host, port);
    return EXIT_FAILURE;
  }
  handle(s, msg);
}


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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe88(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdx
lea    0x2ebf(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1217 <main+0xc7>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3a,%eax
je     11f0 <main+0xa0>
jmp    11bb <main+0x6b>
mov    -0x3c(%rbp),%eax
sub    $0x3f,%eax
je     11f0 <main+0xa0>
jmp    11cc <main+0x7c>
mov    -0x3c(%rbp),%eax
sub    $0x70,%eax
jne    11f5 <main+0xa5>
jmp    11dd <main+0x8d>
mov    0x2e14(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1212 <main+0xc2>
jmp    11f5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1315 <main+0x1c5>
jmp    117c <main+0x2c>
mov    -0x8(%rbp),%eax
mov    0x2dbf(%rip),%rcx
cmp    (%rcx),%eax
jge    124d <main+0xfd>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d88(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d7a(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2d63(%rip),%rcx
cmp    (%rcx),%eax
jge    12a9 <main+0x159>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2d2c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <open_socket@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    1309 <main+0x1b9>
mov    0x2cf0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xd61(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1315 <main+0x1c5>
mov    -0x38(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <handle@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
mov    (%rsi),%rax
mov    %rax,(%rsp)
lea    0xe92(%rip),%r14
lea    0xe95(%rip),%r12
lea    0x2ed4(%rip),%rbx
mov    0x2e75(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
cmp    $0x70,%eax
jne    11ad <main+0x5d>
mov    (%r15),%r14
jmp    1190 <main+0x40>
cmp    $0xffffffff,%eax
jne    124d <main+0xfd>
mov    0x2e23(%rip),%r15
mov    (%r15),%ecx
cmp    %ebp,%ecx
jle    11ed <main+0x9d>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
mov    (%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <usage@plt>
mov    (%r15),%ecx
lea    0x1(%rcx),%eax
mov    %eax,(%r15)
movslq %ecx,%rcx
mov    0x0(%r13,%rcx,8),%r12
cmp    %ebp,%ecx
jl     1228 <main+0xd8>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
mov    (%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1070 <usage@plt>
mov    (%r15),%eax
cltq
mov    0x0(%r13,%rax,8),%rbx
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <open_socket@plt>
cmp    $0xffffffff,%eax
je     1258 <main+0x108>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <handle@plt>
xor    %eax,%eax
jmp    127e <main+0x12e>
mov    0x0(%r13),%rdi
call   1070 <usage@plt>
jmp    1275 <main+0x125>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"8053\00"
@main.longopts = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 112 }, %struct.option zeroinitializer]
@.str.1 = [5 x i8] c"port\00"
@.str.2 = [3 x i8] c"p:\00"
@optarg = global i8* null
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@stderr = global i32 0
@.str.3 = [34 x i8] c"%s: missing argument -- <server>\0A\00"
@.str.4 = [35 x i8] c"%s: missing argument -- <message>\0A\00"
@.str.5 = [22 x i8] c"Cannot contact %s:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%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
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
store i8* %14, i8** %6
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
br label %15
15: ; preds = %31, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt_long(i32 %16, i8** %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
store i32 %18, i32* %10
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %10
switch i32 %21, label %25 [
i32 112, label %22
i32 58, label %24
i32 63, label %24
]
22: ; preds = %20
%23 = load i8*, i8** @optarg
store i8* %23, i8** %8
br label %31
24: ; preds = %20, %20
br label %25
25: ; preds = %20, %24
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @usage(i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %79
31: ; preds = %22
br label %15
32: ; preds = %15
%33 = load i32, i32* %4
%34 = load i32, i32* @optind
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %6
%39 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %6
%41 = call i32 @usage(i8* %40)
br label %42
42: ; preds = %36, %32
%43 = load i8**, i8*** %5
%44 = load i32, i32* @optind
%45 = add nsw i32 %44, 1
store i32 %45, i32* @optind
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
%48 = load i8*, i8** %47
store i8* %48, i8** %7
%49 = load i32, i32* %4
%50 = load i32, i32* @optind
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %58
52: ; preds = %42
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %6
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %54)
%56 = load i8*, i8** %6
%57 = call i32 @usage(i8* %56)
br label %58
58: ; preds = %52, %42
%59 = load i8**, i8*** %5
%60 = load i32, i32* @optind
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
store i8* %63, i8** %9
%64 = load i8*, i8** %7
%65 = load i8*, i8** %8
%66 = call i32 @open_socket(i8* %64, i8* %65)
store i32 %66, i32* %11
%67 = load i32, i32* %11
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %75
69: ; preds = %58
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %7
%72 = load i8*, i8** %8
%73 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %71, i8* %72)
%74 = load i32, i32* @EXIT_FAILURE
store i32 %74, i32* %3
br label %79
75: ; preds = %58
%76 = load i32, i32* %11
%77 = load i8*, i8** %9
%78 = call i32 @handle(i32 %76, i8* %77)
br label %79
79: ; preds = %75, %69, %25
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [5 x i8] c"8053\00"
@main.longopts = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 112 }, %struct.option zeroinitializer]
@.str.1 = [5 x i8] c"port\00"
@.str.2 = [3 x i8] c"p:\00"
@optarg = global i8* null
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@stderr = global i32 0
@.str.3 = [34 x i8] c"%s: missing argument -- <server>\0A\00"
@.str.4 = [35 x i8] c"%s: missing argument -- <message>\0A\00"
@.str.5 = [22 x i8] c"Cannot contact %s:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i8*, i8** %1
br label %4
4: ; preds = %7, %2
%5 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ], [ %8, %7 ]
%6 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
switch i32 %6, label %9 [
i32 -1, label %13
i32 112, label %7
]
7: ; preds = %4
%8 = load i8*, i8** @optarg
br label %4
9: ; preds = %4
%10 = load i8*, i8** %1
%11 = tail call i32 @usage(i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
br label %46
13: ; preds = %4
%14 = load i32, i32* @optind
%15 = icmp sgt i32 %14, %0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%19 = tail call i32 @usage(i8* %3)
%20 = load i32, i32* @optind
br label %21
21: ; preds = %16, %13
%22 = phi i32 [ %20, %16 ], [ %14, %13 ]
%23 = add nsw i32 %22, 1
store i32 %23, i32* @optind
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = icmp slt i32 %22, %0
br i1 %27, label %33, label %28
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%31 = tail call i32 @usage(i8* %3)
%32 = load i32, i32* @optind
br label %33
33: ; preds = %28, %21
%34 = phi i32 [ %32, %28 ], [ %23, %21 ]
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %1, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 @open_socket(i8* %26, i8* %5)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %26, i8* %5)
%43 = load i32, i32* @EXIT_FAILURE
br label %46
44: ; preds = %33
%45 = tail call i32 @handle(i32 %38, i8* %37)
br label %46
46: ; preds = %40, %44, %9
%47 = phi i32 [ %12, %9 ], [ %43, %40 ], [ 0, %44 ]
ret i32 %47
}