#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*/ chatter(int);
int connectToHost(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char *argv[]) {
  int sockfd;
  int len;
  ;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <host> <username>\n", argv[0]);
    return 1;
  }
  if ((len = strlen(argv[2]) + 1) > 20) {
    fprintf(stderr, "client: username is too long\n");
    return 2;
  }
  sockfd = connectToHost(argv[1]);
  if (send(sockfd, argv[2], len, 0) == -1) {
    perror("client: failed to send name");
    return 5;
  }
  chatter(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)
je     11aa <main+0x4a>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmp    $0x14,%eax
jle    11e9 <main+0x89>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    123e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <connectToHost@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
jne    122f <main+0xcf>
lea    0xe1d(%rip),%rdi
call   1080 <perror@plt>
movl   $0x5,-0x4(%rbp)
jmp    123e <main+0xde>
mov    -0x14(%rbp),%edi
call   1030 <chatter@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    1198 <main+0x38>
mov    0x10(%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x14,%eax
jl     11b9 <main+0x59>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x2,%ebx
jmp    11e8 <main+0x88>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe55(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%ebx
jmp    11e8 <main+0x88>
mov    %eax,%ebp
add    $0x1,%ebp
mov    0x8(%rbx),%rdi
call   1060 <connectToHost@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rsi
xor    %ebx,%ebx
mov    %eax,%edi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0xffffffff,%eax
je     11ef <main+0x8f>
mov    %r14d,%edi
call   1030 <chatter@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe45(%rip),%rdi
call   1080 <perror@plt>
mov    $0x5,%ebx
jmp    11e8 <main+0x88>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: %s <host> <username>\0A\00"
@.str.1 = [30 x i8] c"client: username is too long\0A\00"
@.str.2 = [28 x i8] c"client: failed to send name\00"
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 ne i32 %8, 3
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %43
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
%22 = icmp sgt i32 %21, 20
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %43
26: ; preds = %16
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @connectToHost(i8* %29)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = load i32, i32* %7
%36 = call i32 @send(i32 %31, i8* %34, i32 %35, i32 0)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %40
38: ; preds = %26
%39 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 5, i32* %3
br label %43
40: ; preds = %26
%41 = load i32, i32* %6
%42 = call i32 @chatter(i32 %41)
store i32 0, i32* %3
br label %43
43: ; preds = %40, %38, %23, %10
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: %s <host> <username>\0A\00"
@.str.1 = [30 x i8] c"client: username is too long\0A\00"
@.str.2 = [28 x i8] c"client: failed to send name\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %28
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 19
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %28
16: ; preds = %8
%17 = add nsw i32 %11, 1
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @connectToHost(i8* %19)
%21 = load i8*, i8** %9
%22 = tail call i32 @send(i32 %20, i8* %21, i32 %17, i32 0)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %28
26: ; preds = %16
%27 = tail call i32 @chatter(i32 %20)
br label %28
28: ; preds = %26, %24, %13, %4
%29 = phi i32 [ 1, %4 ], [ 2, %13 ], [ 5, %24 ], [ 0, %26 ]
ret i32 %29
}