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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int BUFSIZ;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int recv(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int client_socket;
  ssize_t len;
  struct sockaddr_in remote_addr;
  char buffer[BUFSIZ];
  int file_size;
  FILE *received_file;
  int remain_data = 0;
  memset(&remote_addr, 0, sizeof(remote_addr));
  remote_addr.sin_family = AF_INET;
  inet_pton(AF_INET, "127.0.0.1", &(remote_addr.sin_addr));
  remote_addr.sin_port = htons(5000);
  client_socket = socket(AF_INET, SOCK_STREAM, 0);
  if (client_socket == -1) {
    fprintf(stderr, "Error creating socket --> %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (connect(client_socket, (struct sockaddr *)&remote_addr,
              sizeof(struct sockaddr)) == -1) {
    fprintf(stderr, "Error on connect --> %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("CONNECTED");
  recv(client_socket, buffer, BUFSIZ, 0);
  file_size = atoi(buffer);
  received_file = fopen("server_client.txt", "w");
  if (received_file == NULL) {
    fprintf(stderr, "Failed to open file foo --> %s\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  remain_data = file_size;
  while (((len = recv(client_socket, buffer, BUFSIZ, 0)) > 0) &&
         (remain_data > 0)) {
    fwrite(buffer, sizeof(char), len, received_file);
    remain_data -= len;
    fprintf(stdout, "Receive %d bytes and we hope :- %d bytes\n", len,
            file_size);
  }
  fclose(received_file);
  close(client_socket);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x4c(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rdx
add    $0x4,%rdx
lea    0xd93(%rip),%rsi
call   10a0 <inet_pton@plt>
mov    $0x1388,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12e1 <main+0xf1>
mov    0x2d2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rdx
lea    0xd3e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   10e0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1337 <main+0x147>
mov    0x2cd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x60(%rbp),%edi
mov    %rax,%rdx
lea    0xd06(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xd03(%rip),%rdi
call   1060 <printf@plt>
mov    -0x58(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    0x2c77(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    -0x58(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
lea    0xcde(%rip),%rdi
lea    0xce9(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13c4 <main+0x1d4>
mov    0x2c49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0xcb0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x58(%rbp),%rsi
mov    -0x14(%rbp),%edi
mov    0x2bf0(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x65(%rbp)
jle    13fe <main+0x20e>
cmpl   $0x0,-0x4c(%rbp)
setg   %al
mov    %al,-0x65(%rbp)
mov    -0x65(%rbp),%al
test   $0x1,%al
jne    140e <main+0x21e>
jmp    1450 <main+0x260>
mov    -0x58(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
call   10f0 <fwrite@plt>
mov    -0x18(%rbp),%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    0x2b7b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x3c(%rbp),%ecx
lea    0xc3b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    13ca <main+0x1da>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r14
mov    0x2dbd(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2db2(%rip),%rbx
mov    (%rbx),%edi
mov    %edi,-0x30(%rbp)
lea    -0x34(%rbp),%rdx
lea    0xdba(%rip),%rsi
call   10a0 <inet_pton@plt>
mov    $0x1388,%edi
call   1050 <htons@plt>
mov    %eax,-0x38(%rbp)
mov    (%rbx),%edi
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     1377 <main+0x187>
mov    %eax,%ebx
lea    -0x38(%rbp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   10e0 <connect@plt>
cmp    $0xffffffff,%eax
je     1397 <main+0x1a7>
mov    %r14,-0x40(%rbp)
lea    0xda8(%rip),%rdi
call   1060 <printf@plt>
mov    (%r15),%edx
mov    %ebx,%edi
mov    %r13,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %r13,%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
lea    0xd8c(%rip),%rdi
lea    0xd97(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13b7 <main+0x1c7>
mov    %rax,%r12
mov    (%r15),%edx
mov    %ebx,%r14d
mov    %ebx,%edi
mov    %r13,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1352 <main+0x162>
cmpl   $0x0,-0x2c(%rbp)
jle    1352 <main+0x162>
mov    %eax,%ebx
mov    -0x2c(%rbp),%r15d
nopl   0x0(%rax)
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   10f0 <fwrite@plt>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
mov    %ebx,%edx
mov    -0x2c(%rbp),%ecx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c93(%rip),%rax
mov    (%rax),%edx
mov    %r14d,%edi
mov    %r13,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1352 <main+0x162>
sub    %ebx,%r15d
mov    %eax,%ebx
test   %r15d,%r15d
jg     1300 <main+0x110>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c5a(%rip),%rax
mov    (%rax),%ebx
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc75(%rip),%rsi
jmp    13d5 <main+0x1e5>
mov    0x2c3a(%rip),%rax
mov    (%rax),%ebx
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc73(%rip),%rsi
jmp    13d5 <main+0x1e5>
mov    0x2c1a(%rip),%rax
mov    (%rax),%ebx
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc8a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"Error creating socket --> %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"Error on connect --> %s\0A\00"
@.str.3 = [10 x i8] c"CONNECTED\00"
@.str.4 = [18 x i8] c"server_client.txt\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [32 x i8] c"Failed to open file foo --> %s\0A\00"
@stdout = global i32 0
@.str.7 = [42 x i8] c"Receive %d bytes and we hope :- %d bytes\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 %struct.sockaddr_in
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @BUFSIZ
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %9
%17 = alloca i8, i64 %15
store i64 %15, i64* %10
store i32 0, i32* %13
%18 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%19 = load i32, i32* @AF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %19, i32* %20
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%23 = call i32 @inet_pton(i32 %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %22)
%24 = call i32 @htons(i32 5000)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* @AF_INET
%27 = load i32, i32* @SOCK_STREAM
%28 = call i32 @socket(i32 %26, i32 %27, i32 0)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %38
31: ; preds = %2
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %2
%39 = load i32, i32* %6
%40 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%41 = call i32 @connect(i32 %39, %struct.sockaddr* %40, i32 4)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %50
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %38
%51 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* %6
%53 = load i32, i32* @BUFSIZ
%54 = call i32 @recv(i32 %52, i8* %17, i32 %53, i32 0)
%55 = call i32 @atoi(i8* %17)
store i32 %55, i32* %11
%56 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %56, i32** %12
%57 = load i32*, i32** %12
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %66
59: ; preds = %50
%60 = load i32, i32* @stderr
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %62)
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %50
%67 = load i32, i32* %11
store i32 %67, i32* %13
br label %68
68: ; preds = %78, %66
%69 = load i32, i32* %6
%70 = load i32, i32* @BUFSIZ
%71 = call i32 @recv(i32 %69, i8* %17, i32 %70, i32 0)
store i32 %71, i32* %7
%72 = icmp sgt i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %68
%74 = load i32, i32* %13
%75 = icmp sgt i32 %74, 0
br label %76
76: ; preds = %73, %68
%77 = phi i1 [ false, %68 ], [ %75, %73 ]
br i1 %77, label %78, label %89
78: ; preds = %76
%79 = load i32, i32* %7
%80 = load i32*, i32** %12
%81 = call i32 @fwrite(i8* %17, i32 1, i32 %79, i32* %80)
%82 = load i32, i32* %7
%83 = load i32, i32* %13
%84 = sub nsw i32 %83, %82
store i32 %84, i32* %13
%85 = load i32, i32* @stdout
%86 = load i32, i32* %7
%87 = load i32, i32* %11
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %86, i32 %87)
br label %68
89: ; preds = %76
%90 = load i32*, i32** %12
%91 = call i32 @fclose(i32* %90)
%92 = load i32, i32* %6
%93 = call i32 @close(i32 %92)
store i32 0, i32* %3
%94 = load i8*, i8** %9
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.1 = [30 x i8] c"Error creating socket --> %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"Error on connect --> %s\0A\00"
@.str.3 = [10 x i8] c"CONNECTED\00"
@.str.4 = [18 x i8] c"server_client.txt\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [32 x i8] c"Failed to open file foo --> %s\0A\00"
@stdout = global i32 0
@.str.7 = [42 x i8] c"Receive %d bytes and we hope :- %d bytes\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%10 = load i32, i32* @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%13 = call i32 @inet_pton(i32 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = call i32 @htons(i32 5000)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %2
%28 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%29 = call i32 @connect(i32 %18, %struct.sockaddr* %28, i32 4)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %27
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @BUFSIZ
%41 = call i32 @recv(i32 %18, i8* %8, i32 %40, i32 0)
%42 = call i32 @atoi(i8* %8)
%43 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %51, label %45
45: ; preds = %38
%46 = load i32, i32* @BUFSIZ
%47 = call i32 @recv(i32 %18, i8* %8, i32 %46, i32 0)
%48 = icmp sgt i32 %47, 0
%49 = icmp sgt i32 %42, 0
%50 = select i1 %48, i1 %49, i1 false
br i1 %50, label %58, label %70
51: ; preds = %38
%52 = load i32, i32* @stderr
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %54)
%56 = load i32, i32* @EXIT_FAILURE
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %45, %58
%59 = phi i32 [ %66, %58 ], [ %47, %45 ]
%60 = phi i32 [ %62, %58 ], [ %42, %45 ]
%61 = call i32 @fwrite(i8* %8, i32 1, i32 %59, i32* %43)
%62 = sub nsw i32 %60, %59
%63 = load i32, i32* @stdout
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0), i32 %59, i32 %42)
%65 = load i32, i32* @BUFSIZ
%66 = call i32 @recv(i32 %18, i8* %8, i32 %65, i32 0)
%67 = icmp sgt i32 %66, 0
%68 = icmp sgt i32 %62, 0
%69 = select i1 %67, i1 %68, i1 false
br i1 %69, label %58, label %70
70: ; preds = %58, %45
%71 = call i32 @fclose(i32* %43)
%72 = call i32 @close(i32 %18)
ret i32 0
}