#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 /*<<< 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 init(char *port) {
  int fd_socket;
  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);
  return fd_socket;
}


x86 assembly (clang, -O0):
<init>:
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    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e22(%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),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init>:
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    0x2e6a(%rip),%r12
mov    (%r12),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <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    0x2e2b(%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,%eax
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 @init(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i64
%5 = alloca %struct.sockaddr_in
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strtol(i8* %6, i32* null, i32 0)
store i64 %7, i64* %4
%8 = load i32, i32* @AF_INET
%9 = load i32, i32* @SOCK_STREAM
%10 = call i32 @socket(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %3
%11 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 24)
%12 = load i32, i32* @AF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %12, i32* %13
%14 = load i64, i64* @INADDR_ANY
%15 = call i8* @htons(i64 %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
store i8* %15, i8** %17
%18 = load i64, i64* %4
%19 = call i8* @htons(i64 %18)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i8* %19, i8** %20
%21 = load i32, i32* %3
%22 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%23 = call i32 @bind(i32 %21, %struct.sockaddr* %22, i32 24)
%24 = load i32, i32* %3
%25 = call i32 @listen(i32 %24, i32 10)
%26 = load i32, i32* %3
ret i32 %26
}

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 @init(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)
ret i32 %7
}