#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 accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
creation_canal(int ma_socket, int *ta_socket, struct sockaddr_in *client) {
  int client_size = sizeof client;
  *ta_socket = accept(ma_socket, (struct sockaddr *)client, &client_size);
  if (*ta_socket < 0) {
    perror("change ta socket\n");
    exit(errno);
  }
}


x86 assembly (clang, -O0):
<creation_canal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x8,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <accept@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1189 <creation_canal+0x59>
lea    0xe8a(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<creation_canal>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movl   $0x8,0xc(%rsp)
lea    0xc(%rsp),%rax
mov    %rdx,%rsi
mov    %rax,%rdx
call   1040 <accept@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     115c <creation_canal+0x2c>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe9d(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [18 x i8] c"change ta socket\0A\00"
@errno = global i32 0
define i32 @creation_canal(i32 %0, i32* %1, %struct.sockaddr_in* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca %struct.sockaddr_in*
%8 = alloca i32
store i32 %0, i32* %5
store i32* %1, i32** %6
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %7
store i32 8, i32* %8
%9 = load i32, i32* %5
%10 = load %struct.sockaddr_in*, %struct.sockaddr_in** %7
%11 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%12 = call i32 @accept(i32 %9, %struct.sockaddr* %11, i32* %8)
%13 = load i32*, i32** %6
store i32 %12, i32* %13
%14 = load i32*, i32** %6
%15 = load i32, i32* %14
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @errno
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %3
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [18 x i8] c"change ta socket\0A\00"
@errno = global i32 0
define i32 @creation_canal(i32 %0, i32* nocapture writeonly %1, %struct.sockaddr_in* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 8, i32* %4
%6 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%7 = call i32 @accept(i32 %0, %struct.sockaddr* %6, i32* %4)
store i32 %7, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @errno
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %3
ret i32 undef
}