#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 */
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int input_subsystem_init();
int /*<<< orphan*/ mainloop(int, int);
int socket_init(int /*<<< orphan*/);
int /*<<< orphan*/ strtoul(char *, char **, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  char *endptr = NULL;
  uint16_t port;
  int sock, uinput;
  if (argc < 2)
    usage(argv[0]);
  port = strtoul(argv[1], &endptr, 10);
  if (*endptr != '\0')
    usage(argv[0]);
  uinput = input_subsystem_init();
  sock = socket_init(port);
  mainloop(sock, uinput);
  return 0;
}


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)
movq   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1184 <main+0x34>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    $0x0,%al
call   1040 <input_subsystem_init@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <socket_init@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1070 <mainloop@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
movq   $0x0,(%rsp)
cmp    $0x1,%edi
jg     116b <main+0x1b>
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     118f <main+0x3f>
mov    (%rbx),%rdi
call   1050 <usage@plt>
xor    %eax,%eax
call   1040 <input_subsystem_init@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <socket_init@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1070 <mainloop@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @usage(i8* %15)
br label %17
17: ; preds = %12, %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strtoul(i8* %20, i8** %6, i32 10)
store i32 %21, i32* %7
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @usage(i8* %29)
br label %31
31: ; preds = %26, %17
%32 = call i32 (...) @input_subsystem_init()
store i32 %32, i32* %9
%33 = load i32, i32* %7
%34 = call i32 @socket_init(i32 %33)
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = call i32 @mainloop(i32 %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @usage(i8* %7)
br label %9
9: ; preds = %6, %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strtoul(i8* %11, i8** %3, i32 10)
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17)
br label %19
19: ; preds = %16, %9
%20 = tail call i32 (...) @input_subsystem_init()
%21 = tail call i32 @socket_init(i32 %12)
%22 = tail call i32 @mainloop(i32 %21, i32 %20)
ret i32 0
}