#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*/ atoi(char *);
int /*<<< orphan*/ disconnect_server(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int open_connection_to(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read_one_line(int);
int /*<<< orphan*/ recv_message(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int sockfd;
  if (argc < 3) {
    usage();
    exit(0);
  }
  if ((sockfd = open_connection_to(argv[1], atoi(argv[2]))) == 0) {
    report_error("couldn't open connection to destination");
    return -1;
  }
  recv_message(sockfd);
  read_one_line(sockfd);
  disconnect_server(sockfd);
  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   $0x3,-0x8(%rbp)
jge    11ae <main+0x2e>
mov    $0x0,%al
call   1070 <usage@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   10a0 <open_connection_to@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    11f6 <main+0x76>
lea    0xe1b(%rip),%rdi
call   1060 <report_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1215 <main+0x95>
mov    -0x14(%rbp),%edi
call   1050 <recv_message@plt>
mov    -0x14(%rbp),%edi
call   1030 <read_one_line@plt>
mov    -0x14(%rbp),%edi
call   1040 <disconnect_server@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jle    11cf <main+0x4f>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%rdi
call   1080 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <open_connection_to@plt>
test   %eax,%eax
je     11bc <main+0x3c>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <recv_message@plt>
mov    %ebx,%edi
call   1030 <read_one_line@plt>
mov    %ebx,%edi
call   1040 <disconnect_server@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe3d(%rip),%rdi
call   1060 <report_error@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1070 <usage@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"couldn't open connection to destination\00"
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 slt i32 %7, 3
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (...) @usage()
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
%20 = call i32 @open_connection_to(i8* %15, i32 %19)
store i32 %20, i32* %6
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = call i32 @report_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %31
24: ; preds = %12
%25 = load i32, i32* %6
%26 = call i32 @recv_message(i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @read_one_line(i32 %27)
%29 = load i32, i32* %6
%30 = call i32 @disconnect_server(i32 %29)
store i32 0, i32* %3
br label %31
31: ; preds = %24, %22
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [40 x i8] c"couldn't open connection to destination\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 (...) @usage()
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 @open_connection_to(i8* %9, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = tail call i32 @report_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %21
17: ; preds = %7
%18 = tail call i32 @recv_message(i32 %13)
%19 = tail call i32 @read_one_line(i32 %13)
%20 = tail call i32 @disconnect_server(i32 %13)
br label %21
21: ; preds = %17, %15
%22 = phi i32 [ -1, %15 ], [ 0, %17 ]
ret i32 %22
}