#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 {
  char sin_zero;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
char EOF;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
char *inet_ntoa(TYPE_1__);
int /*<<< orphan*/ listen(int, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  if (argc < 3) {
    printf("Not enough arguments\n");
    exit(0);
  }
  int sockfd, newfd, size, i = 0, numbytes;
  char msg[100], buf[100], ch;
  struct sockaddr_in myaddr, theiraddr;
  pid_t cpid;
  FILE *fp;
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  myaddr.sin_family = AF_INET;
  myaddr.sin_port = htons(atoi(argv[2]));
  myaddr.sin_addr.s_addr = inet_addr(argv[1]);
  memset(&(myaddr.sin_zero), '\0', 8);
  bind(sockfd, (struct sockaddr *)&myaddr, sizeof(struct sockaddr));
  listen(sockfd, 10);
  for (;;) {
    size = sizeof(struct sockaddr_in);
    while ((newfd = accept(sockfd, (struct sockaddr *)&theiraddr, &size)) <= 0)
      ;
    cpid = fork();
    if (cpid == 0) {
      memset(buf, '\0', 8);
      numbytes = recv(newfd, buf, 100 - 1, 0);
      buf[numbytes] = '\0';
      printf("Request from %s ", inet_ntoa(theiraddr.sin_addr));
      printf("for file:: %s ... ", buf);
      fp = fopen(buf, "r");
      if (fp == NULL) {
        printf("Unable to locate file %s\n", buf);
        send(newfd, "bad_req", strlen("bad_req"), 0);
      } else {
        while ((ch = fgetc(fp)) != EOF)
          msg[i++] = ch;
        send(newfd, msg, strlen(msg), 0);
        printf("File %s sent\n", buf);
        fclose(fp);
      }
    }
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1258 <main+0x38>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %eax,-0x110(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x114(%rbp)
lea    -0x118(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10a0 <memset@plt>
mov    -0x14(%rbp),%edi
lea    -0x118(%rbp),%rsi
mov    $0x4,%edx
call   10e0 <bind@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   10d0 <listen@plt>
movl   $0x10,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x128(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jg     1316 <main+0xf6>
jmp    12f2 <main+0xd2>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    14b2 <main+0x292>
lea    -0x100(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10a0 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movb   $0x0,-0x100(%rbp,%rax,1)
mov    -0x124(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc97(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x100(%rbp),%rsi
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x100(%rbp),%rdi
lea    0xc91(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
jne    1408 <main+0x1e8>
lea    -0x100(%rbp),%rsi
lea    0xc6b(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x13c(%rbp)
lea    0xc6e(%rip),%rdi
call   1060 <strlen@plt>
mov    -0x13c(%rbp),%edi
mov    %eax,%edx
lea    0xc5a(%rip),%rsi
xor    %ecx,%ecx
call   1080 <send@plt>
jmp    14ad <main+0x28d>
jmp    140d <main+0x1ed>
mov    -0x138(%rbp),%rdi
call   10b0 <fgetc@plt>
mov    %al,-0x101(%rbp)
movsbl %al,%eax
mov    0x2bb7(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1453 <main+0x233>
mov    -0x101(%rbp),%cl
mov    -0x20(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
jmp    140d <main+0x1ed>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14c(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x90(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x14c(%rbp),%edi
mov    -0x148(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    -0x100(%rbp),%rsi
lea    0xbc4(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x138(%rbp),%rdi
call   1050 <fclose@plt>
jmp    14b2 <main+0x292>
jmp    12eb <main+0xcb>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x2,%edi
jle    1465 <main+0x235>
mov    %rsi,%rbp
mov    0x2d94(%rip),%r14
mov    (%r14),%edi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%ebx
mov    (%r14),%eax
mov    %eax,0x1c(%rsp)
mov    0x10(%rbp),%rdi
call   1120 <atoi@plt>
mov    %eax,%edi
call   1080 <htons@plt>
mov    %eax,0x18(%rsp)
mov    0x8(%rbp),%rdi
call   10d0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <memset@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   10f0 <bind@plt>
mov    %ebx,%edi
mov    $0xa,%esi
call   10e0 <listen@plt>
lea    0x20(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0x30(%rsp),%rbp
xor    %r12d,%r12d
jmp    1325 <main+0xf5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xa0(%rsp),%r12
mov    %r12,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
lea    0xd42(%rip),%rdi
lea    0x30(%rsp),%r12
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rbp
call   1060 <fclose@plt>
mov    0x8(%rsp),%r12d
mov    %r12d,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movl   $0x10,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1110 <accept@plt>
test   %eax,%eax
jle    1340 <main+0x110>
mov    %eax,%r13d
xor    %eax,%eax
call   1140 <fork@plt>
test   %rax,%rax
jne    1330 <main+0x100>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <memset@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cltq
movb   $0x0,0x30(%rsp,%rax,1)
mov    0x24(%rsp),%edi
call   1050 <inet_ntoa@plt>
lea    0xc68(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0xc68(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %rbp,%rdi
lea    0xc67(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
jne    1410 <main+0x1e0>
mov    %rbp,%r12
lea    0xc55(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
lea    0xc5e(%rip),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    %r12,%rbp
jmp    1330 <main+0x100>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rbp
mov    %rax,%rdi
call   10c0 <fgetc@plt>
mov    0x2bbe(%rip),%rcx
cmp    (%rcx),%al
je     12e0 <main+0xb0>
movslq 0x8(%rsp),%rcx
lea    (%rsp,%rcx,1),%r12
add    $0xa0,%r12
nopw   0x0(%rax,%rax,1)
mov    %al,(%r12)
mov    %rbp,%rdi
call   10c0 <fgetc@plt>
add    $0x1,%r12
addl   $0x1,0x8(%rsp)
mov    0x2b84(%rip),%rcx
cmp    (%rcx),%al
jne    1440 <main+0x210>
jmp    12e0 <main+0xb0>
lea    0xbea(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [22 x i8] c"Not enough arguments\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"Request from %s \00"
@.str.2 = [19 x i8] c"for file:: %s ... \00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [26 x i8] c"Unable to locate file %s\0A\00"
@.str.5 = [8 x i8] c"bad_req\00"
@EOF = global i8 0
@.str.6 = [14 x i8] c"File %s sent\0A\00"
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 i32
%10 = alloca i32
%11 = alloca [100 x i8]
%12 = alloca [100 x i8]
%13 = alloca i8
%14 = alloca %struct.sockaddr_in
%15 = alloca %struct.sockaddr_in
%16 = alloca i64
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %2
store i32 0, i32* %9
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = call i32 @socket(i32 %24, i32 %25, i32 0)
store i32 %26, i32* %6
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 3
store i32 %27, i32* %28
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = call i32 @htons(i32 %32)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %33, i32* %34
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @inet_addr(i8* %37)
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %39, i32 0, i32 0
store i32 %38, i32* %40
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%42 = call i32 @memset(i8* %41, i8 signext 0, i32 8)
%43 = load i32, i32* %6
%44 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%45 = call i32 @bind(i32 %43, %struct.sockaddr* %44, i32 4)
%46 = load i32, i32* %6
%47 = call i32 @listen(i32 %46, i32 10)
br label %48
48: ; preds = %110, %23
store i32 16, i32* %8
br label %49
49: ; preds = %54, %48
%50 = load i32, i32* %6
%51 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%52 = call i32 @accept(i32 %50, %struct.sockaddr* %51, i32* %8)
store i32 %52, i32* %7
%53 = icmp sle i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %49
br label %49
55: ; preds = %49
%56 = call i64 (...) @fork()
store i64 %56, i64* %16
%57 = load i64, i64* %16
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %110
59: ; preds = %55
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%61 = call i32 @memset(i8* %60, i8 signext 0, i32 8)
%62 = load i32, i32* %7
%63 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%64 = call i32 @recv(i32 %62, i8* %63, i32 99, i32 0)
store i32 %64, i32* %10
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 %66
store i8 0, i8* %67
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%69 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %68, i32 0, i32 0
%70 = load i32, i32* %69
%71 = call i8* @inet_ntoa(i32 %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %71)
%73 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %73)
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%76 = call i32* @fopen(i8* %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %76, i32** %17
%77 = load i32*, i32** %17
%78 = icmp eq i32* %77, null
br i1 %78, label %79, label %85
79: ; preds = %59
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %80)
%82 = load i32, i32* %7
%83 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%84 = call i32 @send(i32 %82, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %83, i32 0)
br label %109
85: ; preds = %59
br label %86
86: ; preds = %93, %85
%87 = load i32*, i32** %17
%88 = call signext i8 @fgetc(i32* %87)
store i8 %88, i8* %13
%89 = sext i8 %88 to i32
%90 = load i8, i8* @EOF
%91 = sext i8 %90 to i32
%92 = icmp ne i32 %89, %91
br i1 %92, label %93, label %99
93: ; preds = %86
%94 = load i8, i8* %13
%95 = load i32, i32* %9
%96 = add nsw i32 %95, 1
store i32 %96, i32* %9
%97 = sext i32 %95 to i64
%98 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 %97
store i8 %94, i8* %98
br label %86
99: ; preds = %86
%100 = load i32, i32* %7
%101 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%102 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%103 = call i32 @strlen(i8* %102)
%104 = call i32 @send(i32 %100, i8* %101, i32 %103, i32 0)
%105 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %105)
%107 = load i32*, i32** %17
%108 = call i32 @fclose(i32* %107)
br label %109
109: ; preds = %99, %79
br label %110
110: ; preds = %109, %55
br label %48
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"Request from %s \00"
@.str.2 = [19 x i8] c"for file:: %s ... \00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [26 x i8] c"Unable to locate file %s\0A\00"
@.str.5 = [8 x i8] c"bad_req\00"
@EOF = global i8 0
@.str.6 = [14 x i8] c"File %s sent\0A\00"
@str = [21 x i8] c"Not enough arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.sockaddr_in
%8 = icmp slt i32 %0, 3
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = bitcast i32* %3 to i8*
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = tail call i32 @socket(i32 %18, i32 %19, i32 0)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 3
store i32 %21, i32* %22
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 @atoi(i8* %24)
%26 = tail call i32 @htons(i32 %25)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %26, i32* %27
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = tail call i32 @inet_addr(i8* %29)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
store i32 %30, i32* %31
%32 = call i32 @memset(i8* %16, i8 signext 0, i32 8)
%33 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%34 = call i32 @bind(i32 %20, %struct.sockaddr* %33, i32 4)
%35 = call i32 @listen(i32 %20, i32 10)
%36 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1, i32 0
br label %38
38: ; preds = %79, %12
%39 = phi i32 [ %80, %79 ], [ 0, %12 ]
br label %40
40: ; preds = %68, %38
store i32 16, i32* %3
br label %41
41: ; preds = %41, %40
%42 = call i32 @accept(i32 %20, %struct.sockaddr* %36, i32* %3)
%43 = icmp slt i32 %42, 1
br i1 %43, label %41, label %44
44: ; preds = %41
%45 = call i64 (...) @fork()
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %68
47: ; preds = %44
%48 = call i32 @memset(i8* %15, i8 signext 0, i32 8)
%49 = call i32 @recv(i32 %42, i8* %15, i32 99, i32 0)
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %50
store i8 0, i8* %51
%52 = load i32, i32* %37
%53 = call i8* @inet_ntoa(i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %53)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%56 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%57 = icmp eq i32* %56, null
br i1 %57, label %64, label %58
58: ; preds = %47
%59 = call signext i8 @fgetc(i32* %56)
%60 = load i8, i8* @EOF
%61 = icmp eq i8 %59, %60
br i1 %61, label %79, label %62
62: ; preds = %58
%63 = sext i32 %39 to i64
br label %69
64: ; preds = %47
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%66 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%67 = call i32 @send(i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %66, i32 0)
br label %68
68: ; preds = %64, %44
br label %40
69: ; preds = %62, %69
%70 = phi i64 [ %63, %62 ], [ %72, %69 ]
%71 = phi i8 [ %59, %62 ], [ %74, %69 ]
%72 = add i64 %70, 1
%73 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %70
store i8 %71, i8* %73
%74 = call signext i8 @fgetc(i32* %56)
%75 = load i8, i8* @EOF
%76 = icmp eq i8 %74, %75
br i1 %76, label %77, label %69
77: ; preds = %69
%78 = trunc i64 %72 to i32
br label %79
79: ; preds = %77, %58
%80 = phi i32 [ %39, %58 ], [ %78, %77 ]
%81 = call i32 @strlen(i8* %14)
%82 = call i32 @send(i32 %42, i8* %14, i32 %81, i32 0)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %15)
%84 = call i32 @fclose(i32* %56)
br label %38
}