#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*/ time_t;
struct sockaddr_in {
  int sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, unsigned int *);
int bindedSocket(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int date(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                             int);
scalar_t__ listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  int listenfd, connfd;
  char cliIP[INET_ADDRSTRLEN];
  struct sockaddr_in clientaddr;
  unsigned int clen;
  char buff[80];
  int tdate;
  time_t ticks;
  listenfd = bindedSocket(0, argv[1], SOCK_STREAM);
  if (listenfd < 0) {
    perror("Dans bindedSocket");
    exit(1);
  }
  if (listen(listenfd, 5) < 0) {
    perror("listen");
    exit(2);
  }
  for (;;) {
    connfd = accept(listenfd, (struct sockaddr *)&clientaddr, &clen);
    if (connfd < 0) {
      perror("Erreur Dans accept ");
      exit(3);
    }
    inet_ntop(AF_INET, &(clientaddr.sin_addr), cliIP, INET_ADDRSTRLEN);
    printf("Le client est %s:%d \n", cliIP, clientaddr.sin_port);
    ticks = time(NULL);
    tdate = date(buff, sizeof(buff), &ticks);
    write(connfd, buff, tdate);
    close(connfd);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
xor    %edi,%edi
call   10d0 <bindedSocket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1233 <main+0x83>
lea    0xddc(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1090 <listen@plt>
cmp    $0x0,%rax
jge    1260 <main+0xb0>
lea    0xdc1(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
jmp    1265 <main+0xb5>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10b0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1298 <main+0xe8>
lea    0xd90(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x3,%edi
call   10c0 <exit@plt>
mov    -0xa0(%rbp),%rdx
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
mov    0x2d19(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    -0xa0(%rbp),%rsi
mov    -0x30(%rbp),%edx
lea    0xd5e(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x50,%esi
lea    -0x98(%rbp),%rdx
call   1070 <date@plt>
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    -0x94(%rbp),%edx
call   1040 <write@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
jmp    1265 <main+0xb5>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    0x2e08(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    0x8(%rsi),%rsi
mov    0x2df0(%rip),%rax
mov    (%rax),%edx
xor    %edi,%edi
call   10d0 <bindedSocket@plt>
test   %eax,%eax
jns    120b <main+0x5b>
lea    0xe04(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    %eax,%r14d
mov    %eax,%edi
mov    $0x5,%esi
call   1090 <listen@plt>
test   %rax,%rax
jns    1235 <main+0x85>
lea    0xdec(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    %r14d,%edi
call   10b0 <accept@plt>
test   %eax,%eax
js     12cf <main+0x11f>
mov    %eax,%ebx
lea    -0x90(%rbp),%r15
cs nopw 0x0(%rax,%rax,1)
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%ecx
lea    -0x2c(%rbp),%rsi
mov    %r13,%rdx
call   1030 <inet_ntop@plt>
mov    -0x30(%rbp),%edx
lea    0xdaa(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x34(%rbp)
mov    %r15,%rdi
mov    $0x50,%esi
lea    -0x34(%rbp),%rdx
call   1070 <date@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    %r14d,%edi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   10b0 <accept@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1260 <main+0xb0>
lea    0xd43(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x3,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@SOCK_STREAM = global i32 0
@.str = [18 x i8] c"Dans bindedSocket\00"
@.str.1 = [7 x i8] c"listen\00"
@.str.2 = [20 x i8] c"Erreur Dans accept \00"
@AF_INET = global i32 0
@.str.3 = [22 x i8] c"Le client est %s:%d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca [80 x i8]
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @INET_ADDRSTRLEN
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %8
%18 = alloca i8, i64 %16
store i64 %16, i64* %9
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @bindedSocket(i32 0, i8* %21, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* %6
%31 = call i64 @listen(i32 %30, i32 5)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 2)
unreachable
36: ; preds = %29
br label %37
37: ; preds = %46, %36
%38 = load i32, i32* %6
%39 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%40 = call i32 @accept(i32 %38, %struct.sockaddr* %39, i32* %11)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @exit(i32 3)
unreachable
46: ; preds = %37
%47 = load i32, i32* @AF_INET
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%49 = load i32, i32* @INET_ADDRSTRLEN
%50 = call i32 @inet_ntop(i32 %47, i32* %48, i8* %18, i32 %49)
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%52 = load i32, i32* %51
%53 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %18, i32 %52)
%54 = call i32 @time(i32* null)
store i32 %54, i32* %14
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%56 = call i32 @date(i8* %55, i32 80, i32* %14)
store i32 %56, i32* %13
%57 = load i32, i32* %7
%58 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%59 = load i32, i32* %13
%60 = call i32 @write(i32 %57, i8* %58, i32 %59)
%61 = load i32, i32* %7
%62 = call i32 @close(i32 %61)
br label %37
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@SOCK_STREAM = global i32 0
@.str = [18 x i8] c"Dans bindedSocket\00"
@.str.1 = [7 x i8] c"listen\00"
@.str.2 = [20 x i8] c"Erreur Dans accept \00"
@AF_INET = global i32 0
@.str.3 = [22 x i8] c"Le client est %s:%d \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca i32
%7 = load i32, i32* @INET_ADDRSTRLEN
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%13 = bitcast i32* %6 to i8*
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @bindedSocket(i32 0, i8* %15, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = tail call i64 @listen(i32 %17, i32 5)
%24 = icmp slt i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %22
%26 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%27 = call i32 @accept(i32 %17, %struct.sockaddr* %26, i32* %4)
%28 = icmp slt i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %25
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
br label %38
32: ; preds = %22
%33 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%34 = tail call i32 @exit(i32 2)
unreachable
35: ; preds = %38, %25
%36 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 3)
unreachable
38: ; preds = %29, %38
%39 = phi i32 [ %27, %29 ], [ %49, %38 ]
%40 = load i32, i32* @AF_INET
%41 = load i32, i32* @INET_ADDRSTRLEN
%42 = call i32 @inet_ntop(i32 %40, i32* %30, i8* %9, i32 %41)
%43 = load i32, i32* %31
%44 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %43)
%45 = call i32 @time(i32* null)
store i32 %45, i32* %6
%46 = call i32 @date(i8* %12, i32 80, i32* %6)
%47 = call i32 @write(i32 %39, i8* %12, i32 %46)
%48 = call i32 @close(i32 %39)
%49 = call i32 @accept(i32 %17, %struct.sockaddr* %26, i32* %4)
%50 = icmp slt i32 %49, 0
br i1 %50, label %35, label %38
}