#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 */
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr const *, int);
struct sockaddr_in *creerSock(char *, char *, int /*<<< orphan*/, int *);
int /*<<< orphan*/ perror(char *);
int reads(int, char *, int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char **argv) {
  int sockfd;
  struct sockaddr_in *srvaddr;
  char buff[80];
  int slen;
  srvaddr = creerSock(argv[1], argv[2], SOCK_STREAM, &sockfd);
  if (connect(sockfd, (const struct sockaddr *)srvaddr, sizeof(*srvaddr)) < 0) {
    perror("Dasn connect ");
  }
  slen = reads(sockfd, buff, 80);
  write(0, buff, slen);
  close(sockfd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
call   1080 <creerSock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1070 <connect@plt>
cmp    $0x0,%rax
jge    11c6 <main+0x66>
lea    0xe3f(%rip),%rdi
call   1050 <perror@plt>
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x50,%edx
call   1060 <reads@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
mov    -0x74(%rbp),%edx
xor    %edi,%edi
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
call   1080 <creerSock@plt>
mov    0xc(%rsp),%edi
mov    %rax,%rsi
mov    $0x4,%edx
call   1070 <connect@plt>
test   %rax,%rax
js     11c9 <main+0x69>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x50,%edx
call   1060 <reads@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0xc(%rsp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret
lea    0xe30(%rip),%rdi
call   1050 <perror@plt>
jmp    1196 <main+0x36>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@SOCK_STREAM = global i32 0
@.str = [14 x i8] c"Dasn connect \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in*
%8 = alloca [80 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = load i32, i32* @SOCK_STREAM
%17 = call %struct.sockaddr_in* @creerSock(i8* %12, i8* %15, i32 %16, i32* %6)
store %struct.sockaddr_in* %17, %struct.sockaddr_in** %7
%18 = load i32, i32* %6
%19 = load %struct.sockaddr_in*, %struct.sockaddr_in** %7
%20 = bitcast %struct.sockaddr_in* %19 to %struct.sockaddr*
%21 = call i64 @connect(i32 %18, %struct.sockaddr* %20, i32 4)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %2
%24 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %2
%26 = load i32, i32* %6
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%28 = call i32 @reads(i32 %26, i8* %27, i32 80)
store i32 %28, i32* %9
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%30 = load i32, i32* %9
%31 = call i32 @write(i32 0, i8* %29, i32 %30)
%32 = load i32, i32* %6
%33 = call i32 @close(i32 %32)
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@SOCK_STREAM = global i32 0
@.str = [14 x i8] c"Dasn connect \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%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 = load i32, i32* @SOCK_STREAM
%12 = call %struct.sockaddr_in* @creerSock(i8* %8, i8* %10, i32 %11, i32* %3)
%13 = load i32, i32* %3
%14 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%15 = call i64 @connect(i32 %13, %struct.sockaddr* %14, i32 4)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %2
%20 = load i32, i32* %3
%21 = call i32 @reads(i32 %20, i8* %6, i32 80)
%22 = call i32 @write(i32 0, i8* %6, i32 %21)
%23 = load i32, i32* %3
%24 = call i32 @close(i32 %23)
ret i32 0
}