#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ libadjust_recv_files(char *);
int /*<<< orphan*/ libadjust_socket_close();
int libadjust_socket_open_in();
scalar_t__ libadjust_socket_open_in_accept();
int /*<<< orphan*/ libadjust_stats_print(int /*<<< orphan*/);
int /*<<< orphan*/ log_error_and_exit(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s filename\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int port = libadjust_socket_open_in();
  if (port < 0)
    log_error_and_exit("libadjust_socket_open_in");
  fprintf(stdout, "%d\n", port);
  fflush(stdout);
  if (libadjust_socket_open_in_accept() < 0)
    log_error_and_exit("libadjust_socket_open_in_accept");
  if (libadjust_recv_files(argv[1]) < 0)
    log_error_and_exit("libadjust_recv_file");
  libadjust_socket_close();
  libadjust_stats_print(stdout);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11dc <main+0x4c>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1030 <libadjust_socket_open_in@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11fc <main+0x6c>
lea    0xe1d(%rip),%rdi
call   1040 <log_error_and_exit@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x0,%al
call   1080 <libadjust_socket_open_in_accept@plt>
cmp    $0x0,%rax
jge    1241 <main+0xb1>
lea    0xdf5(%rip),%rdi
call   1040 <log_error_and_exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <libadjust_recv_files@plt>
cmp    $0x0,%rax
jge    1264 <main+0xd4>
lea    0xdf2(%rip),%rdi
call   1040 <log_error_and_exit@plt>
mov    $0x0,%al
call   10b0 <libadjust_socket_close@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   1060 <libadjust_stats_print@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    122a <main+0x9a>
xor    %eax,%eax
call   1030 <libadjust_socket_open_in@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11b9 <main+0x29>
lea    0xe60(%rip),%rdi
call   1040 <log_error_and_exit@plt>
mov    0x2e10(%rip),%r14
mov    (%r14),%edi
lea    0xe63(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   1080 <libadjust_socket_open_in_accept@plt>
test   %rax,%rax
jns    11f3 <main+0x63>
lea    0xe43(%rip),%rdi
call   1040 <log_error_and_exit@plt>
mov    0x8(%rbx),%rdi
call   10a0 <libadjust_recv_files@plt>
test   %rax,%rax
jns    120d <main+0x7d>
lea    0xe49(%rip),%rdi
call   1040 <log_error_and_exit@plt>
xor    %eax,%eax
call   10b0 <libadjust_socket_close@plt>
mov    (%r14),%edi
call   1060 <libadjust_stats_print@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdc3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"usage: %s filename\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [25 x i8] c"libadjust_socket_open_in\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [32 x i8] c"libadjust_socket_open_in_accept\00"
@.str.4 = [20 x i8] c"libadjust_recv_file\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = call i32 (...) @libadjust_socket_open_in()
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @log_error_and_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* @stdout
%25 = load i32, i32* %6
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
%29 = call i64 (...) @libadjust_socket_open_in_accept()
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = call i32 @log_error_and_exit(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %23
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i64 @libadjust_recv_files(i8* %36)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = call i32 @log_error_and_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %33
%42 = call i32 (...) @libadjust_socket_close()
%43 = load i32, i32* @stdout
%44 = call i32 @libadjust_stats_print(i32 %43)
%45 = load i32, i32* @EXIT_SUCCESS
%46 = call i32 @exit(i32 %45)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"usage: %s filename\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [25 x i8] c"libadjust_socket_open_in\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [32 x i8] c"libadjust_socket_open_in_accept\00"
@.str.4 = [20 x i8] c"libadjust_recv_file\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = tail call i32 (...) @libadjust_socket_open_in()
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @log_error_and_exit(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = load i32, i32* @stdout
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%18 = load i32, i32* @stdout
%19 = tail call i32 @fflush(i32 %18)
%20 = tail call i64 (...) @libadjust_socket_open_in_accept()
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = tail call i32 @log_error_and_exit(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %15
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = tail call i64 @libadjust_recv_files(i8* %26)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = tail call i32 @log_error_and_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %24
%32 = tail call i32 (...) @libadjust_socket_close()
%33 = load i32, i32* @stdout
%34 = tail call i32 @libadjust_stats_print(i32 %33)
%35 = load i32, i32* @EXIT_SUCCESS
%36 = tail call i32 @exit(i32 %35)
unreachable
}