#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 {
  void *sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ s_addr;
typedef int /*<<< orphan*/ c_addr;
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
void *htons(int);
char *inet_ntoa(TYPE_1__);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int ntohs(void *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct sockaddr_in s_addr;
  struct sockaddr_in c_addr;
  int sock;
  socklen_t addr_len;
  int len, wrLen;
  char buff[128] = {0};
  FILE *fp = NULL;
  if (argc != 2) {
    printf("Usage: ./udpReceive port \n");
    return -1;
  }
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
    perror("socket");
    exit(errno);
  } else
    printf("create socket.\n");
  memset(&s_addr, 0, sizeof(struct sockaddr_in));
  s_addr.sin_family = AF_INET;
  if (argv[1])
    s_addr.sin_port = htons(atoi(argv[1]));
  else
    s_addr.sin_port = htons(1234);
  s_addr.sin_addr.s_addr = INADDR_ANY;
  if ((bind(sock, (struct sockaddr *)&s_addr, sizeof(s_addr))) == -1) {
    perror("bind");
    exit(errno);
  } else
    printf("bind address to socket.\n");
  fp = fopen("udp.ts", "a+");
  if (!fp) {
    printf("Open udp.ts failed.\n");
  }
  addr_len = sizeof(c_addr);
  while (1) {
    len = recvfrom(sock, buff, sizeof(buff) - 1, 0, (struct sockaddr *)&c_addr,
                   &addr_len);
    if (len < 0) {
      perror("recvfrom");
      exit(errno);
    }
    wrLen = fwrite(buff, 1, 128, fp);
    if (wrLen != 128)
      printf("Write length is wrong.\n");
    fflush(fp);
    printf("Received from %s:%d的消息:%s,len = %d\n",
           inet_ntoa(c_addr.sin_addr), ntohs(c_addr.sin_port), buff, wrLen);
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
movq   $0x0,-0xc8(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     123d <main+0x5d>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0xd0,%rsp
pop    %rbp
ret
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    127c <main+0x9c>
lea    0xdb2(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     12d2 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %rax,-0x20(%rbp)
jmp    12e0 <main+0x100>
mov    $0x4d2,%edi
call   1040 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    0x2cf9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1320 <main+0x140>
lea    0xd25(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd1b(%rip),%rdi
lea    0xd1b(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jne    1364 <main+0x184>
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x10,-0x38(%rbp)
mov    -0x34(%rbp),%edi
lea    -0xc0(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x7f,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r9
call   1080 <recvfrom@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    13b0 <main+0x1d0>
lea    0xcd2(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c1f(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    -0xc0(%rbp),%rdi
mov    -0xc8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x80,%edx
call   10f0 <fwrite@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x80,-0x40(%rbp)
je     13eb <main+0x20b>
lea    0xc94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc8(%rbp),%rdi
call   1070 <fflush@plt>
mov    -0x28(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0xd0(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <ntohs@plt>
mov    -0xd0(%rbp),%rsi
mov    %eax,%edx
lea    -0xc0(%rbp),%rcx
mov    -0x40(%rbp),%r8d
lea    0xc66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    136b <main+0x18b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
cmp    $0x2,%edi
je     125d <main+0x6d>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
mov    0x2d81(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,0x8(%rsp)
cmp    $0xffffffff,%eax
jne    128f <main+0x9f>
lea    0xd76(%rip),%rdi
jmp    1368 <main+0x178>
lea    0xdb3(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x1c(%rsp)
mov    0x8(%rbx),%rax
mov    $0x4d2,%edi
test   %rax,%rax
je     12cb <main+0xdb>
mov    %rax,%rdi
call   10e0 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %rax,0x10(%rsp)
mov    0x2d04(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%edi
mov    $0x10,%edx
call   10b0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1303 <main+0x113>
lea    0xd06(%rip),%rdi
jmp    1368 <main+0x178>
lea    0xd4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xcf6(%rip),%rdi
lea    0xcf6(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1336 <main+0x146>
lea    0xd3f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x10,0xc(%rsp)
lea    0x30(%rsp),%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    0x8(%rsp),%edi
mov    $0x7f,%edx
xor    %ecx,%ecx
call   1090 <recvfrom@plt>
test   %eax,%eax
jns    137b <main+0x18b>
lea    0xcae(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2c54(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0x30(%rsp),%rbp
lea    0x20(%rsp),%r12
lea    0xc(%rsp),%r13
jmp    13e0 <main+0x1f0>
mov    %rbx,%rdi
call   1080 <fflush@plt>
mov    0x28(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%r15
mov    0x20(%rsp),%rdi
call   10a0 <ntohs@plt>
lea    0xc6e(%rip),%rdi
mov    %r15,%rsi
mov    %eax,%edx
mov    %rbp,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%edi
mov    %rbp,%rsi
mov    $0x7f,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   1090 <recvfrom@plt>
test   %eax,%eax
js     1361 <main+0x171>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x80,%edx
mov    %rbx,%rcx
call   1100 <fwrite@plt>
mov    %eax,%r14d
cmp    $0x80,%eax
je     138c <main+0x19c>
lea    0xc7e(%rip),%rdi
call   1030 <puts@plt>
jmp    138c <main+0x19c>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [27 x i8] c"Usage: ./udpReceive port \0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@errno = global i32 0
@.str.2 = [16 x i8] c"create socket.\0A\00"
@INADDR_ANY = global i32 0
@.str.3 = [5 x i8] c"bind\00"
@.str.4 = [25 x i8] c"bind address to socket.\0A\00"
@.str.5 = [7 x i8] c"udp.ts\00"
@.str.6 = [3 x i8] c"a+\00"
@.str.7 = [21 x i8] c"Open udp.ts failed.\0A\00"
@.str.8 = [9 x i8] c"recvfrom\00"
@.str.9 = [24 x i8] c"Write length is wrong.\0A\00"
@.str.10 = [42 x i8] c"Received from %s:%d\E7\9A\84\E6\B6\88\E6\81\AF:%s,len = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [128 x i8]
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [128 x i8]* %12 to i8*
store i32* null, i32** %13
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
ret i32 -1
19: ; preds = %2
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_DGRAM
%22 = call i32 @socket(i32 %20, i32 %21, i32 0)
store i32 %22, i32* %8
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* @errno
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %19
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 16)
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %32, i32* %33
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %45
38: ; preds = %30
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
%43 = call i8* @htons(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i8* %43, i8** %44
br label %48
45: ; preds = %30
%46 = call i8* @htons(i32 1234)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i8* %46, i8** %47
br label %48
48: ; preds = %45, %38
%49 = load i32, i32* @INADDR_ANY
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %50, i32 0, i32 0
store i32 %49, i32* %51
%52 = load i32, i32* %8
%53 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%54 = call i32 @bind(i32 %52, %struct.sockaddr* %53, i32 16)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %60
56: ; preds = %48
%57 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%58 = load i32, i32* @errno
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %48
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60
%63 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %63, i32** %13
%64 = load i32*, i32** %13
%65 = icmp ne i32* %64, null
br i1 %65, label %68, label %66
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %68
68: ; preds = %66, %62
store i32 16, i32* %9
br label %69
69: ; preds = %68, %88
%70 = load i32, i32* %8
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%72 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%73 = call i32 @recvfrom(i32 %70, i8* %71, i32 127, i32 0, %struct.sockaddr* %72, i32* %9)
store i32 %73, i32* %10
%74 = load i32, i32* %10
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %69
%77 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%78 = load i32, i32* @errno
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %69
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%82 = load i32*, i32** %13
%83 = call i32 @fwrite(i8* %81, i32 1, i32 128, i32* %82)
store i32 %83, i32* %11
%84 = load i32, i32* %11
%85 = icmp ne i32 %84, 128
br i1 %85, label %86, label %88
86: ; preds = %80
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %88
88: ; preds = %86, %80
%89 = load i32*, i32** %13
%90 = call i32 @fflush(i32* %89)
%91 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%92 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %91, i32 0, i32 0
%93 = load i32, i32* %92
%94 = call i8* @inet_ntoa(i32 %93)
%95 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%96 = load i8*, i8** %95
%97 = call i32 @ntohs(i8* %96)
%98 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%99 = load i32, i32* %11
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i8* %94, i32 %97, i8* %98, i32 %99)
br label %69
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@errno = global i32 0
@INADDR_ANY = global i32 0
@.str.3 = [5 x i8] c"bind\00"
@.str.5 = [7 x i8] c"udp.ts\00"
@.str.6 = [3 x i8] c"a+\00"
@.str.8 = [9 x i8] c"recvfrom\00"
@.str.10 = [42 x i8] c"Received from %s:%d\E7\9A\84\E6\B6\88\E6\81\AF:%s,len = %d\0A\00"
@str = [15 x i8] c"create socket.\00"
@str.11 = [24 x i8] c"bind address to socket.\00"
@str.12 = [20 x i8] c"Open udp.ts failed.\00"
@str.13 = [23 x i8] c"Write length is wrong.\00"
@str.14 = [26 x i8] c"Usage: ./udpReceive port \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [128 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = icmp eq i32 %0, 2
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.14, i64 0, i64 0))
ret i32 -1
14: ; preds = %2
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_DGRAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @errno
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %14
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%25 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 16)
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %26, i32* %27
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %33, label %31
31: ; preds = %23
%32 = call i32 @atoi(i8* %29)
br label %33
33: ; preds = %23, %31
%34 = phi i32 [ %32, %31 ], [ 1234, %23 ]
%35 = call i8* @htons(i32 %34)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i8* %35, i8** %36
%37 = load i32, i32* @INADDR_ANY
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %37, i32* %38
%39 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%40 = call i32 @bind(i32 %17, %struct.sockaddr* %39, i32 16)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %46
42: ; preds = %33
%43 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* @errno
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %33
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%48 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
store i32 16, i32* %5
%53 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%54 = call i32 @recvfrom(i32 %17, i8* %10, i32 127, i32 0, %struct.sockaddr* %53, i32* %5)
%55 = icmp slt i32 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %52
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
br label %63
59: ; preds = %68, %52
%60 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%61 = load i32, i32* @errno
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %56, %68
%64 = call i32 @fwrite(i8* %10, i32 1, i32 128, i32* %48)
%65 = icmp eq i32 %64, 128
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
br label %68
68: ; preds = %66, %63
%69 = call i32 @fflush(i32* %48)
%70 = load i32, i32* %57
%71 = call i8* @inet_ntoa(i32 %70)
%72 = load i8*, i8** %58
%73 = call i32 @ntohs(i8* %72)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i8* %71, i32 %73, i8* %10, i32 %64)
%75 = call i32 @recvfrom(i32 %17, i8* %10, i32 127, i32 0, %struct.sockaddr* %53, i32* %5)
%76 = icmp slt i32 %75, 0
br i1 %76, label %59, label %63
}