#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*/ uint16_t;
struct in_addr {
  int dummy;
};
struct sockaddr_in {
  struct in_addr sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
struct sockaddr_in init_server_descriptor(int port) {
  struct sockaddr_in addr;
  memset((char *)&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons((uint16_t)port);
  struct in_addr listen_ip;
  inet_aton("0.0.0.0", &listen_ip);
  addr.sin_addr = listen_ip;
  return addr;
}


x86 assembly (clang, -O0):
<init_server_descriptor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0xc(%rbp)
lea    0xe97(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <inet_aton@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%edx
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_server_descriptor>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %ebx,%edi
call   1030 <htons@plt>
mov    %eax,0x14(%rsp)
lea    0xe99(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <inet_aton@plt>
mov    0x8(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x10(%rsp),%rax
mov    0x18(%rsp),%edx
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.in_addr, i32, i32 }
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@.str = [8 x i8] c"0.0.0.0\00"
define { i64, i32 } @init_server_descriptor(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca %struct.in_addr
%5 = alloca { i64, i32 }
store i32 %0, i32* %3
%6 = bitcast %struct.sockaddr_in* %2 to i8*
%7 = call i32 @memset(i8* %6, i32 0, i32 12)
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i32 %8, i32* %9
%10 = load i32, i32* %3
%11 = call i32 @htons(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
store i32 %11, i32* %12
%13 = call i32 @inet_aton(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %4)
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%15 = bitcast %struct.in_addr* %14 to i8*
%16 = bitcast %struct.in_addr* %4 to i8*
%17 = bitcast { i64, i32 }* %5 to i8*
%18 = bitcast %struct.sockaddr_in* %2 to i8*
%19 = load { i64, i32 }, { i64, i32 }* %5
ret { i64, i32 } %19
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.in_addr, i32, i32 }
%struct.in_addr = type { i32 }
@AF_INET = global i32 0
@.str = [8 x i8] c"0.0.0.0\00"
define { i64, i32 } @init_server_descriptor(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.in_addr
%4 = bitcast %struct.sockaddr_in* %2 to i8*
%5 = call i32 @memset(i8* %4, i32 0, i32 12)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %6, i32* %7
%8 = call i32 @htons(i32 %0)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i32 %8, i32* %9
%10 = bitcast %struct.in_addr* %3 to i8*
%11 = call i32 @inet_aton(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %3)
%12 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i64 0, i32 0
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
%14 = load i32, i32* %12
store i32 %14, i32* %13
%15 = bitcast %struct.sockaddr_in* %2 to i64*
%16 = load i64, i64* %15
%17 = load i32, i32* %7
%18 = insertvalue { i64, i32 } poison, i64 %16, 0
%19 = insertvalue { i64, i32 } %18, i32 %17, 1
ret { i64, i32 } %19
}