#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*/ close_connection();
int /*<<< orphan*/ connect_to_nnserver();
int /*<<< orphan*/ wait_for_connecting();
int /*<<< orphan*/ write_msg(char *);
int main(int argc, char *argv[]) {
  connect_to_nnserver();
  wait_for_connecting();
  if (argc > 1) {
    for (int i = 1; i < argc; i++) {
      write_msg(argv[i]);
      if ((i + 1) < argc) {
        write_msg(" ");
      }
    }
  } else {
    write_msg("echo ...");
  }
  close_connection();
  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)
mov    $0x0,%al
call   1050 <connect_to_nnserver@plt>
mov    $0x0,%al
call   1030 <wait_for_connecting@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11c5 <main+0x85>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c0 <main+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <write_msg@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    11ad <main+0x6d>
lea    0xe58(%rip),%rdi
call   1060 <write_msg@plt>
jmp    11b2 <main+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1175 <main+0x35>
jmp    11d1 <main+0x91>
lea    0xe36(%rip),%rdi
call   1060 <write_msg@plt>
mov    $0x0,%al
call   1040 <close_connection@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebp
xor    %eax,%eax
call   1050 <connect_to_nnserver@plt>
xor    %eax,%eax
call   1030 <wait_for_connecting@plt>
cmp    $0x2,%ebp
jl     11ab <main+0x6b>
mov    %ebp,%r12d
mov    $0x1,%ebx
sub    %r12,%rbx
mov    $0x2,%ebp
lea    0xe89(%rip),%r14
jmp    1192 <main+0x52>
nopl   0x0(%rax)
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbp
cmp    $0x2,%rax
je     11b7 <main+0x77>
mov    -0x8(%r15,%rbp,8),%rdi
call   1060 <write_msg@plt>
cmp    %r12,%rbp
jae    1180 <main+0x40>
mov    %r14,%rdi
call   1060 <write_msg@plt>
jmp    1180 <main+0x40>
lea    0xe50(%rip),%rdi
call   1060 <write_msg@plt>
xor    %eax,%eax
call   1040 <close_connection@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [9 x i8] c"echo ...\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 = call i32 (...) @connect_to_nnserver()
%8 = call i32 (...) @wait_for_connecting()
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %34
11: ; preds = %2
store i32 1, i32* %6
br label %12
12: ; preds = %30, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @write_msg(i8* %21)
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %16
%28 = call i32 @write_msg(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %16
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %12
33: ; preds = %12
br label %36
34: ; preds = %2
%35 = call i32 @write_msg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %33
%37 = call i32 (...) @close_connection()
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [9 x i8] c"echo ...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @connect_to_nnserver()
%4 = tail call i32 (...) @wait_for_connecting()
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = zext i32 %0 to i64
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %18
%10 = phi i64 [ 1, %6 ], [ %14, %18 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @write_msg(i8* %12)
%14 = add nuw nsw i64 %10, 1
%15 = icmp ult i64 %14, %7
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 @write_msg(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %9, %16
%19 = icmp eq i64 %14, %8
br i1 %19, label %22, label %9
20: ; preds = %2
%21 = tail call i32 @write_msg(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %18, %20
%23 = tail call i32 (...) @close_connection()
ret i32 0
}