#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*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ libadjust_send_files(int, char **);
int /*<<< orphan*/ libadjust_socket_close();
scalar_t__ libadjust_socket_open_out(int);
int /*<<< orphan*/ libadjust_stats_print(int /*<<< orphan*/);
int /*<<< orphan*/ log_error_and_exit(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "usage: %s port filename\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int port;
  sscanf(argv[1], "%d", &port);
  if (libadjust_socket_open_out(port) < 0)
    log_error_and_exit("libadjust_socket_open_out");
  if (libadjust_send_files(1, argv + 2) < 0)
    log_error_and_exit("libadjust_send_files");
  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   $0x3,-0x8(%rbp)
je     11ca <main+0x4a>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x14(%rbp),%edi
call   1090 <libadjust_socket_open_out@plt>
cmp    $0x0,%rax
jge    1200 <main+0x80>
lea    0xe21(%rip),%rdi
call   1030 <log_error_and_exit@plt>
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
mov    $0x1,%edi
call   1070 <libadjust_send_files@plt>
cmp    $0x0,%rax
jge    1228 <main+0xa8>
lea    0xe13(%rip),%rdi
call   1030 <log_error_and_exit@plt>
mov    $0x0,%al
call   10a0 <libadjust_socket_close@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
call   1050 <libadjust_stats_print@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1201 <main+0x81>
mov    0x8(%rbx),%rdi
lea    0xe81(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    0xc(%rsp),%edi
call   1090 <libadjust_socket_open_out@plt>
test   %rax,%rax
jns    11bc <main+0x3c>
lea    0xe65(%rip),%rdi
call   1030 <log_error_and_exit@plt>
add    $0x10,%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1070 <libadjust_send_files@plt>
test   %rax,%rax
jns    11de <main+0x5e>
lea    0xe5d(%rip),%rdi
call   1030 <log_error_and_exit@plt>
xor    %eax,%eax
call   10a0 <libadjust_socket_close@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1050 <libadjust_stats_print@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdec(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"usage: %s port filename\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"libadjust_socket_open_out\00"
@.str.3 = [21 x i8] c"libadjust_send_files\00"
@stdout = 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
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, 3
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 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 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 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%22 = load i32, i32* %6
%23 = call i64 @libadjust_socket_open_out(i32 %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @log_error_and_exit(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %17
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = call i64 @libadjust_send_files(i32 1, i8** %29)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @log_error_and_exit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %27
%35 = call i32 (...) @libadjust_socket_close()
%36 = load i32, i32* @stdout
%37 = call i32 @libadjust_stats_print(i32 %36)
%38 = load i32, i32* @EXIT_SUCCESS
%39 = call i32 @exit(i32 %38)
unreachable
}

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