#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*/ szBuf;

/* Variables and functions */
int /*<<< orphan*/ CreateUdpSock(int *, int);
scalar_t__ RecvMsgByUdp(int, char *, int *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ printf(char *, int, char *);
int strlen(char *);
int main() {
  int nSock, nSize;
  char szBuf[256];
  CreateUdpSock(&nSock, 9999);
  nSize = sizeof(szBuf);
  while (RecvMsgByUdp(nSock, szBuf, &nSize) == 0) {
    printf("Recv UDP Data:[%d][%s]\n", strlen(szBuf), szBuf);
    nSize = sizeof(szBuf);
  }
  close(nSock);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
mov    $0x270f,%esi
call   1070 <CreateUdpSock@plt>
movl   $0x100,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <RecvMsgByUdp@plt>
cmp    $0x0,%rax
jne    11c1 <main+0x71>
lea    -0x110(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    -0x110(%rbp),%rdx
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
movl   $0x100,-0xc(%rbp)
jmp    1177 <main+0x27>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0xc(%rsp),%rdi
mov    $0x270f,%esi
call   1070 <CreateUdpSock@plt>
movl   $0x100,0x8(%rsp)
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <RecvMsgByUdp@plt>
test   %rax,%rax
jne    11d1 <main+0x81>
lea    0x10(%rsp),%rbx
lea    0xe69(%rip),%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
movl   $0x100,0x8(%rsp)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <RecvMsgByUdp@plt>
test   %rax,%rax
je     11a0 <main+0x50>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Recv UDP Data:[%d][%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [256 x i8]
store i32 0, i32* %1
%5 = call i32 @CreateUdpSock(i32* %2, i32 9999)
store i32 256, i32* %3
br label %6
6: ; preds = %11, %0
%7 = load i32, i32* %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = call i64 @RecvMsgByUdp(i32 %7, i8* %8, i32* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %14)
store i32 256, i32* %3
br label %6
16: ; preds = %6
%17 = load i32, i32* %2
%18 = call i32 @close(i32 %17)
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [24 x i8] c"Recv UDP Data:[%d][%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32 @CreateUdpSock(i32* %1, i32 9999)
store i32 256, i32* %2
%8 = load i32, i32* %1
%9 = call i64 @RecvMsgByUdp(i32 %8, i8* %6, i32* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %0, %11
%12 = call i32 @strlen(i8* %6)
%13 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %6)
store i32 256, i32* %2
%14 = load i32, i32* %1
%15 = call i64 @RecvMsgByUdp(i32 %14, i8* %6, i32* %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %11, label %17
17: ; preds = %11, %0
%18 = load i32, i32* %1
%19 = call i32 @close(i32 %18)
ret i32 0
}