#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*/ seraddr;

/* Variables and functions */
int connect_server(char *, short);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ send_data(int, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  short port;
  char seraddr[20];
  char sendstr1[] = "Linux debian 3.16.0-4-amd64 #1 SMP Debian "
                    "3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux";
  int fd = 0;
  port = 1080;
  strncpy(seraddr, "127.0.0.1", sizeof(seraddr));
  if ((fd = connect_server(seraddr, port)) == -1) {
    printf("connect to server failed\n");
    exit(1);
  } else {
    send_data(fd, sendstr1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x59,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x84(%rbp)
movw   $0x438,-0x6(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rdi
movswl -0x6(%rbp),%esi
call   1040 <connect_server@plt>
mov    %eax,-0x84(%rbp)
cmp    $0xffffffff,%eax
jne    11de <main+0x7e>
lea    0xe94(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x84(%rbp),%edi
lea    -0x80(%rbp),%rsi
call   1070 <send_data@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
movups 0xeea(%rip),%xmm0
movups %xmm0,0x49(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe81(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe65(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb3(%rip),%rsi
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x438,%esi
call   1050 <connect_server@plt>
cmp    $0xffffffff,%eax
je     11df <main+0x8f>
mov    %rsp,%rsi
mov    %eax,%edi
call   1060 <send_data@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.sendstr1 = [89 x i8] c"Linux debian 3.16.0-4-amd64 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux\00"
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [26 x i8] c"connect to server failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca [20 x i8]
%4 = alloca [89 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [89 x i8]* %4 to i8*
store i32 0, i32* %5
store i16 1080, i16* %2
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i32 @strncpy(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 20)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = load i16, i16* %2
%11 = call i32 @connect_server(i8* %9, i16 signext %10)
store i32 %11, i32* %5
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* %5
%18 = getelementptr inbounds [89 x i8], [89 x i8]* %4, i64 0, i64 0
%19 = call i32 @send_data(i32 %17, i8* %18)
br label %20
20: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.sendstr1 = [89 x i8] c"Linux debian 3.16.0-4-amd64 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux\00"
@.str = [10 x i8] c"127.0.0.1\00"
@str = [25 x i8] c"connect to server failed\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [89 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [89 x i8], [89 x i8]* %2, i64 0, i64 0
%5 = call i32 @strncpy(i8* %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 20)
%6 = call i32 @connect_server(i8* %3, i16 signext 1080)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 @send_data(i32 %6, i8* %4)
ret i32 0
}