#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;
typedef int socklen_t;
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ other_sin;

/* Variables and functions */
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
scalar_t__ check_buffer(long *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ errx(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, ...);
char *inet_ntoa(int /*<<< orphan*/);
int listen(int, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, long *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srandom(long);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void tcpstream_server(struct sockaddr_in sin, long seed) {
  int i, j, listen_sock, accept_sock;
  struct sockaddr_in other_sin;
  long buffer[1024];
  socklen_t addrlen;
  ssize_t len;
  int input_byte_counter;
  listen_sock = socket(PF_INET, SOCK_STREAM, 0);
  if (listen_sock == -1)
    errx(-1, "socket: %s", strerror(errno));
  if (bind(listen_sock, (struct sockaddr *)&sin, sizeof(sin)) == -1)
    errx(-1, "bind: %s", strerror(errno));
  if (listen(listen_sock, -1) == -1)
    errx(-1, "listen: %s", strerror(errno));
  while (1) {
    bzero(&other_sin, sizeof(other_sin));
    addrlen = sizeof(other_sin);
    accept_sock = accept(listen_sock, (struct sockaddr *)&other_sin, &addrlen);
    if (accept_sock == -1) {
      perror("accept");
      continue;
    }
    printf("connection opened from %s:%d\n", inet_ntoa(other_sin.sin_addr),
           ntohs(other_sin.sin_port));
    input_byte_counter = 0;
    srandom(seed);
    for (j = 0; j < 10240; j++) {
      for (i = 0; i < 1024; i++) {
        len = recv(accept_sock, buffer, i * sizeof(long), MSG_WAITALL);
        if (len != i * sizeof(long)) {
          perror("recv");
          goto done;
        }
        if (check_buffer(buffer, i) == 0) {
          fprintf(stderr, "Corruption in block beginning %d and ending %d\n",
                  input_byte_counter, input_byte_counter + len);
          fprintf(stderr, "Block size %d\n", i * sizeof(long));
          goto done;
        }
        input_byte_counter += len;
      }
    }
  done:
    printf("connection closed\n");
    close(accept_sock);
  }
}


x86 assembly (clang, -O0):
<tcpstream_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2050,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    0x2db5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    125a <tcpstream_server+0x5a>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %eax,%edx
mov    $0xffffffff,%edi
lea    0xdab(%rip),%rsi
call   1070 <errx@plt>
mov    -0x1c(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   10d0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1295 <tcpstream_server+0x95>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %eax,%edx
mov    $0xffffffff,%edi
lea    0xd7b(%rip),%rsi
call   1070 <errx@plt>
mov    -0x1c(%rbp),%edi
mov    $0xffffffff,%esi
call   10b0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12cc <tcpstream_server+0xcc>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    %eax,%edx
mov    $0xffffffff,%edi
lea    0xd4d(%rip),%rsi
call   1070 <errx@plt>
jmp    12d1 <tcpstream_server+0xd1>
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
call   10f0 <bzero@plt>
movl   $0x8,-0x2034(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2034(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    131a <tcpstream_server+0x11a>
lea    0xd0f(%rip),%rdi
call   10e0 <perror@plt>
jmp    12d1 <tcpstream_server+0xd1>
mov    -0x24(%rbp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,-0x2048(%rbp)
mov    -0x28(%rbp),%edi
call   10c0 <ntohs@plt>
mov    -0x2048(%rbp),%rsi
mov    %eax,%edx
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x203c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <srandom@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2800,-0x18(%rbp)
jge    146f <tcpstream_server+0x26f>
movl   $0x0,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    145c <tcpstream_server+0x25c>
mov    -0x20(%rbp),%edi
lea    -0x2030(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
mov    0x2c1a(%rip),%rax
mov    (%rax),%ecx
call   1030 <recv@plt>
mov    %eax,-0x2038(%rbp)
movslq -0x2038(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
cmp    %rcx,%rax
je     13d4 <tcpstream_server+0x1d4>
lea    0xc7a(%rip),%rdi
call   10e0 <perror@plt>
jmp    1474 <tcpstream_server+0x274>
lea    -0x2030(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <check_buffer@plt>
cmp    $0x0,%rax
jne    143c <tcpstream_server+0x23c>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
mov    -0x203c(%rbp),%edx
mov    -0x203c(%rbp),%ecx
add    -0x2038(%rbp),%ecx
lea    0xc3a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
lea    0xc49(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1474 <tcpstream_server+0x274>
mov    -0x2038(%rbp),%eax
add    -0x203c(%rbp),%eax
mov    %eax,-0x203c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1376 <tcpstream_server+0x176>
jmp    1461 <tcpstream_server+0x261>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1362 <tcpstream_server+0x162>
jmp    1474 <tcpstream_server+0x274>
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%edi
call   1090 <close@plt>
jmp    12d1 <tcpstream_server+0xd1>

x86 assembly (clang, -O2):
<tcpstream_server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2038,%rsp
mov    %rsi,0x20(%rsp)
mov    %rdi,0x28(%rsp)
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    0x2d9d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    126d <tcpstream_server+0x5d>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd9f(%rip),%rsi
mov    $0xffffffff,%edi
mov    %eax,%edx
call   1080 <errx@plt>
lea    0x28(%rsp),%rsi
mov    %r14d,%edi
mov    $0x8,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12a5 <tcpstream_server+0x95>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd72(%rip),%rsi
mov    $0xffffffff,%edi
mov    %eax,%edx
call   1080 <errx@plt>
mov    %r14d,%edi
mov    $0xffffffff,%esi
call   10c0 <listen@plt>
cmp    $0xffffffff,%eax
jne    12d8 <tcpstream_server+0xc8>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xd48(%rip),%rsi
mov    $0xffffffff,%edi
mov    %eax,%edx
call   1080 <errx@plt>
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%rbx
lea    0x30(%rsp),%r12
mov    %r14d,0x18(%rsp)
jmp    12fc <tcpstream_server+0xec>
xchg   %ax,%ax
lea    0xd28(%rip),%rdi
call   10f0 <perror@plt>
mov    %rbp,%rdi
mov    $0x8,%esi
call   1100 <bzero@plt>
movl   $0x8,0xc(%rsp)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1110 <accept@plt>
cmp    $0xffffffff,%eax
je     12f0 <tcpstream_server+0xe0>
mov    %eax,%r13d
mov    0x14(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
call   10d0 <ntohs@plt>
xor    %r14d,%r14d
lea    0xce0(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x20(%rsp),%rdi
call   1040 <srandom@plt>
xor    %eax,%eax
xchg   %ax,%ax
mov    %eax,0x1c(%rsp)
xor    %r15d,%r15d
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    0x2c41(%rip),%rax
mov    (%rax),%ecx
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <recv@plt>
mov    %eax,%ebx
cltq
cmp    %rax,%r15
jne    13d0 <tcpstream_server+0x1c0>
mov    %r12,%rdi
mov    %ebp,%esi
call   1070 <check_buffer@plt>
test   %rax,%rax
je     13e0 <tcpstream_server+0x1d0>
add    %ebx,%r14d
add    $0x1,%rbp
add    $0x8,%r15
cmp    $0x400,%rbp
jne    1370 <tcpstream_server+0x160>
mov    0x1c(%rsp),%eax
add    $0x1,%eax
cmp    $0x2800,%eax
jne    1360 <tcpstream_server+0x150>
jmp    1414 <tcpstream_server+0x204>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xc6d(%rip),%rdi
call   10f0 <perror@plt>
jmp    1414 <tcpstream_server+0x204>
xchg   %ax,%ax
mov    0x2bf9(%rip),%rbp
mov    0x0(%rbp),%edi
add    %r14d,%ebx
lea    0xc55(%rip),%rsi
mov    %r14d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xc6f(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
lea    0xc6d(%rip),%rdi
call   1050 <puts@plt>
mov    %r13d,%edi
call   10a0 <close@plt>
mov    0x18(%rsp),%r14d
lea    0x10(%rsp),%rbp
lea    0xc(%rsp),%rbx
jmp    12fc <tcpstream_server+0xec>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [11 x i8] c"socket: %s\00"
@errno = global i32 0
@.str.1 = [9 x i8] c"bind: %s\00"
@.str.2 = [11 x i8] c"listen: %s\00"
@.str.3 = [7 x i8] c"accept\00"
@.str.4 = [30 x i8] c"connection opened from %s:%d\0A\00"
@MSG_WAITALL = global i32 0
@.str.5 = [5 x i8] c"recv\00"
@stderr = global i32 0
@.str.6 = [48 x i8] c"Corruption in block beginning %d and ending %d\0A\00"
@.str.7 = [15 x i8] c"Block size %d\0A\00"
@.str.8 = [19 x i8] c"connection closed\0A\00"
define void @tcpstream_server(i64 %0, i64 %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca [1024 x i64]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = bitcast %struct.sockaddr_in* %3 to i64*
store i64 %0, i64* %14
store i64 %1, i64* %4
%15 = load i32, i32* @PF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i32 %15, i32 %16, i32 0)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %20, %2
%25 = load i32, i32* %7
%26 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%27 = call i32 @bind(i32 %25, %struct.sockaddr* %26, i32 8)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i32, i32* @errno
%31 = call i32 @strerror(i32 %30)
%32 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %24
%34 = load i32, i32* %7
%35 = call i32 @listen(i32 %34, i32 -1)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i32, i32* @errno
%39 = call i32 @strerror(i32 %38)
%40 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %37, %33
br label %42
42: ; preds = %41, %49, %115
%43 = call i32 @bzero(%struct.sockaddr_in* %9, i32 8)
store i32 8, i32* %11
%44 = load i32, i32* %7
%45 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%46 = call i32 @accept(i32 %44, %struct.sockaddr* %45, i32* %11)
store i32 %46, i32* %8
%47 = load i32, i32* %8
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %42
%50 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %42
51: ; preds = %42
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%53 = load i32, i32* %52
%54 = call i8* @inet_ntoa(i32 %53)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @ntohs(i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %54, i32 %57)
store i32 0, i32* %13
%59 = load i64, i64* %4
%60 = call i32 @srandom(i64 %59)
store i32 0, i32* %6
br label %61
61: ; preds = %111, %51
%62 = load i32, i32* %6
%63 = icmp slt i32 %62, 10240
br i1 %63, label %64, label %114
64: ; preds = %61
store i32 0, i32* %5
br label %65
65: ; preds = %107, %64
%66 = load i32, i32* %5
%67 = icmp slt i32 %66, 1024
br i1 %67, label %68, label %110
68: ; preds = %65
%69 = load i32, i32* %8
%70 = getelementptr inbounds [1024 x i64], [1024 x i64]* %10, i64 0, i64 0
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = mul i64 %72, 8
%74 = trunc i64 %73 to i32
%75 = load i32, i32* @MSG_WAITALL
%76 = call i32 @recv(i32 %69, i64* %70, i32 %74, i32 %75)
store i32 %76, i32* %12
%77 = load i32, i32* %12
%78 = sext i32 %77 to i64
%79 = load i32, i32* %5
%80 = sext i32 %79 to i64
%81 = mul i64 %80, 8
%82 = icmp ne i64 %78, %81
br i1 %82, label %83, label %85
83: ; preds = %68
%84 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %115
85: ; preds = %68
%86 = getelementptr inbounds [1024 x i64], [1024 x i64]* %10, i64 0, i64 0
%87 = load i32, i32* %5
%88 = call i64 @check_buffer(i64* %86, i32 %87)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %103
90: ; preds = %85
%91 = load i32, i32* @stderr
%92 = load i32, i32* %13
%93 = load i32, i32* %13
%94 = load i32, i32* %12
%95 = add nsw i32 %93, %94
%96 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %92, i32 %95)
%97 = load i32, i32* @stderr
%98 = load i32, i32* %5
%99 = sext i32 %98 to i64
%100 = mul i64 %99, 8
%101 = trunc i64 %100 to i32
%102 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %101)
br label %115
103: ; preds = %85
%104 = load i32, i32* %12
%105 = load i32, i32* %13
%106 = add nsw i32 %105, %104
store i32 %106, i32* %13
br label %107
107: ; preds = %103
%108 = load i32, i32* %5
%109 = add nsw i32 %108, 1
store i32 %109, i32* %5
br label %65
110: ; preds = %65
br label %111
111: ; preds = %110
%112 = load i32, i32* %6
%113 = add nsw i32 %112, 1
store i32 %113, i32* %6
br label %61
114: ; preds = %61
br label %115
115: ; preds = %114, %90, %83
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%117 = load i32, i32* %8
%118 = call i32 @close(i32 %117)
br label %42
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [11 x i8] c"socket: %s\00"
@errno = global i32 0
@.str.1 = [9 x i8] c"bind: %s\00"
@.str.2 = [11 x i8] c"listen: %s\00"
@.str.3 = [7 x i8] c"accept\00"
@.str.4 = [30 x i8] c"connection opened from %s:%d\0A\00"
@MSG_WAITALL = global i32 0
@.str.5 = [5 x i8] c"recv\00"
@stderr = global i32 0
@.str.6 = [48 x i8] c"Corruption in block beginning %d and ending %d\0A\00"
@.str.7 = [15 x i8] c"Block size %d\0A\00"
@str = [18 x i8] c"connection closed\00"
define void @tcpstream_server(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i64]
%6 = alloca i32
store i64 %0, i64* %3
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast [1024 x i64]* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = load i32, i32* @PF_INET
%11 = load i32, i32* @SOCK_STREAM
%12 = tail call i32 @socket(i32 %10, i32 %11, i32 0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @errno
%16 = tail call i32 @strerror(i32 %15)
%17 = tail call i32 @errx(i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %2
%19 = bitcast i64* %3 to %struct.sockaddr*
%20 = call i32 @bind(i32 %12, %struct.sockaddr* %19, i32 8)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* @errno
%24 = call i32 @strerror(i32 %23)
%25 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %18
%27 = call i32 @listen(i32 %12, i32 -1)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* @errno
%31 = call i32 @strerror(i32 %30)
%32 = call i32 @errx(i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %26
%34 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%37 = getelementptr inbounds [1024 x i64], [1024 x i64]* %5, i64 0, i64 0
br label %38
38: ; preds = %44, %33
%39 = call i32 @bzero(%struct.sockaddr_in* %4, i32 8)
store i32 8, i32* %6
%40 = call i32 @accept(i32 %12, %struct.sockaddr* %34, i32* %6)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %84
br label %38
45: ; preds = %38
%46 = load i32, i32* %35
%47 = call i8* @inet_ntoa(i32 %46)
%48 = load i32, i32* %36
%49 = call i32 @ntohs(i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %47, i32 %49)
%51 = call i32 @srandom(i64 %1)
br label %52
52: ; preds = %45, %81
%53 = phi i32 [ 0, %45 ], [ %78, %81 ]
%54 = phi i32 [ 0, %45 ], [ %82, %81 ]
br label %55
55: ; preds = %52, %77
%56 = phi i64 [ 0, %52 ], [ %79, %77 ]
%57 = phi i32 [ %53, %52 ], [ %78, %77 ]
%58 = shl nuw nsw i64 %56, 3
%59 = trunc i64 %58 to i32
%60 = load i32, i32* @MSG_WAITALL
%61 = call i32 @recv(i32 %40, i64* %37, i32 %59, i32 %60)
%62 = sext i32 %61 to i64
%63 = icmp eq i64 %58, %62
br i1 %63, label %66, label %64
64: ; preds = %55
%65 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %84
66: ; preds = %55
%67 = trunc i64 %56 to i32
%68 = call i64 @check_buffer(i64* %37, i32 %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %77
70: ; preds = %66
%71 = trunc i64 %58 to i32
%72 = load i32, i32* @stderr
%73 = add nsw i32 %61, %57
%74 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0), i32 %57, i32 %73)
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %71)
br label %84
77: ; preds = %66
%78 = add nsw i32 %61, %57
%79 = add nuw nsw i64 %56, 1
%80 = icmp eq i64 %79, 1024
br i1 %80, label %81, label %55
81: ; preds = %77
%82 = add nuw nsw i32 %54, 1
%83 = icmp eq i32 %82, 10240
br i1 %83, label %84, label %52
84: ; preds = %81, %70, %64
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%86 = call i32 @close(i32 %40)
br label %44
}