#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 */
typedef int /*<<< orphan*/ length;

/* Variables and functions */
int /*<<< orphan*/ SHUT_WR;
int create_socket(char *, int);
int /*<<< orphan*/ exit(int);
int htonl(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int strlen(char *);
scalar_t__ write(int, ...);
int main(int argc, char **argv) {
  int t_length = 0;
  for (int i = 1; i < argc; i++) {
    t_length += strlen(argv[i]) + 1;
  }
  int length = htonl(t_length == 0 ? 1 : t_length);
  int sockfd = create_socket("localhost", 9999);
  if (write(sockfd, &length, sizeof(length)) < 0) {
    perror("error writing to socket");
    exit(1);
  };
  int buffer_size = 1024;
  char buffer[buffer_size];
  if (argc == 1) {
    memset(buffer, 0, buffer_size);
    snprintf(buffer, buffer_size - 1, "\n");
    if (write(sockfd, buffer, strlen(buffer)) < 0) {
      perror("error writing to socket");
      exit(1);
    };
  } else {
    for (int i = 1; i < argc; i++) {
      memset(buffer, 0, buffer_size);
      snprintf(buffer, buffer_size - 1, "%s\n", argv[i]);
      if (write(sockfd, buffer, strlen(buffer)) < 0) {
        perror("error writing to socket");
        exit(1);
      };
    }
  }
  shutdown(sockfd, SHUT_WR);
  memset(buffer, 0, buffer_size);
  char bytes[4];
  if (read(sockfd, bytes, 4) != 4) {
    perror("error reading length");
    exit(1);
  };
  while (read(sockfd, buffer, buffer_size - 1) > 0) {
    if (buffer[0] != '\n') {
      printf("%s", buffer);
    }
    memset(buffer, 0, buffer_size);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1208 <main+0x58>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d4 <main+0x24>
cmpl   $0x0,-0x14(%rbp)
jne    121f <main+0x6f>
mov    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1225 <main+0x75>
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
call   1080 <htonl@plt>
mov    %eax,-0x1c(%rbp)
lea    0xdc9(%rip),%rdi
mov    $0x270f,%esi
call   10b0 <create_socket@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1277 <main+0xc7>
lea    0xda2(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movl   $0x400,-0x24(%rbp)
mov    -0x24(%rbp),%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,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1318 <main+0x168>
mov    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
lea    0xd57(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%eax
mov    %eax,-0x54(%rbp)
call   1050 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1313 <main+0x163>
lea    0xd06(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    13b4 <main+0x204>
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13af <main+0x1ff>
mov    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xccc(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%eax
mov    %eax,-0x58(%rbp)
call   1050 <strlen@plt>
mov    -0x58(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
mov    $0x0,%al
call   1030 <write@plt>
cmp    $0x0,%rax
jge    139c <main+0x1ec>
lea    0xc7d(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    13a1 <main+0x1f1>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    131f <main+0x16f>
jmp    13b4 <main+0x204>
mov    -0x20(%rbp),%edi
mov    0x2c2a(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x20(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
cmp    $0x4,%eax
je     1403 <main+0x253>
lea    0xc32(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1408 <main+0x258>
mov    -0x50(%rbp),%rsi
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x0,%eax
jle    1456 <main+0x2a6>
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1443 <main+0x293>
mov    -0x50(%rbp),%rsi
lea    0xbfd(%rip),%rdi
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
jmp    1408 <main+0x258>
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    %rsi,%r15
mov    %edi,%r12d
cmp    $0x1,%edi
jle    11fe <main+0x4e>
mov    %r12d,%r14d
xor    %r13d,%r13d
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
call   1050 <strlen@plt>
add    %eax,%r13d
add    $0x1,%r13d
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11e0 <main+0x30>
test   %r13d,%r13d
jne    1204 <main+0x54>
mov    $0x1,%r13d
mov    %r13d,%edi
call   1080 <htonl@plt>
mov    %eax,-0x2c(%rbp)
lea    0xdea(%rip),%rdi
mov    $0x270f,%esi
call   10b0 <create_socket@plt>
mov    %eax,%r14d
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
mov    %eax,%edi
xor    %eax,%eax
call   1030 <write@plt>
test   %rax,%rax
js     1295 <main+0xe5>
mov    %rsp,%rax
mov    %rsp,%rbx
add    $0xfffffffffffffc00,%rbx
mov    %rbx,%rsp
cmp    $0x1,%r12d
mov    %rax,-0x38(%rbp)
jne    12ab <main+0xfb>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
lea    0xdba(%rip),%rdx
mov    %rbx,%rdi
mov    $0x3ff,%esi
xor    %eax,%eax
call   1070 <snprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <write@plt>
test   %rax,%rax
jns    130e <main+0x15e>
lea    0xd6e(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jle    130e <main+0x15e>
mov    %r12d,%r13d
mov    $0x1,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    (%r15,%r12,8),%rcx
mov    %rbx,%rdi
mov    $0x3ff,%esi
lea    0xd40(%rip),%rdx
xor    %eax,%eax
call   1070 <snprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <write@plt>
test   %rax,%rax
js     1295 <main+0xe5>
add    $0x1,%r12
cmp    %r12,%r13
jne    12c0 <main+0x110>
mov    0x2cd3(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
call   1040 <shutdown@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
lea    -0x3c(%rbp),%rsi
mov    %r14d,%edi
mov    $0x4,%edx
call   10a0 <read@plt>
cmp    $0x4,%eax
jne    13ba <main+0x20a>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    13a5 <main+0x1f5>
lea    0xcdc(%rip),%r15
jmp    1393 <main+0x1e3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
call   10a0 <read@plt>
test   %eax,%eax
jle    13a5 <main+0x1f5>
cmpb   $0xa,(%rbx)
je     1370 <main+0x1c0>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
jmp    1370 <main+0x1c0>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc65(%rip),%rdi
jmp    129c <main+0xec>

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [24 x i8] c"error writing to socket\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@SHUT_WR = global i32 0
@.str.4 = [21 x i8] c"error reading length\00"
@.str.5 = [3 x i8] c"%s\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 i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca [4 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %15
15: ; preds = %29, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = add nsw i32 %25, 1
%27 = load i32, i32* %6
%28 = add nsw i32 %27, %26
store i32 %28, i32* %6
br label %29
29: ; preds = %19
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %15
32: ; preds = %15
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
br label %38
36: ; preds = %32
%37 = load i32, i32* %6
br label %38
38: ; preds = %36, %35
%39 = phi i32 [ 1, %35 ], [ %37, %36 ]
%40 = call i32 @htonl(i32 %39)
store i32 %40, i32* %8
%41 = call i32 @create_socket(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9999)
store i32 %41, i32* %9
%42 = load i32, i32* %9
%43 = call i64 (i32, ...) @write(i32 %42, i32* %8, i64 4)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
store i32 1024, i32* %10
%49 = load i32, i32* %10
%50 = zext i32 %49 to i64
%51 = call i8* @llvm.stacksave()
store i8* %51, i8** %11
%52 = alloca i8, i64 %50
store i64 %50, i64* %12
%53 = load i32, i32* %4
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %69
55: ; preds = %48
%56 = load i32, i32* %10
%57 = call i32 @memset(i8* %52, i32 0, i32 %56)
%58 = load i32, i32* %10
%59 = sub nsw i32 %58, 1
%60 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %52, i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%61 = load i32, i32* %9
%62 = call i32 @strlen(i8* %52)
%63 = call i64 (i32, ...) @write(i32 %61, i8* %52, i32 %62)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %55
%66 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %55
br label %97
69: ; preds = %48
store i32 1, i32* %13
br label %70
70: ; preds = %93, %69
%71 = load i32, i32* %13
%72 = load i32, i32* %4
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %96
74: ; preds = %70
%75 = load i32, i32* %10
%76 = call i32 @memset(i8* %52, i32 0, i32 %75)
%77 = load i32, i32* %10
%78 = sub nsw i32 %77, 1
%79 = load i8**, i8*** %5
%80 = load i32, i32* %13
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
%83 = load i8*, i8** %82
%84 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %52, i32 %78, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %83)
%85 = load i32, i32* %9
%86 = call i32 @strlen(i8* %52)
%87 = call i64 (i32, ...) @write(i32 %85, i8* %52, i32 %86)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %74
%90 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %74
br label %93
93: ; preds = %92
%94 = load i32, i32* %13
%95 = add nsw i32 %94, 1
store i32 %95, i32* %13
br label %70
96: ; preds = %70
br label %97
97: ; preds = %96, %68
%98 = load i32, i32* %9
%99 = load i32, i32* @SHUT_WR
%100 = call i32 @shutdown(i32 %98, i32 %99)
%101 = load i32, i32* %10
%102 = call i32 @memset(i8* %52, i32 0, i32 %101)
%103 = load i32, i32* %9
%104 = getelementptr inbounds [4 x i8], [4 x i8]* %14, i64 0, i64 0
%105 = call i32 @read(i32 %103, i8* %104, i32 4)
%106 = icmp ne i32 %105, 4
br i1 %106, label %107, label %110
107: ; preds = %97
%108 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %97
br label %111
111: ; preds = %124, %110
%112 = load i32, i32* %9
%113 = load i32, i32* %10
%114 = sub nsw i32 %113, 1
%115 = call i32 @read(i32 %112, i8* %52, i32 %114)
%116 = icmp sgt i32 %115, 0
br i1 %116, label %117, label %127
117: ; preds = %111
%118 = getelementptr inbounds i8, i8* %52, i64 0
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = icmp ne i32 %120, 10
br i1 %121, label %122, label %124
122: ; preds = %117
%123 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %52)
br label %124
124: ; preds = %122, %117
%125 = load i32, i32* %10
%126 = call i32 @memset(i8* %52, i32 0, i32 %125)
br label %111
127: ; preds = %111
store i32 0, i32* %3
%128 = load i8*, i8** %11
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [24 x i8] c"error writing to socket\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@SHUT_WR = global i32 0
@.str.4 = [21 x i8] c"error reading length\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [4 x i8]
%5 = icmp sgt i32 %0, 1
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = bitcast i32* %3 to i8*
br label %13
8: ; preds = %2
%9 = zext i32 %0 to i64
br label %20
10: ; preds = %20
%11 = bitcast i32* %3 to i8*
%12 = icmp eq i32 %27, 0
br i1 %12, label %13, label %14
13: ; preds = %6, %10
br label %14
14: ; preds = %10, %13
%15 = phi i32 [ 1, %13 ], [ %27, %10 ]
%16 = tail call i32 @htonl(i32 %15)
store i32 %16, i32* %3
%17 = tail call i32 @create_socket(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9999)
%18 = call i64 (i32, ...) @write(i32 %17, i32* %3, i64 4)
%19 = icmp slt i64 %18, 0
br i1 %19, label %30, label %33
20: ; preds = %8, %20
%21 = phi i64 [ 1, %8 ], [ %28, %20 ]
%22 = phi i32 [ 0, %8 ], [ %27, %20 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %21
%24 = load i8*, i8** %23
%25 = tail call i32 @strlen(i8* %24)
%26 = add i32 %22, 1
%27 = add i32 %26, %25
%28 = add nuw nsw i64 %21, 1
%29 = icmp eq i64 %28, %9
br i1 %29, label %10, label %20
30: ; preds = %14
%31 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %14
%34 = call i8* @llvm.stacksave()
%35 = alloca [1024 x i8]
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %35, i64 0, i64 0
%37 = icmp eq i32 %0, 1
br i1 %37, label %41, label %38
38: ; preds = %33
br i1 %5, label %39, label %65
39: ; preds = %38
%40 = zext i32 %0 to i64
br label %52
41: ; preds = %33
%42 = call i32 @memset(i8* %36, i32 0, i32 1024)
%43 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %36, i32 1023, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @strlen(i8* %36)
%45 = call i64 (i32, ...) @write(i32 %17, i8* %36, i32 %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %65
47: ; preds = %41
%48 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %52
%51 = icmp eq i64 %61, %40
br i1 %51, label %65, label %52
52: ; preds = %39, %50
%53 = phi i64 [ 1, %39 ], [ %61, %50 ]
%54 = call i32 @memset(i8* %36, i32 0, i32 1024)
%55 = getelementptr inbounds i8*, i8** %1, i64 %53
%56 = load i8*, i8** %55
%57 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %36, i32 1023, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %56)
%58 = call i32 @strlen(i8* %36)
%59 = call i64 (i32, ...) @write(i32 %17, i8* %36, i32 %58)
%60 = icmp slt i64 %59, 0
%61 = add nuw nsw i64 %53, 1
br i1 %60, label %62, label %50
62: ; preds = %52
%63 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %50, %38, %41
%66 = load i32, i32* @SHUT_WR
%67 = call i32 @shutdown(i32 %17, i32 %66)
%68 = call i32 @memset(i8* %36, i32 0, i32 1024)
%69 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%70 = call i32 @read(i32 %17, i8* %69, i32 4)
%71 = icmp eq i32 %70, 4
br i1 %71, label %72, label %75
72: ; preds = %65
%73 = call i32 @read(i32 %17, i8* %36, i32 1023)
%74 = icmp sgt i32 %73, 0
br i1 %74, label %78, label %87
75: ; preds = %65
%76 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %72, %83
%79 = load i8, i8* %36
%80 = icmp eq i8 %79, 10
br i1 %80, label %83, label %81
81: ; preds = %78
%82 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %36)
br label %83
83: ; preds = %81, %78
%84 = call i32 @memset(i8* %36, i32 0, i32 1024)
%85 = call i32 @read(i32 %17, i8* %36, i32 1023)
%86 = icmp sgt i32 %85, 0
br i1 %86, label %78, label %87
87: ; preds = %83, %72
%88 = bitcast i32* %3 to i8*
ret i32 0
}