#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 */
typedef int /*<<< orphan*/ uint16_t;
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 {
  scalar_t__ h_length;
  scalar_t__ h_addr_list;
};
typedef int /*<<< orphan*/ serv_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
char *calloc(int, int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, size_t);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
scalar_t__ write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sockfd, portno, n, len, flag;
  struct sockaddr_in serv_addr;
  struct hostent *server;
  char *buffer;
  buffer = calloc(256, sizeof(char));
  portno = 3002;
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  server = gethostbyname("localhost");
  if (server == NULL) {
    fprintf(stderr, "ERROR, no such host\n");
    exit(0);
  }
  memset((char *)&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  memcpy((char *)server->h_addr_list, (char *)&serv_addr.sin_addr.s_addr,
         (size_t)server->h_length);
  serv_addr.sin_port = htons((uint16_t)portno);
  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
    error("ERROR connecting");
  do {
    printf("Enter next command> ");
    flag = 0;
    memset(buffer, 0, 256);
    fgets(buffer, 255, stdin);
    if (strncmp(buffer, "get", 3) == 0)
      flag = 1;
    n = (int)write(sockfd, buffer, strlen(buffer));
    if (n < 0)
      error("ERROR writing to socket");
    memset(buffer, 0, 256);
    read(sockfd, buffer, 255);
    if (strcmp(buffer, "stop") == 0)
      break;
    len = atoi(buffer);
    memset(buffer, 0, 256);
    n = (int)read(sockfd, buffer, (size_t)len);
    if (n < 0)
      error("ERROR reading from socket");
    if (n != 0 && flag == 1)
      printf("%s\n", buffer);
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0xbba,-0x18(%rbp)
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1282 <main+0x62>
lea    0xd83(%rip),%rdi
call   1100 <error@plt>
lea    0xd8c(%rip),%rdi
call   10d0 <gethostbyname@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12b9 <main+0x99>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xd72(%rip),%rsi
call   10e0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
call   10f0 <memcpy@plt>
mov    -0x18(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0x0,%rax
jge    1323 <main+0x103>
lea    0xd16(%rip),%rdi
call   1100 <error@plt>
jmp    1328 <main+0x108>
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    0x2c88(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   10a0 <fgets@plt>
mov    -0x40(%rbp),%rdi
lea    0xceb(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    138a <main+0x16a>
movl   $0x1,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13c8 <main+0x1a8>
lea    0xc9b(%rip),%rdi
call   1100 <error@plt>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0xff,%edx
call   1090 <read@plt>
mov    -0x40(%rbp),%rdi
lea    0xc82(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1408 <main+0x1e8>
jmp    1487 <main+0x267>
mov    -0x40(%rbp),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x40(%rbp),%rsi
movslq -0x20(%rbp),%rdx
call   1090 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    144d <main+0x22d>
lea    0xc33(%rip),%rdi
call   1100 <error@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1473 <main+0x253>
cmpl   $0x1,-0x24(%rbp)
jne    1473 <main+0x253>
mov    -0x40(%rbp),%rsi
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1478 <main+0x258>
mov    $0x1,%al
test   $0x1,%al
jne    1328 <main+0x108>
jmp    1487 <main+0x267>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x100,%edi
mov    $0x1,%esi
call   10c0 <calloc@plt>
mov    %rax,%rbx
mov    0x2d91(%rip),%r12
mov    (%r12),%edi
mov    0x2d66(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    127e <main+0x4e>
lea    0xd87(%rip),%rdi
call   1110 <error@plt>
lea    0xd90(%rip),%rdi
call   10e0 <gethostbyname@plt>
test   %rax,%rax
je     140c <main+0x1dc>
mov    %rax,%r14
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    (%r12),%eax
mov    %eax,0x10(%rsp)
mov    (%r14),%rdx
mov    0x8(%r14),%rdi
lea    0xc(%rsp),%rsi
call   1100 <memcpy@plt>
mov    $0xbba,%edi
call   1070 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   1140 <connect@plt>
test   %rax,%rax
jns    12f2 <main+0xc2>
lea    0xd47(%rip),%rdi
call   1110 <error@plt>
lea    0xd7d(%rip),%r12
nopl   0x0(%rax)
lea    0xd3e(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   10b0 <fgets@plt>
mov    %rbx,%rdi
lea    0xd1d(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   $0x80000000,%eax
je     1372 <main+0x142>
lea    0xcf1(%rip),%rdi
call   1110 <error@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
mov    $0xff,%edx
mov    %r15d,%edi
mov    %rbx,%rsi
call   10a0 <read@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     13fb <main+0x1cb>
mov    %rbx,%rdi
call   1120 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1090 <memset@plt>
movslq %ebp,%rdx
mov    %r15d,%edi
mov    %rbx,%rsi
call   10a0 <read@plt>
mov    %rax,%r14
test   %r14d,%r14d
jns    13dc <main+0x1ac>
lea    0xca4(%rip),%rdi
call   1110 <error@plt>
test   %r14d,%r14d
je     1300 <main+0xd0>
test   %r13,%r13
jne    1300 <main+0xd0>
mov    %rbx,%rdi
call   1040 <puts@plt>
jmp    1300 <main+0xd0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bbd(%rip),%rax
mov    (%rax),%edi
lea    0xc03(%rip),%rsi
call   10f0 <fprintf@plt>
xor    %edi,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i64, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"ERROR opening socket\00"
@.str.1 = [10 x i8] c"localhost\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.3 = [17 x i8] c"ERROR connecting\00"
@.str.4 = [21 x i8] c"Enter next command> \00"
@stdin = global i32 0
@.str.5 = [4 x i8] c"get\00"
@.str.6 = [24 x i8] c"ERROR writing to socket\00"
@.str.7 = [5 x i8] c"stop\00"
@.str.8 = [26 x i8] c"ERROR reading from socket\00"
@.str.9 = [4 x i8] c"%s\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 %struct.sockaddr_in
%12 = alloca %struct.hostent*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i8* @calloc(i32 256, i32 1)
store i8* %14, i8** %13
store i32 3002, i32* %7
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i32 %15, i32 %16, i32 0)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
%23 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store %struct.hostent* %23, %struct.hostent** %12
%24 = load %struct.hostent*, %struct.hostent** %12
%25 = icmp eq %struct.hostent* %24, null
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %22
%31 = bitcast %struct.sockaddr_in* %11 to i8*
%32 = call i32 @memset(i8* %31, i32 0, i32 12)
%33 = load i32, i32* @AF_INET
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %33, i32* %34
%35 = load %struct.hostent*, %struct.hostent** %12
%36 = getelementptr inbounds %struct.hostent, %struct.hostent* %35, i32 0, i32 1
%37 = load i64, i64* %36
%38 = inttoptr i64 %37 to i8*
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %39, i32 0, i32 0
%41 = bitcast i32* %40 to i8*
%42 = load %struct.hostent*, %struct.hostent** %12
%43 = getelementptr inbounds %struct.hostent, %struct.hostent* %42, i32 0, i32 0
%44 = load i64, i64* %43
%45 = call i32 @memcpy(i8* %38, i8* %41, i64 %44)
%46 = load i32, i32* %7
%47 = call i32 @htons(i32 %46)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %47, i32* %48
%49 = load i32, i32* %6
%50 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%51 = call i64 @connect(i32 %49, %struct.sockaddr* %50, i32 12)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %30
%54 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %30
br label %56
56: ; preds = %113, %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %10
%58 = load i8*, i8** %13
%59 = call i32 @memset(i8* %58, i32 0, i32 256)
%60 = load i8*, i8** %13
%61 = load i32, i32* @stdin
%62 = call i32 @fgets(i8* %60, i32 255, i32 %61)
%63 = load i8*, i8** %13
%64 = call i64 @strncmp(i8* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %56
store i32 1, i32* %10
br label %67
67: ; preds = %66, %56
%68 = load i32, i32* %6
%69 = load i8*, i8** %13
%70 = load i8*, i8** %13
%71 = call i32 @strlen(i8* %70)
%72 = call i64 @write(i32 %68, i8* %69, i32 %71)
%73 = trunc i64 %72 to i32
store i32 %73, i32* %8
%74 = load i32, i32* %8
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %67
%77 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %78
78: ; preds = %76, %67
%79 = load i8*, i8** %13
%80 = call i32 @memset(i8* %79, i32 0, i32 256)
%81 = load i32, i32* %6
%82 = load i8*, i8** %13
%83 = call i64 @read(i32 %81, i8* %82, i64 255)
%84 = load i8*, i8** %13
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %78
br label %114
88: ; preds = %78
%89 = load i8*, i8** %13
%90 = call i32 @atoi(i8* %89)
store i32 %90, i32* %9
%91 = load i8*, i8** %13
%92 = call i32 @memset(i8* %91, i32 0, i32 256)
%93 = load i32, i32* %6
%94 = load i8*, i8** %13
%95 = load i32, i32* %9
%96 = sext i32 %95 to i64
%97 = call i64 @read(i32 %93, i8* %94, i64 %96)
%98 = trunc i64 %97 to i32
store i32 %98, i32* %8
%99 = load i32, i32* %8
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %88
%102 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %103
103: ; preds = %101, %88
%104 = load i32, i32* %8
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %112
106: ; preds = %103
%107 = load i32, i32* %10
%108 = icmp eq i32 %107, 1
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i8*, i8** %13
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %109, %106, %103
br label %113
113: ; preds = %112
br i1 true, label %56, label %114
114: ; preds = %113, %87
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i64, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [21 x i8] c"ERROR opening socket\00"
@.str.1 = [10 x i8] c"localhost\00"
@stderr = global i32 0
@.str.2 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.3 = [17 x i8] c"ERROR connecting\00"
@.str.4 = [21 x i8] c"Enter next command> \00"
@stdin = global i32 0
@.str.5 = [4 x i8] c"get\00"
@.str.6 = [24 x i8] c"ERROR writing to socket\00"
@.str.7 = [5 x i8] c"stop\00"
@.str.8 = [26 x i8] c"ERROR reading from socket\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = tail call dereferenceable_or_null(256) i8* @calloc(i32 256, i32 1)
%6 = load i32, i32* @AF_INET
%7 = load i32, i32* @SOCK_STREAM
%8 = tail call i32 @socket(i32 %6, i32 %7, i32 0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq %struct.hostent* %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %12
%20 = call i32 @memset(i8* %4, i32 0, i32 12)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i64 0, i32 1
%24 = load i64, i64* %23
%25 = inttoptr i64 %24 to i8*
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%27 = bitcast i32* %26 to i8*
%28 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i64 0, i32 0
%29 = load i64, i64* %28
%30 = call i32 @memcpy(i8* %25, i8* %27, i64 %29)
%31 = call i32 @htons(i32 3002)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %31, i32* %32
%33 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%34 = call i64 @connect(i32 %8, %struct.sockaddr* %33, i32 12)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %19
%37 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %36, %19
br label %39
39: ; preds = %69, %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 @memset(i8* %5, i32 0, i32 256)
%42 = load i32, i32* @stdin
%43 = call i32 @fgets(i8* %5, i32 255, i32 %42)
%44 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%45 = icmp eq i64 %44, 0
%46 = call i32 @strlen(i8* %5)
%47 = call i64 @write(i32 %8, i8* %5, i32 %46)
%48 = and i64 %47, 2147483648
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %39
%51 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %52
52: ; preds = %50, %39
%53 = call i32 @memset(i8* %5, i32 0, i32 256)
%54 = call i64 @read(i32 %8, i8* %5, i64 255)
%55 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %72, label %57
57: ; preds = %52
%58 = call i32 @atoi(i8* %5)
%59 = call i32 @memset(i8* %5, i32 0, i32 256)
%60 = sext i32 %58 to i64
%61 = call i64 @read(i32 %8, i8* %5, i64 %60)
%62 = trunc i64 %61 to i32
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %66
66: ; preds = %64, %57
%67 = icmp ne i32 %62, 0
%68 = select i1 %67, i1 %45, i1 false
br i1 %68, label %70, label %69
69: ; preds = %66, %70
br label %39
70: ; preds = %66
%71 = call i32 @puts(i8* dereferenceable(1) %5)
br label %69
72: ; preds = %52
ret i32 0
}