#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 /*<<< orphan*/ seraddr;
typedef int /*<<< orphan*/ cliaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ do_ser(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct sockaddr_in cliaddr, seraddr;
  int udpfd;
  udpfd = socket(AF_INET, SOCK_DGRAM, 0);
  bzero(&cliaddr, sizeof(cliaddr));
  bzero(&seraddr, sizeof(seraddr));
  seraddr.sin_family = AF_INET;
  seraddr.sin_port = htons(atoi(argv[1]));
  seraddr.sin_addr.s_addr = htonl(INADDR_ANY);
  bind(udpfd, (struct sockaddr *)&seraddr, sizeof(seraddr));
  fprintf(stderr, "blocking in recvfrom\n");
  do_ser(udpfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x34(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xc,%esi
call   1070 <bzero@plt>
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   1070 <bzero@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   1060 <bind@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1080 <do_ser@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r15
mov    0x2e51(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1070 <bzero@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0xc,%esi
call   1070 <bzero@plt>
mov    0x0(%r13),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%r15),%rdi
call   1090 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,(%rsp)
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0xc,%edx
call   1060 <bind@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
call   1050 <fprintf@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1080 <do_ser@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
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
@INADDR_ANY = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"blocking in recvfrom\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* @AF_INET
%9 = load i32, i32* @SOCK_DGRAM
%10 = call i32 @socket(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %7
%11 = call i32 @bzero(%struct.sockaddr_in* %5, i32 12)
%12 = call i32 @bzero(%struct.sockaddr_in* %6, i32 12)
%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 i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = call i32 @htons(i32 %18)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i32 %19, i32* %20
%21 = load i32, i32* @INADDR_ANY
%22 = call i32 @htonl(i32 %21)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = load i32, i32* %7
%26 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%27 = call i32 @bind(i32 %25, %struct.sockaddr* %26, i32 12)
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* %7
%31 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%32 = call i32 @do_ser(i32 %30, %struct.sockaddr* %31, i32 12)
ret i32 0
}

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
@INADDR_ANY = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"blocking in recvfrom\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_DGRAM
%9 = tail call i32 @socket(i32 %7, i32 %8, i32 0)
%10 = call i32 @bzero(%struct.sockaddr_in* %3, i32 12)
%11 = call i32 @bzero(%struct.sockaddr_in* %4, i32 12)
%12 = load i32, i32* @AF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %12, i32* %13
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = tail call i32 @htons(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %17, i32* %18
%19 = load i32, i32* @INADDR_ANY
%20 = tail call i32 @htonl(i32 %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %20, i32* %21
%22 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%23 = call i32 @bind(i32 %9, %struct.sockaddr* %22, i32 12)
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%26 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%27 = call i32 @do_ser(i32 %9, %struct.sockaddr* %26, i32 12)
ret i32 0
}