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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ libadjust_socket_close();
scalar_t__ libadjust_socket_open_out(int);
scalar_t__ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
scalar_t__ transmit(int, char **);
int /*<<< orphan*/ usage();
int start_client(int argc, char *argv[]) {
  if (argc < 1)
    usage();
  char buffer[BUFSIZ];
  fgets(buffer, sizeof(buffer), stdin);
  int port;
  if (sscanf(buffer, "%d\n", &port) < 0)
    return -1;
  if (libadjust_socket_open_out(port) < 0)
    errx(EXIT_FAILURE, "libadjust_socket_open_out");
  if (transmit(argc, argv) < 0)
    errx(EXIT_FAILURE, "transmit");
  libadjust_socket_close();
  return 0;
}


x86 assembly (clang, -O0):
<start_client>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    1190 <start_client+0x20>
mov    $0x0,%al
call   1070 <usage@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    %eax,%esi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
mov    -0x30(%rbp),%rdi
lea    0xe29(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x0,%rax
jge    11fd <start_client+0x8d>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    1264 <start_client+0xf4>
mov    -0x24(%rbp),%edi
call   1080 <libadjust_socket_open_out@plt>
cmp    $0x0,%rax
jge    1224 <start_client+0xb4>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
call   1030 <errx@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <transmit@plt>
cmp    $0x0,%rax
jge    124f <start_client+0xdf>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
call   1030 <errx@plt>
mov    $0x0,%al
call   1090 <libadjust_socket_close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_client>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
test   %edi,%edi
jg     118b <start_client+0x1b>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2e39(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1040 <fgets@plt>
lea    0xe40(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    %rbx,%rdi
call   1060 <sscanf@plt>
test   %rax,%rax
js     1223 <start_client+0xb3>
mov    -0x1c(%rbp),%edi
call   1080 <libadjust_socket_open_out@plt>
test   %rax,%rax
jns    11f3 <start_client+0x83>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
call   1030 <errx@plt>
mov    %r15d,%edi
mov    %r14,%rsi
call   1050 <transmit@plt>
test   %rax,%rax
jns    1218 <start_client+0xa8>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
call   1030 <errx@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <libadjust_socket_close@plt>
jmp    1228 <start_client+0xb8>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [26 x i8] c"libadjust_socket_open_out\00"
@.str.2 = [9 x i8] c"transmit\00"
define i32 @start_client(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @usage()
br label %14
14: ; preds = %12, %2
%15 = load i32, i32* @BUFSIZ
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %6
%18 = alloca i8, i64 %16
store i64 %16, i64* %7
%19 = trunc i64 %16 to i32
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %18, i32 %19, i32 %20)
%22 = call i64 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %8)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %14
store i32 -1, i32* %3
store i32 1, i32* %9
br label %42
25: ; preds = %14
%26 = load i32, i32* %8
%27 = call i64 @libadjust_socket_open_out(i32 %26)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @errx(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %29, %25
%33 = load i32, i32* %4
%34 = load i8**, i8*** %5
%35 = call i64 @transmit(i32 %33, i8** %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @errx(i32 %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %37, %32
%41 = call i32 (...) @libadjust_socket_close()
store i32 0, i32* %3
store i32 1, i32* %9
br label %42
42: ; preds = %40, %24
%43 = load i8*, i8** %6
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [26 x i8] c"libadjust_socket_open_out\00"
@.str.2 = [9 x i8] c"transmit\00"
define i32 @start_client(i32 %0, i8** %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (...) @usage()
br label %7
7: ; preds = %5, %2
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 %8, i32 %11)
%13 = bitcast i32* %3 to i8*
%14 = call i64 @sscanf(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = icmp slt i64 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = call i64 @libadjust_socket_open_out(i32 %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @errx(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %16
%24 = call i64 @transmit(i32 %0, i8** %1)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @errx(i32 %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %26, %23
%30 = call i32 (...) @libadjust_socket_close()
br label %31
31: ; preds = %7, %29
%32 = phi i32 [ 0, %29 ], [ -1, %7 ]
ret i32 %32
}