#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;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ server;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
scalar_t__ listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int listenfd, connfd;
  FILE *fp;
  struct sockaddr_in server;
  if (argc != 3) {
    puts(argv[0]);
    puts("Usage: server <port> <file>");
    return 1;
  }
  if ((fp = fopen(argv[2], "rb")) == 0) {
    perror("Cannot find file to serve");
    return 2;
  }
  memset(&server, 0, sizeof(server));
  server.sin_family = AF_INET;
  server.sin_addr.s_addr = htonl(INADDR_ANY);
  server.sin_port = htons(atoi(argv[1]));
  if ((listenfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    perror("Cannot create server socket");
    return 3;
  }
  if (bind(listenfd, (struct sockaddr *)&server, sizeof(server)) < 0) {
    perror("Cannot open the interface");
    return 4;
  }
  if (listen(listenfd, 5) < 0) {
    perror("Cannot listen on the interface");
    return 5;
  }
  for (;;) {
    if ((connfd = accept(listenfd, (struct sockaddr *)NULL, NULL)) < 0) {
      perror("Error accepting a client connection");
      return 6;
    }
    while (!feof(fp)) {
      char bytes[1024];
      int r = fread(bytes, sizeof(char), 1024, fp);
      while (r > 0) {
        int total = write(connfd, bytes, r);
        if (total < 0) {
          perror("Error writing data to client");
          return 7;
        }
        r -= total;
      }
    }
    fseek(fp, 0, SEEK_SET);
    close(connfd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1247 <main+0x47>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <puts@plt>
lea    0xdca(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1472 <main+0x272>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdc6(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1281 <main+0x81>
lea    0xdaf(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1472 <main+0x272>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
mov    0x2cf3(%rip),%rax
mov    (%rax),%esi
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1309 <main+0x109>
lea    0xd41(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x3,-0x4(%rbp)
jmp    1472 <main+0x272>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    133c <main+0x13c>
lea    0xd2a(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x4,-0x4(%rbp)
jmp    1472 <main+0x272>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
cmp    $0x0,%rax
jge    136b <main+0x16b>
lea    0xd15(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x5,-0x4(%rbp)
jmp    1472 <main+0x272>
jmp    1370 <main+0x170>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    13a3 <main+0x1a3>
lea    0xcfc(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x6,-0x4(%rbp)
jmp    1472 <main+0x272>
jmp    13a8 <main+0x1a8>
mov    -0x20(%rbp),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13c6 <main+0x1c6>
jmp    1451 <main+0x251>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <fread@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0x0,-0x434(%rbp)
jle    144c <main+0x24c>
mov    -0x18(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    -0x434(%rbp),%edx
call   1050 <write@plt>
mov    %eax,-0x438(%rbp)
cmpl   $0x0,-0x438(%rbp)
jge    1433 <main+0x233>
lea    0xc90(%rip),%rdi
call   10f0 <perror@plt>
movl   $0x7,-0x4(%rbp)
jmp    1472 <main+0x272>
mov    -0x438(%rbp),%ecx
mov    -0x434(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x434(%rbp)
jmp    13e6 <main+0x1e6>
jmp    13a8 <main+0x1a8>
mov    -0x20(%rbp),%rdi
mov    0x2b64(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
jmp    1370 <main+0x170>
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1246 <main+0x46>
mov    (%rbx),%rdi
call   1030 <puts@plt>
lea    0xdd8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rbx),%rdi
lea    0xdcb(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
jne    126e <main+0x6e>
lea    0xdbd(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x2,%ebx
jmp    1232 <main+0x32>
mov    %rax,%r15
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d61(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,(%rsp)
mov    0x0(%rbp),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
mov    0x2d12(%rip),%rax
mov    (%rax),%edx
call   1120 <socket@plt>
test   %eax,%eax
jns    12e7 <main+0xe7>
lea    0xd61(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x3,%ebx
jmp    1232 <main+0x32>
mov    %eax,%r14d
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
jns    1314 <main+0x114>
lea    0xd50(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x4,%ebx
jmp    1232 <main+0x32>
mov    $0x5,%ebx
mov    %r14d,%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
test   %rax,%rax
jns    133c <main+0x13c>
lea    0xd3d(%rip),%rdi
call   10f0 <perror@plt>
jmp    1232 <main+0x32>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
test   %eax,%eax
jns    1362 <main+0x162>
lea    0xd3b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x6,%ebx
jmp    1232 <main+0x32>
mov    %eax,%ebx
lea    0x10(%rsp),%r12
mov    0x2c50(%rip),%r13
jmp    1399 <main+0x199>
mov    0x0(%r13),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1100 <accept@plt>
mov    %eax,%ebx
test   %eax,%eax
js     134c <main+0x14c>
mov    %r15,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    1372 <main+0x172>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1399 <main+0x199>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1050 <write@plt>
test   %eax,%eax
js     13d8 <main+0x1d8>
sub    %eax,%ebp
test   %ebp,%ebp
jg     13c0 <main+0x1c0>
jmp    1399 <main+0x199>
lea    0xcd3(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x7,%ebx
jmp    1232 <main+0x32>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [28 x i8] c"Usage: server <port> <file>\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Cannot find file to serve\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [28 x i8] c"Cannot create server socket\00"
@.str.4 = [26 x i8] c"Cannot open the interface\00"
@.str.5 = [31 x i8] c"Cannot listen on the interface\00"
@.str.6 = [36 x i8] c"Error accepting a client connection\00"
@.str.7 = [29 x i8] c"Error writing data to client\00"
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca %struct.sockaddr_in
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @puts(i8* %18)
%20 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %103
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %8
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %103
29: ; preds = %21
%30 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %31, i32* %32
%33 = load i32, i32* @INADDR_ANY
%34 = call i32 @htonl(i32 %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
%41 = call i32 @htons(i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %41, i32* %42
%43 = load i32, i32* @AF_INET
%44 = load i32, i32* @SOCK_STREAM
%45 = load i32, i32* @IPPROTO_TCP
%46 = call i32 @socket(i32 %43, i32 %44, i32 %45)
store i32 %46, i32* %6
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %29
%49 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %3
br label %103
50: ; preds = %29
%51 = load i32, i32* %6
%52 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%53 = call i64 @bind(i32 %51, %struct.sockaddr* %52, i32 12)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 4, i32* %3
br label %103
57: ; preds = %50
%58 = load i32, i32* %6
%59 = call i64 @listen(i32 %58, i32 5)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
store i32 5, i32* %3
br label %103
63: ; preds = %57
br label %64
64: ; preds = %97, %63
%65 = load i32, i32* %6
%66 = call i32 @accept(i32 %65, %struct.sockaddr* null, i32* null)
store i32 %66, i32* %7
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 6, i32* %3
br label %103
70: ; preds = %64
br label %71
71: ; preds = %96, %70
%72 = load i32*, i32** %8
%73 = call i32 @feof(i32* %72)
%74 = icmp ne i32 %73, 0
%75 = xor i1 %74, true
br i1 %75, label %76, label %97
76: ; preds = %71
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%78 = load i32*, i32** %8
%79 = call i32 @fread(i8* %77, i32 1, i32 1024, i32* %78)
store i32 %79, i32* %11
br label %80
80: ; preds = %92, %76
%81 = load i32, i32* %11
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %96
83: ; preds = %80
%84 = load i32, i32* %7
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%86 = load i32, i32* %11
%87 = call i32 @write(i32 %84, i8* %85, i32 %86)
store i32 %87, i32* %12
%88 = load i32, i32* %12
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %83
%91 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
store i32 7, i32* %3
br label %103
92: ; preds = %83
%93 = load i32, i32* %12
%94 = load i32, i32* %11
%95 = sub nsw i32 %94, %93
store i32 %95, i32* %11
br label %80
96: ; preds = %80
br label %71
97: ; preds = %71
%98 = load i32*, i32** %8
%99 = load i32, i32* @SEEK_SET
%100 = call i32 @fseek(i32* %98, i32 0, i32 %99)
%101 = load i32, i32* %7
%102 = call i32 @close(i32 %101)
br label %64
103: ; preds = %90, %68, %61, %55, %48, %27, %15
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [28 x i8] c"Usage: server <port> <file>\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Cannot find file to serve\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [28 x i8] c"Cannot create server socket\00"
@.str.4 = [26 x i8] c"Cannot open the interface\00"
@.str.5 = [31 x i8] c"Cannot listen on the interface\00"
@.str.6 = [36 x i8] c"Error accepting a client connection\00"
@.str.7 = [29 x i8] c"Error writing data to client\00"
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [1024 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = icmp eq i32 %0, 3
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %80
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %80
18: ; preds = %11
%19 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %20, i32* %21
%22 = load i32, i32* @INADDR_ANY
%23 = call i32 @htonl(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %23, i32* %24
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
%28 = call i32 @htons(i32 %27)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %28, i32* %29
%30 = load i32, i32* @AF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = load i32, i32* @IPPROTO_TCP
%33 = call i32 @socket(i32 %30, i32 %31, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %18
%36 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %80
37: ; preds = %18
%38 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%39 = call i64 @bind(i32 %33, %struct.sockaddr* %38, i32 12)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %80
43: ; preds = %37
%44 = call i64 @listen(i32 %33, i32 5)
%45 = icmp slt i64 %44, 0
br i1 %45, label %51, label %46
46: ; preds = %43
%47 = call i32 @accept(i32 %33, %struct.sockaddr* null, i32* null)
%48 = icmp slt i32 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %46
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
br label %53
51: ; preds = %43
%52 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %80
53: ; preds = %49, %74
%54 = phi i32 [ %47, %49 ], [ %78, %74 ]
%55 = call i32 @feof(i32* %14)
%56 = icmp eq i32 %55, 0
br i1 %56, label %59, label %74
57: ; preds = %74, %46
%58 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
br label %80
59: ; preds = %53, %71
%60 = call i32 @fread(i8* %50, i32 1, i32 1024, i32* %14)
%61 = icmp sgt i32 %60, 0
br i1 %61, label %64, label %71
62: ; preds = %64
%63 = icmp sgt i32 %68, 0
br i1 %63, label %64, label %71
64: ; preds = %59, %62
%65 = phi i32 [ %68, %62 ], [ %60, %59 ]
%66 = call i32 @write(i32 %54, i8* %50, i32 %65)
%67 = icmp slt i32 %66, 0
%68 = sub nsw i32 %65, %66
br i1 %67, label %69, label %62
69: ; preds = %64
%70 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %80
71: ; preds = %62, %59
%72 = call i32 @feof(i32* %14)
%73 = icmp eq i32 %72, 0
br i1 %73, label %59, label %74
74: ; preds = %71, %53
%75 = load i32, i32* @SEEK_SET
%76 = call i32 @fseek(i32* %14, i32 0, i32 %75)
%77 = call i32 @close(i32 %54)
%78 = call i32 @accept(i32 %33, %struct.sockaddr* null, i32* null)
%79 = icmp slt i32 %78, 0
br i1 %79, label %57, label %53
80: ; preds = %69, %57, %51, %41, %35, %16, %7
%81 = phi i32 [ 1, %7 ], [ 2, %16 ], [ 3, %35 ], [ 4, %41 ], [ 5, %51 ], [ 6, %57 ], [ 7, %69 ]
ret i32 %81
}