#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 atoi(char *);
int /*<<< orphan*/ command_loop(int);
int do_connect(char *, int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int port;
  int sd;
  if (argc < 2) {
    usage();
    return 1;
  }
  if (argc < 3) {
    port = 10500;
  } else {
    port = atoi(argv[2]);
  }
  sd = do_connect(argv[1], port);
  command_loop(sd);
  return 0;
}


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)
jge    1173 <main+0x33>
mov    $0x0,%al
call   1050 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bb <main+0x7b>
cmpl   $0x3,-0x8(%rbp)
jge    1189 <main+0x49>
movl   $0x2904,-0x14(%rbp)
jmp    1199 <main+0x59>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <do_connect@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <command_loop@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1154 <main+0x14>
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0x1,%eax
pop    %rbx
ret
mov    %rsi,%rbx
mov    $0x2904,%esi
cmp    $0x2,%edi
je     116c <main+0x2c>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%esi
mov    0x8(%rbx),%rdi
call   1030 <do_connect@plt>
mov    %eax,%edi
call   1040 <command_loop@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
store i32 1, i32* %3
br label %29
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 10500, i32* %6
br label %21
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
br label %21
21: ; preds = %16, %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* %6
%26 = call i32 @do_connect(i8* %24, i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = call i32 @command_loop(i32 %27)
store i32 0, i32* %3
br label %29
29: ; preds = %21, %10
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %18
6: ; preds = %2
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
br label %12
12: ; preds = %6, %8
%13 = phi i32 [ %11, %8 ], [ 10500, %6 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @do_connect(i8* %15, i32 %13)
%17 = tail call i32 @command_loop(i32 %16)
br label %18
18: ; preds = %12, %4
%19 = phi i32 [ 1, %4 ], [ 0, %12 ]
ret i32 %19
}