#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 _connect(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mainloop(int, char **, int);
int /*<<< orphan*/ strtoul(char *, char **, int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  uint16_t port;
  char *endptr = NULL;
  int aibd_sock;
  if (argc < 4)
    usage(argv[0]);
  port = strtoul(argv[2], &endptr, 10);
  if (*endptr != '\0')
    usage(argv[0]);
  aibd_sock = _connect(argv[1], port);
  mainloop(aibd_sock, argv + 3, argc - 3);
  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,-0x20(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1174 <main+0x34>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1040 <_connect@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x18,%rsi
mov    -0x8(%rbp),%edx
sub    $0x3,%edx
call   1060 <mainloop@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
cmp    $0x3,%edi
jg     1163 <main+0x23>
mov    (%rbx),%rdi
call   1030 <usage@plt>
mov    0x10(%rbx),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rax
cmpb   $0x0,(%rax)
je     118b <main+0x4b>
mov    (%rbx),%rdi
call   1030 <usage@plt>
mov    0x8(%rbx),%rdi
mov    %r14d,%esi
call   1040 <_connect@plt>
add    $0x18,%rbx
add    $0xfffffffd,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <mainloop@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
br label %16
16: ; preds = %11, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @strtoul(i8* %19, i8** %7, i32 10)
store i32 %20, i32* %6
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %16
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 @usage(i8* %28)
br label %30
30: ; preds = %25, %16
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = load i32, i32* %6
%35 = call i32 @_connect(i8* %33, i32 %34)
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 3
%41 = call i32 @mainloop(i32 %36, i8** %38, i32 %40)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp slt i32 %0, 4
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 2
%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 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @_connect(i8* %21, i32 %12)
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = add nsw i32 %0, -3
%25 = tail call i32 @mainloop(i32 %22, i8** %23, i32 %24)
ret i32 0
}