#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;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serv_addr;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ log_out;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int MAP_ANONYMOUS;
int MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ fork();
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int *mmap(int /*<<< orphan*/ *, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sockfd;
  int portno = 7158;
  char snd_buffer[512];
  char rcv_buffer[512];
  int *log_out = mmap(NULL, sizeof(log_out), PROT_READ | PROT_WRITE,
                      MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  struct sockaddr_in serv_addr;
  struct hostent *server = gethostbyname("localhost");
  int n;
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0) {
    close(sockfd);
    error("ERROR opening socket");
  }
  bzero((char *)&serv_addr, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr,
        server->h_length);
  serv_addr.sin_port = htons(portno);
  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
    close(sockfd);
    error("ERROR connecting");
  }
  pid_t pid = fork();
  for (;;) {
    if (pid < 0) {
      error("fork()");
      continue;
    } else if (pid == 0) {
      bzero(rcv_buffer, 512);
      n = read(sockfd, rcv_buffer, 512);
      if (n < 0) {
        close(sockfd);
        error("ERROR reading from socket");
      }
      if (strncmp(rcv_buffer, "Logged out successfully.", 24) == 0) {
        printf("%s\n", rcv_buffer);
        *log_out = 1;
        exit(0);
        break;
      } else
        printf("%s", rcv_buffer);
      fflush(stdout);
    } else if (pid > 0) {
      if (*log_out == 1) {
        exit(0);
      }
      bzero(snd_buffer, 512);
      fgets(snd_buffer, 512, stdin);
      n = write(sockfd, snd_buffer, strlen(snd_buffer));
      if (n < 0) {
        close(sockfd);
        error("ERROR writing to socket");
      }
      fflush(stdout);
    }
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1bf6,-0x18(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%edx
mov    0x2d60(%rip),%rax
or     (%rax),%edx
mov    0x2d8f(%rip),%rax
mov    (%rax),%ecx
mov    0x2d66(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,-0x428(%rbp)
lea    0xd77(%rip),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x440(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x2d13(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12cf <main+0xaf>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xd40(%rip),%rdi
call   10f0 <error@plt>
lea    -0x438(%rbp),%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x430(%rbp)
mov    -0x440(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x438(%rbp),%rsi
add    $0x4,%rsi
mov    -0x440(%rbp),%rax
mov    (%rax),%edx
call   10e0 <bcopy@plt>
mov    -0x18(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,-0x438(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x438(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0x0,%rax
jge    1353 <main+0x133>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xcd1(%rip),%rdi
call   10f0 <error@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jge    1380 <main+0x160>
lea    0xcba(%rip),%rdi
call   10f0 <error@plt>
jmp    1361 <main+0x141>
cmpq   $0x0,-0x450(%rbp)
jne    1449 <main+0x229>
lea    -0x420(%rbp),%rdi
mov    $0x200,%esi
call   1100 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x200,%edx
call   10a0 <read@plt>
mov    %eax,-0x444(%rbp)
cmpl   $0x0,-0x444(%rbp)
jge    13da <main+0x1ba>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xc62(%rip),%rdi
call   10f0 <error@plt>
lea    -0x420(%rbp),%rdi
lea    0xc69(%rip),%rsi
mov    $0x18,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1423 <main+0x203>
lea    -0x420(%rbp),%rsi
lea    0xc60(%rip),%rdi
call   1080 <printf@plt>
mov    -0x428(%rbp),%rax
movl   $0x1,(%rax)
xor    %edi,%edi
call   1110 <exit@plt>
lea    -0x420(%rbp),%rsi
lea    0xc3d(%rip),%rdi
call   1080 <printf@plt>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    150a <main+0x2ea>
cmpq   $0x0,-0x450(%rbp)
jle    1505 <main+0x2e5>
mov    -0x428(%rbp),%rax
cmpl   $0x1,(%rax)
jne    146e <main+0x24e>
xor    %edi,%edi
call   1110 <exit@plt>
lea    -0x220(%rbp),%rdi
mov    $0x200,%esi
call   1100 <bzero@plt>
lea    -0x220(%rbp),%rdi
mov    0x2b43(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   10b0 <fgets@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x45c(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x458(%rbp)
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x45c(%rbp),%edi
mov    -0x458(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x444(%rbp)
cmpl   $0x0,-0x444(%rbp)
jge    14f7 <main+0x2d7>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xb7f(%rip),%rdi
call   10f0 <error@plt>
mov    0x2aaa(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
jmp    150a <main+0x2ea>
jmp    150f <main+0x2ef>
jmp    1361 <main+0x141>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    0x2dc0(%rip),%rax
mov    0x2d71(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d9e(%rip),%rax
mov    0x2d77(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x8,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%r14
lea    0xd8c(%rip),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,%rbx
mov    0x2d55(%rip),%r12
mov    (%r12),%edi
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12b0 <main+0x90>
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xd5f(%rip),%rdi
call   10f0 <error@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   1100 <bzero@plt>
mov    (%r12),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rsi
lea    0x4(%rsp),%rdi
mov    (%rbx),%edx
call   10e0 <memmove@plt>
mov    $0x1bf6,%edi
call   1070 <htons@plt>
mov    %eax,(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
test   %rax,%rax
jns    130c <main+0xec>
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xd18(%rip),%rdi
call   10f0 <error@plt>
xor    %eax,%eax
call   1130 <fork@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%r12
mov    0x2c86(%rip),%r15
lea    0x210(%rsp),%r13
test   %rbx,%rbx
jns    135e <main+0x13e>
jmp    134d <main+0x12d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
call   10d0 <fflush@plt>
test   %rbx,%rbx
jns    135e <main+0x13e>
lea    0xcdc(%rip),%rdi
call   10f0 <error@plt>
test   %rbx,%rbx
js     134d <main+0x12d>
je     13c0 <main+0x1a0>
cmpl   $0x1,(%r14)
je     1438 <main+0x218>
mov    %r13,%rdi
mov    $0x200,%esi
call   1100 <bzero@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    $0x200,%esi
call   10b0 <fgets@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    1340 <main+0x120>
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xcbe(%rip),%rdi
call   10f0 <error@plt>
jmp    1340 <main+0x120>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x200,%esi
call   1100 <bzero@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x200,%edx
call   10a0 <read@plt>
test   %eax,%eax
jns    13f3 <main+0x1d3>
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xc49(%rip),%rdi
call   10f0 <error@plt>
mov    %r12,%rdi
lea    0xc54(%rip),%rsi
mov    $0x18,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1420 <main+0x200>
lea    0xc5b(%rip),%rdi
mov    %r12,%rsi
call   1080 <printf@plt>
jmp    1340 <main+0x120>
lea    0xc43(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1080 <printf@plt>
movl   $0x1,(%r14)
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str = [10 x i8] c"localhost\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@.str.2 = [17 x i8] c"ERROR connecting\00"
@.str.3 = [7 x i8] c"fork()\00"
@.str.4 = [26 x i8] c"ERROR reading from socket\00"
@.str.5 = [25 x i8] c"Logged out successfully.\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@stdout = global i32 0
@stdin = global i32 0
@.str.8 = [24 x i8] c"ERROR writing to socket\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 [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca i32*
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.hostent*
%13 = alloca i32
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 7158, i32* %7
%15 = load i32, i32* @PROT_READ
%16 = load i32, i32* @PROT_WRITE
%17 = or i32 %15, %16
%18 = load i32, i32* @MAP_SHARED
%19 = load i32, i32* @MAP_ANONYMOUS
%20 = or i32 %18, %19
%21 = call i32* @mmap(i32* null, i32 8, i32 %17, i32 %20, i32 -1, i32 0)
store i32* %21, i32** %10
%22 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store %struct.hostent* %22, %struct.hostent** %12
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = call i32 @socket(i32 %23, i32 %24, i32 0)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %2
%29 = load i32, i32* %6
%30 = call i32 @close(i32 %29)
%31 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %28, %2
%33 = bitcast %struct.sockaddr_in* %11 to i8*
%34 = call i32 @bzero(i8* %33, i32 12)
%35 = load i32, i32* @AF_INET
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %35, i32* %36
%37 = load %struct.hostent*, %struct.hostent** %12
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %37, i32 0, i32 1
%39 = load i64, i64* %38
%40 = inttoptr i64 %39 to i8*
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
%43 = bitcast i32* %42 to i8*
%44 = load %struct.hostent*, %struct.hostent** %12
%45 = getelementptr inbounds %struct.hostent, %struct.hostent* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = call i32 @bcopy(i8* %40, i8* %43, i32 %46)
%48 = load i32, i32* %7
%49 = call i32 @htons(i32 %48)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %49, i32* %50
%51 = load i32, i32* %6
%52 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%53 = call i64 @connect(i32 %51, %struct.sockaddr* %52, i32 12)
%54 = icmp slt i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %32
%56 = load i32, i32* %6
%57 = call i32 @close(i32 %56)
%58 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %55, %32
%60 = call i64 (...) @fork()
store i64 %60, i64* %14
br label %61
61: ; preds = %127, %64, %59
%62 = load i64, i64* %14
%63 = icmp slt i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %61
66: ; preds = %61
%67 = load i64, i64* %14
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %96
69: ; preds = %66
%70 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%71 = call i32 @bzero(i8* %70, i32 512)
%72 = load i32, i32* %6
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%74 = call i32 @read(i32 %72, i8* %73, i32 512)
store i32 %74, i32* %13
%75 = load i32, i32* %13
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %69
%78 = load i32, i32* %6
%79 = call i32 @close(i32 %78)
%80 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %81
81: ; preds = %77, %69
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%83 = call i64 @strncmp(i8* %82, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 24)
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %90
85: ; preds = %81
%86 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%87 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %86)
%88 = load i32*, i32** %10
store i32 1, i32* %88
%89 = call i32 @exit(i32 0)
unreachable
90: ; preds = %81
%91 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%92 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %90
%94 = load i32, i32* @stdout
%95 = call i32 @fflush(i32 %94)
br label %126
96: ; preds = %66
%97 = load i64, i64* %14
%98 = icmp sgt i64 %97, 0
br i1 %98, label %99, label %125
99: ; preds = %96
%100 = load i32*, i32** %10
%101 = load i32, i32* %100
%102 = icmp eq i32 %101, 1
br i1 %102, label %103, label %105
103: ; preds = %99
%104 = call i32 @exit(i32 0)
unreachable
105: ; preds = %99
%106 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%107 = call i32 @bzero(i8* %106, i32 512)
%108 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%109 = load i32, i32* @stdin
%110 = call i32 @fgets(i8* %108, i32 512, i32 %109)
%111 = load i32, i32* %6
%112 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%113 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%114 = call i32 @strlen(i8* %113)
%115 = call i32 @write(i32 %111, i8* %112, i32 %114)
store i32 %115, i32* %13
%116 = load i32, i32* %13
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %105
%119 = load i32, i32* %6
%120 = call i32 @close(i32 %119)
%121 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %122
122: ; preds = %118, %105
%123 = load i32, i32* @stdout
%124 = call i32 @fflush(i32 %123)
br label %125
125: ; preds = %122, %96
br label %126
126: ; preds = %125, %93
br label %127
127: ; preds = %126
br label %61
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str = [10 x i8] c"localhost\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@.str.2 = [17 x i8] c"ERROR connecting\00"
@.str.3 = [7 x i8] c"fork()\00"
@.str.4 = [26 x i8] c"ERROR reading from socket\00"
@.str.5 = [25 x i8] c"Logged out successfully.\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@stdout = global i32 0
@stdin = global i32 0
@.str.8 = [24 x i8] c"ERROR writing to socket\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca %struct.sockaddr_in
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @PROT_READ
%9 = load i32, i32* @PROT_WRITE
%10 = or i32 %9, %8
%11 = load i32, i32* @MAP_SHARED
%12 = load i32, i32* @MAP_ANONYMOUS
%13 = or i32 %12, %11
%14 = tail call i32* @mmap(i32* null, i32 8, i32 %10, i32 %13, i32 -1, i32 0)
%15 = bitcast %struct.sockaddr_in* %5 to i8*
%16 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = tail call i32 @close(i32 %19)
%23 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %2
%25 = call i32 @bzero(i8* %15, i32 12)
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 1
%29 = load i64, i64* %28
%30 = inttoptr i64 %29 to i8*
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
%32 = bitcast i32* %31 to i8*
%33 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 0
%34 = load i32, i32* %33
%35 = tail call i32 @htons(i32 7158)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %35, i32* %36
%37 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%38 = call i64 @connect(i32 %19, %struct.sockaddr* %37, i32 12)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %24
%41 = call i32 @close(i32 %19)
%42 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %40, %24
%44 = call i64 (...) @fork()
%45 = icmp slt i64 %44, 0
%46 = icmp eq i64 %44, 0
br label %47
47: ; preds = %86, %43
br i1 %45, label %48, label %50
48: ; preds = %47
%49 = call i32 @error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %86
50: ; preds = %47
br i1 %46, label %51, label %68
51: ; preds = %50
%52 = call i32 @bzero(i8* %7, i32 512)
%53 = call i32 @read(i32 %19, i8* %7, i32 512)
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = call i32 @close(i32 %19)
%57 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %55, %51
%59 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 24)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %7)
store i32 1, i32* %14
%63 = call i32 @exit(i32 0)
unreachable
64: ; preds = %58
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%66 = load i32, i32* @stdout
%67 = call i32 @fflush(i32 %66)
br label %86
68: ; preds = %50
%69 = load i32, i32* %14
%70 = icmp eq i32 %69, 1
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = call i32 @exit(i32 0)
unreachable
73: ; preds = %68
%74 = call i32 @bzero(i8* %6, i32 512)
%75 = load i32, i32* @stdin
%76 = call i32 @fgets(i8* %6, i32 512, i32 %75)
%77 = call i32 @strlen(i8* %6)
%78 = call i32 @write(i32 %19, i8* %6, i32 %77)
%79 = icmp slt i32 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %73
%81 = call i32 @close(i32 %19)
%82 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %83
83: ; preds = %80, %73
%84 = load i32, i32* @stdout
%85 = call i32 @fflush(i32 %84)
br label %86
86: ; preds = %83, %64, %48
br label %47
}