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

/* Variables and functions */
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, unsigned int *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ record(char const *, unsigned int);
int recvfrom(int, void *, int, int /*<<< orphan*/, struct sockaddr *,
             int /*<<< orphan*/ *);
int sendto(int, void *, int, int /*<<< orphan*/, struct sockaddr *,
           int /*<<< orphan*/);
int snprintf(char *, int, char *, unsigned int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("usage: %s <hiscore-path> [<port=%d>]\n", argv[0], 31559);
    return 1;
  }
  const char *filename = argv[1];
  int port = argc < 3 ? 31559 : atoi(argv[2]);
  unsigned int hiscore = 0;
  FILE *fp = fopen(filename, "r");
  if (fp != NULL) {
    fscanf(fp, "%u", &hiscore);
    fclose(fp);
  } else {
    fprintf(stderr, "reading '%s': %s\n", filename, strerror(errno));
    if (record(filename, hiscore))
      return 1;
  }
  int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  struct sockaddr_in local;
  local.sin_addr.s_addr = INADDR_ANY;
  local.sin_port = htons(port);
  if (bind(sock, (struct sockaddr *)&local, sizeof(struct sockaddr)) < 0) {
    perror("bind");
    return 1;
  }
  for (;;) {
    struct sockaddr_in remote;
    socklen_t remote_len;
    char buf[16];
    int size = recvfrom(sock, (void *)buf, sizeof(buf) - 1, 0,
                        (struct sockaddr *)&remote, &remote_len);
    if (size < 0)
      perror("recvfrom");
    else if (size > 0 && size < sizeof(buf)) {
      buf[size] = '\0';
      int score = strtoul(buf, NULL, 10);
      if (score > hiscore) {
        hiscore = score;
        if (record(filename, hiscore))
          return 1;
      }
      size = snprintf(buf, sizeof(buf), "%u\n", hiscore);
      if (size < 0) {
        perror("snprintf");
      } else if (size >= sizeof(buf)) {
        fprintf(stderr, "message size (%d) too small to write hiscore %u\n",
                sizeof(buf), hiscore);
      } else {
        size = sendto(sock, (void *)buf, sizeof(buf), 0,
                      (struct sockaddr *)&remote, remote_len);
        if (size < 0)
          perror("sendto");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1247 <main+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x7b47,%edx
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f8 <main+0x2f8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    126a <main+0x6a>
mov    $0x7b47,%eax
mov    %eax,-0x6c(%rbp)
jmp    127a <main+0x7a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd94(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12c8 <main+0xc8>
mov    -0x28(%rbp),%rdi
lea    0xd77(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1080 <fscanf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1329 <main+0x129>
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    %rax,%rcx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <record@plt>
cmp    $0x0,%rax
je     1324 <main+0x124>
movl   $0x1,-0x4(%rbp)
jmp    14f8 <main+0x2f8>
jmp    1329 <main+0x129>
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
mov    0x2ca7(%rip),%rax
mov    (%rax),%esi
mov    0x2c6e(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2c95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    1396 <main+0x196>
lea    0xcb8(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f8 <main+0x2f8>
jmp    139b <main+0x19b>
mov    -0x2c(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%r8
mov    $0xf,%edx
xor    %ecx,%ecx
lea    -0x44(%rbp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    13d4 <main+0x1d4>
lea    0xc78(%rip),%rdi
call   10e0 <perror@plt>
jmp    14f3 <main+0x2f3>
cmpl   $0x0,-0x64(%rbp)
jle    14ee <main+0x2ee>
movslq -0x64(%rbp),%rax
cmp    $0x10,%rax
jae    14ee <main+0x2ee>
movslq -0x64(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x20(%rbp),%eax
jbe    1443 <main+0x243>
mov    -0x68(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1030 <record@plt>
cmp    $0x0,%rax
je     143e <main+0x23e>
movl   $0x1,-0x4(%rbp)
jmp    14f8 <main+0x2f8>
jmp    1443 <main+0x243>
lea    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    $0x10,%esi
lea    0xc2b(%rip),%rdx
call   1070 <snprintf@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    1479 <main+0x279>
lea    0xbdc(%rip),%rdi
call   10e0 <perror@plt>
jmp    14e9 <main+0x2e9>
movslq -0x64(%rbp),%rax
cmp    $0x10,%rax
jb     14ab <main+0x2ab>
mov    0x2b42(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%ecx
lea    0xbba(%rip),%rsi
mov    $0x10,%edx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    14e4 <main+0x2e4>
mov    -0x2c(%rbp),%edi
lea    -0x60(%rbp),%rsi
lea    -0x40(%rbp),%r8
mov    -0x44(%rbp),%r9d
mov    $0x10,%edx
xor    %ecx,%ecx
call   1090 <sendto@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    14df <main+0x2df>
lea    0xbab(%rip),%rdi
call   10e0 <perror@plt>
jmp    14e4 <main+0x2e4>
jmp    14e9 <main+0x2e9>
jmp    14ee <main+0x2ee>
jmp    14f3 <main+0x2f3>
jmp    139b <main+0x19b>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jg     123b <main+0x3b>
mov    (%rsi),%rsi
lea    0xde3(%rip),%rdi
mov    $0x7b47,%edx
call   1060 <printf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsi),%r14
mov    $0x7b47,%ebx
cmp    $0x2,%edi
je     1254 <main+0x54>
mov    0x10(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%ebx
movl   $0x0,(%rsp)
lea    0xdc4(%rip),%rsi
mov    %r14,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     13ed <main+0x1ed>
mov    %rax,%rbp
lea    0xdab(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1080 <fscanf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
mov    0x2d07(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,%ebp
mov    0x2d2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    %ebx,%edi
call   1050 <htons@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   10c0 <bind@plt>
test   %rax,%rax
js     1432 <main+0x232>
lea    0x10(%rsp),%rbx
lea    0x20(%rsp),%r15
lea    0x4(%rsp),%r12
lea    0xd87(%rip),%r13
jmp    131f <main+0x11f>
nopl   0x0(%rax)
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%ecx
mov    $0x10,%edx
lea    0xd3c(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xf,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r12,%r9
call   10b0 <recvfrom@plt>
test   %eax,%eax
js     13cb <main+0x1cb>
lea    -0x1(%rax),%ecx
cmp    $0xe,%ecx
ja     131f <main+0x11f>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10f0 <strtoul@plt>
mov    (%rsp),%ecx
cmp    %ecx,%eax
jbe    137c <main+0x17c>
mov    %eax,(%rsp)
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <record@plt>
test   %rax,%rax
jne    1227 <main+0x27>
mov    (%rsp),%ecx
mov    %rbx,%rdi
mov    $0x10,%esi
mov    %r13,%rdx
call   1070 <snprintf@plt>
test   %eax,%eax
js     13dc <main+0x1dc>
cmp    $0x10,%eax
jae    1300 <main+0x100>
mov    0x4(%rsp),%r9d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
mov    %r15,%r8
call   1090 <sendto@plt>
test   %eax,%eax
jns    131f <main+0x11f>
lea    0xcc4(%rip),%rdi
call   10e0 <perror@plt>
jmp    131f <main+0x11f>
lea    0xc70(%rip),%rdi
call   10e0 <perror@plt>
jmp    131f <main+0x11f>
lea    0xc68(%rip),%rdi
call   10e0 <perror@plt>
jmp    131f <main+0x11f>
mov    0x2bdc(%rip),%rax
mov    (%rax),%ebp
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc20(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <record@plt>
test   %rax,%rax
jne    1227 <main+0x27>
jmp    1290 <main+0x90>
lea    0xc04(%rip),%rdi
call   10e0 <perror@plt>
jmp    1227 <main+0x27>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [38 x i8] c"usage: %s <hiscore-path> [<port=%d>]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%u\00"
@stderr = global i32 0
@.str.3 = [18 x i8] c"reading '%s': %s\0A\00"
@errno = global i32 0
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@INADDR_ANY = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [9 x i8] c"recvfrom\00"
@.str.6 = [4 x i8] c"%u\0A\00"
@.str.7 = [9 x i8] c"snprintf\00"
@.str.8 = [49 x i8] c"message size (%d) too small to write hiscore %u\0A\00"
@.str.9 = [7 x i8] c"sendto\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca [16 x i8]
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %22, i32 31559)
store i32 1, i32* %3
br label %141
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %6
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 3
br i1 %29, label %30, label %31
30: ; preds = %24
br label %36
31: ; preds = %24
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
br label %36
36: ; preds = %31, %30
%37 = phi i32 [ 31559, %30 ], [ %35, %31 ]
store i32 %37, i32* %7
store i32 0, i32* %8
%38 = load i8*, i8** %6
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %9
%40 = load i32*, i32** %9
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %47
42: ; preds = %36
%43 = load i32*, i32** %9
%44 = call i32 @fscanf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%45 = load i32*, i32** %9
%46 = call i32 @fclose(i32* %45)
br label %59
47: ; preds = %36
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %6
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %49, i8* %51)
%53 = load i8*, i8** %6
%54 = load i32, i32* %8
%55 = call i64 @record(i8* %53, i32 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %47
store i32 1, i32* %3
br label %141
58: ; preds = %47
br label %59
59: ; preds = %58, %42
%60 = load i32, i32* @PF_INET
%61 = load i32, i32* @SOCK_DGRAM
%62 = load i32, i32* @IPPROTO_UDP
%63 = call i32 @socket(i32 %60, i32 %61, i32 %62)
store i32 %63, i32* %10
%64 = load i32, i32* @INADDR_ANY
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%66 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %65, i32 0, i32 0
store i32 %64, i32* %66
%67 = load i32, i32* %7
%68 = call i32 @htons(i32 %67)
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %68, i32* %69
%70 = load i32, i32* %10
%71 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%72 = call i64 @bind(i32 %70, %struct.sockaddr* %71, i32 4)
%73 = icmp slt i64 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %59
%75 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %141
76: ; preds = %59
br label %77
77: ; preds = %140, %76
%78 = load i32, i32* %10
%79 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%80 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%81 = call i32 @recvfrom(i32 %78, i8* %79, i32 15, i32 0, %struct.sockaddr* %80, i32* %13)
store i32 %81, i32* %15
%82 = load i32, i32* %15
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %77
%85 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %140
86: ; preds = %77
%87 = load i32, i32* %15
%88 = icmp sgt i32 %87, 0
br i1 %88, label %89, label %139
89: ; preds = %86
%90 = load i32, i32* %15
%91 = sext i32 %90 to i64
%92 = icmp ult i64 %91, 16
br i1 %92, label %93, label %139
93: ; preds = %89
%94 = load i32, i32* %15
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 %95
store i8 0, i8* %96
%97 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%98 = call i32 @strtoul(i8* %97, i32* null, i32 10)
store i32 %98, i32* %16
%99 = load i32, i32* %16
%100 = load i32, i32* %8
%101 = icmp ugt i32 %99, %100
br i1 %101, label %102, label %110
102: ; preds = %93
%103 = load i32, i32* %16
store i32 %103, i32* %8
%104 = load i8*, i8** %6
%105 = load i32, i32* %8
%106 = call i64 @record(i8* %104, i32 %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %102
store i32 1, i32* %3
br label %141
109: ; preds = %102
br label %110
110: ; preds = %109, %93
%111 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%112 = load i32, i32* %8
%113 = call i32 @snprintf(i8* %111, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %112)
store i32 %113, i32* %15
%114 = load i32, i32* %15
%115 = icmp slt i32 %114, 0
br i1 %115, label %116, label %118
116: ; preds = %110
%117 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %138
118: ; preds = %110
%119 = load i32, i32* %15
%120 = sext i32 %119 to i64
%121 = icmp uge i64 %120, 16
br i1 %121, label %122, label %126
122: ; preds = %118
%123 = load i32, i32* @stderr
%124 = load i32, i32* %8
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i64 16, i32 %124)
br label %137
126: ; preds = %118
%127 = load i32, i32* %10
%128 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 0
%129 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%130 = load i32, i32* %13
%131 = call i32 @sendto(i32 %127, i8* %128, i32 16, i32 0, %struct.sockaddr* %129, i32 %130)
store i32 %131, i32* %15
%132 = load i32, i32* %15
%133 = icmp slt i32 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %126
%135 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %136
136: ; preds = %134, %126
br label %137
137: ; preds = %136, %122
br label %138
138: ; preds = %137, %116
br label %139
139: ; preds = %138, %89, %86
br label %140
140: ; preds = %139, %84
br label %77
141: ; preds = %108, %74, %57, %19
%142 = load i32, i32* %3
ret i32 %142
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [38 x i8] c"usage: %s <hiscore-path> [<port=%d>]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%u\00"
@stderr = global i32 0
@.str.3 = [18 x i8] c"reading '%s': %s\0A\00"
@errno = global i32 0
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@INADDR_ANY = global i32 0
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [9 x i8] c"recvfrom\00"
@.str.6 = [4 x i8] c"%u\0A\00"
@.str.7 = [9 x i8] c"snprintf\00"
@.str.8 = [49 x i8] c"message size (%d) too small to write hiscore %u\0A\00"
@.str.9 = [7 x i8] c"sendto\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca [16 x i8]
%8 = icmp slt i32 %0, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %10, i32 31559)
br label %96
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = icmp eq i32 %0, 2
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
br label %20
20: ; preds = %12, %16
%21 = phi i32 [ %19, %16 ], [ 31559, %12 ]
%22 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%23 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = call i32 @fscanf(i32* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%27 = call i32 @fclose(i32* %23)
br label %35
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = load i32, i32* @errno
%31 = tail call i8* @strerror(i32 %30)
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %14, i8* %31)
%33 = tail call i64 @record(i8* %14, i32 0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %95
35: ; preds = %28, %25
%36 = load i32, i32* @PF_INET
%37 = load i32, i32* @SOCK_DGRAM
%38 = load i32, i32* @IPPROTO_UDP
%39 = call i32 @socket(i32 %36, i32 %37, i32 %38)
%40 = bitcast %struct.sockaddr_in* %4 to i8*
%41 = load i32, i32* @INADDR_ANY
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %41, i32* %42
%43 = call i32 @htons(i32 %21)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %43, i32* %44
%45 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%46 = call i64 @bind(i32 %39, %struct.sockaddr* %45, i32 4)
%47 = icmp slt i64 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %35
%49 = bitcast %struct.sockaddr_in* %5 to i8*
%50 = bitcast i32* %6 to i8*
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%52 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
br label %55
53: ; preds = %35
%54 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %94
55: ; preds = %48, %93
%56 = call i32 @recvfrom(i32 %39, i8* %51, i32 15, i32 0, %struct.sockaddr* %52, i32* %6)
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %93
60: ; preds = %55
%61 = add nsw i32 %56, -1
%62 = icmp ult i32 %61, 15
br i1 %62, label %63, label %93
63: ; preds = %60
%64 = zext i32 %56 to i64
%65 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %64
store i8 0, i8* %65
%66 = call i32 @strtoul(i8* nocapture %51, i32* null, i32 10)
%67 = load i32, i32* %3
%68 = icmp ugt i32 %66, %67
br i1 %68, label %69, label %75
69: ; preds = %63
store i32 %66, i32* %3
%70 = call i64 @record(i8* %14, i32 %66)
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = load i32, i32* %3
br label %75
74: ; preds = %69
br label %94
75: ; preds = %72, %63
%76 = phi i32 [ %73, %72 ], [ %67, %63 ]
%77 = call i32 @snprintf(i8* %51, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %76)
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %93
81: ; preds = %75
%82 = icmp ugt i32 %77, 15
br i1 %82, label %83, label %87
83: ; preds = %81
%84 = load i32, i32* @stderr
%85 = load i32, i32* %3
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i64 16, i32 %85)
br label %93
87: ; preds = %81
%88 = load i32, i32* %6
%89 = call i32 @sendto(i32 %39, i8* %51, i32 16, i32 0, %struct.sockaddr* %52, i32 %88)
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
br label %93
93: ; preds = %79, %87, %91, %83, %58, %60
br label %55
94: ; preds = %74, %53
br label %95
95: ; preds = %28, %94
br label %96
96: ; preds = %95, %9
ret i32 1
}