#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*/ clientStream(int, char *);
int /*<<< orphan*/ close(int);
int createClientSocket(char *, char *);
int /*<<< orphan*/ getSockName(int);
int /*<<< orphan*/ sysError(char *);
int /*<<< orphan*/ usrError(char *);
int main(int argc, char **argv) {
  if (argc != 4)
    usrError("Usage:\tClient <address/domain> <service/port> <string>");
  char *address = argv[1];
  char *service = argv[2];
  char *string = argv[3];
  int clntSock = createClientSocket(address, service);
  if (clntSock < 0)
    sysError("connection failed");
  getSockName(clntSock);
  clientStream(clntSock, string);
  close(clntSock);
  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)
cmpl   $0x4,-0x8(%rbp)
je     118c <main+0x2c>
lea    0xe79(%rip),%rdi
call   1040 <usrError@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <createClientSocket@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11d6 <main+0x76>
lea    0xe66(%rip),%rdi
call   1030 <sysError@plt>
mov    -0x2c(%rbp),%edi
call   1080 <getSockName@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1070 <clientStream@plt>
mov    -0x2c(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x4,%edi
je     1177 <main+0x17>
lea    0xe8e(%rip),%rdi
call   1040 <usrError@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    0x18(%rbx),%rbx
call   1060 <createClientSocket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    119a <main+0x3a>
lea    0xea2(%rip),%rdi
call   1030 <sysError@plt>
mov    %ebp,%edi
call   1080 <getSockName@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <clientStream@plt>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Usage:\09Client <address/domain> <service/port> <string>\00"
@.str.1 = [18 x i8] c"connection failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @usrError(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i32 @createClientSocket(i8* %24, i8* %25)
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %14
%30 = call i32 @sysError(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %14
%32 = load i32, i32* %9
%33 = call i32 @getSockName(i32 %32)
%34 = load i32, i32* %9
%35 = load i8*, i8** %8
%36 = call i32 @clientStream(i32 %34, i8* %35)
%37 = load i32, i32* %9
%38 = call i32 @close(i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"Usage:\09Client <address/domain> <service/port> <string>\00"
@.str.1 = [18 x i8] c"connection failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @usrError(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @createClientSocket(i8* %8, i8* %10)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = tail call i32 @sysError(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %6
%18 = tail call i32 @getSockName(i32 %13)
%19 = tail call i32 @clientStream(i32 %13, i8* %12)
%20 = tail call i32 @close(i32 %13)
ret i32 0
}