#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__ {
  void *s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ servaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
long INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
void *htons(long);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
long strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int reception(char *port) {
  int fd_socket;
  int fd_comm;
  long port_number = strtol(port, NULL, 0);
  struct sockaddr_in servaddr;
  fd_socket = socket(AF_INET, SOCK_STREAM, 0);
  memset(&servaddr, 0, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = htons(INADDR_ANY);
  servaddr.sin_port = htons(port_number);
  bind(fd_socket, (struct sockaddr *)&servaddr, sizeof(servaddr));
  listen(fd_socket, 10);
  fd_comm = accept(fd_socket, (struct sockaddr *)NULL, NULL);
  return fd_comm;
}


x86 assembly (clang, -O0):
<reception>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%rdi
call   1030 <htons@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1070 <bind@plt>
mov    -0xc(%rbp),%edi
mov    $0xa,%esi
call   1060 <listen@plt>
mov    -0xc(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1080 <accept@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reception>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %esi,%esi
xor    %edx,%edx
call   1050 <strtol@plt>
mov    %rax,%r14
mov    0x2e5a(%rip),%r12
mov    (%r12),%edi
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,%ebx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    (%r12),%eax
mov    %eax,0x10(%rsp)
mov    0x2e1b(%rip),%rax
mov    (%rax),%rdi
call   1030 <htons@plt>
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
call   1030 <htons@plt>
mov    %rax,(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x18,%edx
call   1070 <bind@plt>
mov    %ebx,%edi
mov    $0xa,%esi
call   1060 <listen@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <accept@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i64 0
define i32 @reception(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca %struct.sockaddr_in
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strtol(i8* %7, i32* null, i32 0)
store i64 %8, i64* %5
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = call i32 @socket(i32 %9, i32 %10, i32 0)
store i32 %11, i32* %3
%12 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 24)
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %13, i32* %14
%15 = load i64, i64* @INADDR_ANY
%16 = call i8* @htons(i64 %15)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
store i8* %16, i8** %18
%19 = load i64, i64* %5
%20 = call i8* @htons(i64 %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i8* %20, i8** %21
%22 = load i32, i32* %3
%23 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%24 = call i32 @bind(i32 %22, %struct.sockaddr* %23, i32 24)
%25 = load i32, i32* %3
%26 = call i32 @listen(i32 %25, i32 10)
%27 = load i32, i32* %3
%28 = call i32 @accept(i32 %27, %struct.sockaddr* null, i32* null)
store i32 %28, i32* %4
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@INADDR_ANY = global i64 0
define i32 @reception(i8* nocapture %0) {
%2 = alloca %struct.sockaddr_in
%3 = tail call i64 @strtol(i8* nocapture %0, i32* null, i32 0)
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 24)
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %9, i32* %10
%11 = load i64, i64* @INADDR_ANY
%12 = call i8* @htons(i64 %11)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
store i8* %12, i8** %13
%14 = call i8* @htons(i64 %3)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
store i8* %14, i8** %15
%16 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%17 = call i32 @bind(i32 %7, %struct.sockaddr* %16, i32 24)
%18 = call i32 @listen(i32 %7, i32 10)
%19 = call i32 @accept(i32 %7, %struct.sockaddr* null, i32* null)
ret i32 %19
}