#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_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ si_other;
typedef int /*<<< orphan*/ si_me;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ recvfrom(int, char *, int, int /*<<< orphan*/,
                            struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
void *server_recvfrom_thread(void *arg) {
  struct sockaddr_in si_me, si_other;
  int s;
  socklen_t slen = sizeof(si_other);
  char buf[512];
  s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  memset((char *)&si_me, 0, sizeof(si_me));
  si_me.sin_family = AF_INET;
  si_me.sin_port = htons(25588);
  si_me.sin_addr.s_addr = htonl(INADDR_ANY);
  bind(s, (struct sockaddr *)&si_me, sizeof(si_me));
  recvfrom(s, buf, 512, 0, (struct sockaddr *)&si_other, &slen);
  usleep(2000);
  return NULL;
}


x86 assembly (clang, -O0):
<server_recvfrom_thread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xc,-0x30(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
call   1090 <socket@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x63f4,%edi
call   1030 <htons@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x18(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   1070 <bind@plt>
mov    -0x2c(%rbp),%edi
lea    -0x230(%rbp),%rsi
lea    -0x28(%rbp),%r8
mov    $0x200,%edx
xor    %ecx,%ecx
lea    -0x30(%rbp),%r9
call   1060 <recvfrom@plt>
mov    $0x7d0,%edi
call   1080 <usleep@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<server_recvfrom_thread>:
push   %r15
push   %r14
push   %rbx
sub    $0x230,%rsp
movl   $0xc,0xc(%rsp)
mov    0x2e5d(%rip),%r15
mov    (%r15),%edi
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
mov    0x2e22(%rip),%rax
mov    (%rax),%edx
call   1090 <socket@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
mov    $0x63f4,%edi
call   1030 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1070 <bind@plt>
lea    0x30(%rsp),%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %ebx,%edi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1060 <recvfrom@plt>
mov    $0x7d0,%edi
call   1080 <usleep@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@INADDR_ANY = global i32 0
define noalias i8* @server_recvfrom_thread(i8* nocapture readnone %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [512 x i8]
%6 = bitcast %struct.sockaddr_in* %2 to i8*
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 12, i32* %4
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @AF_INET
%11 = load i32, i32* @SOCK_DGRAM
%12 = load i32, i32* @IPPROTO_UDP
%13 = tail call i32 @socket(i32 %10, i32 %11, i32 %12)
%14 = call i32 @memset(i8* %6, i32 0, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %15, i32* %16
%17 = call i32 @htons(i32 25588)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i32 %17, i32* %18
%19 = load i32, i32* @INADDR_ANY
%20 = call i32 @htonl(i32 %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
store i32 %20, i32* %21
%22 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%23 = call i32 @bind(i32 %13, %struct.sockaddr* %22, i32 12)
%24 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%25 = call i32 @recvfrom(i32 %13, i8* %9, i32 512, i32 0, %struct.sockaddr* %24, i32* %4)
%26 = call i32 @usleep(i32 2000)
ret i8* null
}