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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int bind(int, struct sockaddr_in *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ net_recv_write(int, struct sockaddr_in *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void *net_thread(void *net_args) {
  int recv_soc;
  int recv_port = 13579;
  int stat;
  struct sockaddr_in recv_socaddr;
  fprintf(stderr, "Starting NET thread: %d\n", 94);
  memset(&recv_socaddr, 0, sizeof(struct sockaddr_in));
  recv_socaddr.sin_port = htons(recv_port);
  recv_socaddr.sin_family = AF_INET;
  recv_socaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  recv_soc = socket(AF_INET, SOCK_DGRAM, 0);
  stat = bind(recv_soc, (struct sockaddr_in *)&recv_socaddr,
              sizeof(struct sockaddr_in));
  net_recv_write(recv_soc, &recv_socaddr);
  return 0;
}


x86 assembly (clang, -O0):
<net_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x350b,-0x10(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
mov    $0x5e,%edx
call   1060 <fprintf@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1070 <bind@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1080 <net_recv_write@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<net_thread>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
mov    $0x5e,%edx
call   1060 <fprintf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    $0x350b,%edi
call   1030 <htons@plt>
mov    %eax,0x10(%rsp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,0xc(%rsp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x8(%rsp)
mov    0x2e00(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1070 <bind@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <net_recv_write@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [25 x i8] c"Starting NET thread: %d\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_DGRAM = global i32 0
define i8* @net_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
store i8* %0, i8** %2
store i32 13579, i32* %4
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 94)
%9 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 12)
%10 = load i32, i32* %4
%11 = call i32 @htons(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %11, i32* %12
%13 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i32 %13, i32* %14
%15 = load i32, i32* @INADDR_ANY
%16 = call i32 @htonl(i32 %15)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
store i32 %16, i32* %18
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_DGRAM
%21 = call i32 @socket(i32 %19, i32 %20, i32 0)
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 @bind(i32 %22, %struct.sockaddr_in* %6, i32 12)
store i32 %23, i32* %5
%24 = load i32, i32* %3
%25 = call i32 @net_recv_write(i32 %24, %struct.sockaddr_in* %6)
ret i8* null
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [25 x i8] c"Starting NET thread: %d\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_DGRAM = global i32 0
define noalias i8* @net_thread(i8* nocapture readnone %0) {
%2 = alloca %struct.sockaddr_in
%3 = bitcast %struct.sockaddr_in* %2 to i8*
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 94)
%6 = call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 12)
%7 = call i32 @htons(i32 13579)
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %7, i32* %8
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i32 %9, i32* %10
%11 = load i32, i32* @INADDR_ANY
%12 = call i32 @htonl(i32 %11)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
store i32 %12, i32* %13
%14 = load i32, i32* @SOCK_DGRAM
%15 = call i32 @socket(i32 %9, i32 %14, i32 0)
%16 = call i32 @bind(i32 %15, %struct.sockaddr_in* %2, i32 12)
%17 = call i32 @net_recv_write(i32 %15, %struct.sockaddr_in* %2)
ret i8* null
}