#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*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ close(int);
int date(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                             int);
int /*<<< orphan*/ 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, SOCK_STREAM, 2013);
  if (listenfd < 0) {
    perror("Dans bindedSocket");
    exit(1);
  }
  listen(listenfd, 5);
  for (;;) {
    connfd = accept(listenfd, (struct sockaddr *)&clientaddr, &clen);
    if (connfd < 0) {
      perror("Erreur Dans accept ");
      exit(-2);
    }
    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    0x2dd9(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    $0x7dd,%edx
call   10d0 <bindedSocket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1230 <main+0x80>
lea    0xddf(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1090 <listen@plt>
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    1270 <main+0xc0>
lea    0xdb1(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xfffffffe,%edi
call   10c0 <exit@plt>
mov    -0xa0(%rbp),%rdx
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
mov    0x2d41(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    -0xa0(%rbp),%rsi
mov    -0x30(%rbp),%edx
lea    0xd7f(%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    123d <main+0x8d>

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    0x2df4(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
mov    $0x7dd,%edx
call   10d0 <bindedSocket@plt>
test   %eax,%eax
jns    120c <main+0x5c>
lea    0xe03(%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>
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    %r14d,%edi
call   10b0 <accept@plt>
test   %eax,%eax
js     12af <main+0xff>
mov    %eax,%ebx
lea    -0x90(%rbp),%r15
nopl   0x0(%rax)
mov    0x2da1(%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    0xdc3(%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    1240 <main+0x90>
lea    0xd5c(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xfffffffe,%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 = [20 x i8] c"Erreur Dans accept \00"
@AF_INET = global i32 0
@.str.2 = [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 i32, i32* @SOCK_STREAM
%20 = call i32 @bindedSocket(i32 0, i32 %19, i32 2013)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i32, i32* %6
%28 = call i32 @listen(i32 %27, i32 5)
br label %29
29: ; preds = %38, %26
%30 = load i32, i32* %6
%31 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%32 = call i32 @accept(i32 %30, %struct.sockaddr* %31, i32* %11)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 -2)
unreachable
38: ; preds = %29
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%41 = load i32, i32* @INET_ADDRSTRLEN
%42 = call i32 @inet_ntop(i32 %39, i32* %40, i8* %18, i32 %41)
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%44 = load i32, i32* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32 %44)
%46 = call i32 @time(i32* null)
store i32 %46, i32* %14
%47 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%48 = call i32 @date(i8* %47, i32 80, i32* %14)
store i32 %48, i32* %13
%49 = load i32, i32* %7
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %12, i64 0, i64 0
%51 = load i32, i32* %13
%52 = call i32 @write(i32 %49, i8* %50, i32 %51)
%53 = load i32, i32* %7
%54 = call i32 @close(i32 %53)
br label %29
}

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