#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ end_remoto;

/* Variables and functions */
void *AF_INET;
int SOCK_STREAM;
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ funcao_do_cliente(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ perror(char *);
int socket(int, int, int);
main() {
  int domain, type, protocol;
  int socketfd;
  int novo_socketfd;
  struct sockaddr_in end_local;
  struct sockaddr_in end_remoto;
  bzero(&end_remoto, sizeof(end_remoto));
  bzero(&end_local, sizeof(end_remoto));
  int tam_end_local;
  int tam_end_remoto;
  int resultado_do_fork;
  domain = AF_INET;
  type = SOCK_STREAM;
  protocol = 0;
  socketfd = socket(domain, type, protocol);
  if (socketfd == -1) {
    perror("Erro no socket\n");
    exit(1);
  }
  end_remoto.sin_family = AF_INET;
  end_remoto.sin_port = htons(30000);
  end_remoto.sin_addr.s_addr = inet_addr("192.168.134.128");
  tam_end_remoto = sizeof(end_remoto);
  if (connect(socketfd, (struct sockaddr *)&end_remoto, tam_end_remoto) == -1) {
    perror("Erro no connect\n");
    exit(1);
  }
  funcao_do_cliente(socketfd);
  close(socketfd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x38(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bzero@plt>
lea    -0x28(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bzero@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   10b0 <socket@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1205 <main+0x75>
lea    0xe0a(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    $0x7530,%edi
call   1040 <htons@plt>
mov    %eax,-0x34(%rbp)
lea    0xde9(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x38(%rbp)
movl   $0x10,-0x40(%rbp)
mov    -0x10(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%edx
call   10a0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1264 <main+0xd4>
lea    0xdcb(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%edi
call   1030 <funcao_do_cliente@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
mov    $0x10,%esi
call   1080 <bzero@plt>
mov    0x2e3b(%rip),%r14
mov    (%r14),%edi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
cmp    $0xffffffff,%eax
je     121b <main+0x8b>
mov    %eax,%ebx
mov    (%r14),%rax
mov    %rax,0x10(%rsp)
mov    $0x7530,%edi
call   1040 <htons@plt>
mov    %eax,0xc(%rsp)
lea    0xe2c(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10a0 <connect@plt>
cmp    $0xffffffff,%eax
je     1224 <main+0x94>
mov    %ebx,%edi
call   1030 <funcao_do_cliente@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xdde(%rip),%rdi
jmp    122b <main+0x9b>
lea    0xdf5(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"Erro no socket\0A\00"
@.str.1 = [16 x i8] c"192.168.134.128\00"
@.str.2 = [17 x i8] c"Erro no connect\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = call i32 @bzero(%struct.sockaddr_in* %7, i32 16)
%12 = call i32 @bzero(%struct.sockaddr_in* %6, i32 16)
%13 = load i8*, i8** @AF_INET
%14 = ptrtoint i8* %13 to i32
store i32 %14, i32* %1
%15 = load i32, i32* @SOCK_STREAM
store i32 %15, i32* %2
store i32 0, i32* %3
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i32 @socket(i32 %16, i32 %17, i32 %18)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %0
%23 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %0
%26 = load i8*, i8** @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %26, i8** %27
%28 = call i32 @htons(i32 30000)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i32 %28, i32* %29
%30 = call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
store i32 %30, i32* %32
store i32 16, i32* %9
%33 = load i32, i32* %4
%34 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%35 = load i32, i32* %9
%36 = call i32 @connect(i32 %33, %struct.sockaddr* %34, i32 %35)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %25
%39 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %25
%42 = load i32, i32* %4
%43 = call i32 @funcao_do_cliente(i32 %42)
%44 = load i32, i32* %4
%45 = call i32 @close(i32 %44)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str = [16 x i8] c"Erro no socket\0A\00"
@.str.1 = [16 x i8] c"192.168.134.128\00"
@.str.2 = [17 x i8] c"Erro no connect\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = bitcast %struct.sockaddr_in* %1 to i8*
%3 = call i32 @bzero(%struct.sockaddr_in* %1, i32 16)
%4 = load i8*, i8** @AF_INET
%5 = ptrtoint i8* %4 to i64
%6 = trunc i64 %5 to i32
%7 = load i32, i32* @SOCK_STREAM
%8 = tail call i32 @socket(i32 %6, i32 %7, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = load i8*, i8** @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i8* %14, i8** %15
%16 = tail call i32 @htons(i32 30000)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %16, i32* %17
%18 = tail call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %18, i32* %19
%20 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%21 = call i32 @connect(i32 %8, %struct.sockaddr* %20, i32 16)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %13
%24 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %13
%27 = call i32 @funcao_do_cliente(i32 %8)
%28 = call i32 @close(i32 %8)
ret i32 0
}