#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 /*<<< orphan*/ server_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_aton(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int sockfd, portnum, n;
  struct sockaddr_in server_addr;
  char inputbuf[256];
  if (argc < 3) {
    fprintf(stderr, "usage %s <server-ip-addr> <server-port>\n", argv[0]);
    exit(0);
  }
  portnum = atoi(argv[2]);
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0) {
    fprintf(stderr, "ERROR opening socket\n");
    exit(1);
  }
  bzero((char *)&server_addr, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  if (!inet_aton(argv[1], &server_addr.sin_addr)) {
    fprintf(stderr, "ERROR invalid server IP address\n");
    exit(1);
  }
  server_addr.sin_port = htons(portnum);
  if (connect(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) <
      0) {
    fprintf(stderr, "ERROR connecting\n");
    exit(1);
  }
  printf("Connected to server\n");
  do {
    printf("Please enter the message to the server: ");
    bzero(inputbuf, 256);
    fgets(inputbuf, 256 - 1, stdin);
    n = write(sockfd, inputbuf, strlen(inputbuf));
    if (n < 0) {
      fprintf(stderr, "ERROR writing to socket\n");
      exit(1);
    }
    bzero(inputbuf, 256);
    n = read(sockfd, inputbuf, (256 - 1));
    if (n < 0) {
      fprintf(stderr, "ERROR reading from socket\n");
      exit(1);
    }
    printf("Server replied: %s\n", inputbuf);
    if (!((inputbuf[0] == 'G' && inputbuf[1] == 'o' && inputbuf[2] == 'o' &&
           inputbuf[3] == 'd' && inputbuf[4] == 'b' && inputbuf[5] == 'y' &&
           inputbuf[6] == 'e') ||
          (inputbuf[0] == 'O' && inputbuf[1] == 'K'))) {
      fprintf(stderr, "ERROR wrong reply from server\n");
      exit(1);
    }
  } while (!(inputbuf[0] == 'G' && inputbuf[1] == 'o' && inputbuf[2] == 'o' &&
             inputbuf[3] == 'd' && inputbuf[4] == 'b' && inputbuf[5] == 'y' &&
             inputbuf[6] == 'e'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1218 <main+0x48>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    126f <main+0x9f>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10b0 <bzero@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
call   10a0 <inet_aton@plt>
cmp    $0x0,%eax
jne    12c8 <main+0xf8>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
lea    0xd88(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <connect@plt>
cmp    $0x0,%rax
jge    130f <main+0x13f>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   10b0 <bzero@plt>
lea    -0x130(%rbp),%rdi
mov    0x2c96(%rip),%rax
mov    (%rax),%edx
mov    $0xff,%esi
call   1080 <fgets@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x13c(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x130(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x13c(%rbp),%edi
mov    -0x138(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13bb <main+0x1eb>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x130(%rbp),%rdi
mov    $0x100,%esi
call   10b0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0xff,%edx
call   1070 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    140e <main+0x23e>
mov    0x2bdc(%rip),%rax
mov    (%rax),%edi
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    -0x130(%rbp),%rsi
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x130(%rbp),%eax
cmp    $0x47,%eax
jne    1493 <main+0x2c3>
movsbl -0x12f(%rbp),%eax
cmp    $0x6f,%eax
jne    1493 <main+0x2c3>
movsbl -0x12e(%rbp),%eax
cmp    $0x6f,%eax
jne    1493 <main+0x2c3>
movsbl -0x12d(%rbp),%eax
cmp    $0x64,%eax
jne    1493 <main+0x2c3>
movsbl -0x12c(%rbp),%eax
cmp    $0x62,%eax
jne    1493 <main+0x2c3>
movsbl -0x12b(%rbp),%eax
cmp    $0x79,%eax
jne    1493 <main+0x2c3>
movsbl -0x12a(%rbp),%eax
cmp    $0x65,%eax
je     14d4 <main+0x304>
movsbl -0x130(%rbp),%eax
cmp    $0x4f,%eax
jne    14b3 <main+0x2e3>
movsbl -0x12f(%rbp),%eax
cmp    $0x4b,%eax
je     14d4 <main+0x304>
mov    0x2b16(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    14d9 <main+0x309>
movsbl -0x130(%rbp),%ecx
xor    %eax,%eax
cmp    $0x47,%ecx
mov    %al,-0x13d(%rbp)
jne    157c <main+0x3ac>
movsbl -0x12f(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6f,%ecx
mov    %al,-0x13d(%rbp)
jne    157c <main+0x3ac>
movsbl -0x12e(%rbp),%ecx
xor    %eax,%eax
cmp    $0x6f,%ecx
mov    %al,-0x13d(%rbp)
jne    157c <main+0x3ac>
movsbl -0x12d(%rbp),%ecx
xor    %eax,%eax
cmp    $0x64,%ecx
mov    %al,-0x13d(%rbp)
jne    157c <main+0x3ac>
movsbl -0x12c(%rbp),%ecx
xor    %eax,%eax
cmp    $0x62,%ecx
mov    %al,-0x13d(%rbp)
jne    157c <main+0x3ac>
movsbl -0x12b(%rbp),%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x13d(%rbp)
jne    157c <main+0x3ac>
movsbl -0x12a(%rbp),%eax
cmp    $0x65,%eax
sete   %al
mov    %al,-0x13d(%rbp)
mov    -0x13d(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    131d <main+0x14d>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x120,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    13aa <main+0x1ca>
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    0x2dda(%rip),%r15
mov    (%r15),%edi
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
js     13cb <main+0x1eb>
mov    %eax,%ebp
mov    %rsp,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rdi
lea    0x4(%rsp),%rsi
call   10b0 <inet_aton@plt>
test   %eax,%eax
je     13dd <main+0x1fd>
mov    %r14d,%edi
call   1060 <htons@plt>
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %rax,%rax
js     13ef <main+0x20f>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xde7(%rip),%r14
lea    0x20(%rsp),%rbx
mov    0x2d49(%rip),%r12
lea    0xe31(%rip),%r15
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1090 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
js     1377 <main+0x197>
mov    %rbx,%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1080 <read@plt>
test   %eax,%eax
js     1389 <main+0x1a9>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movdqa 0x20(%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x646f6f47,%eax
jne    133b <main+0x15b>
cmpb   $0x62,0x24(%rsp)
jne    133b <main+0x15b>
cmpb   $0x79,0x25(%rsp)
jne    133b <main+0x15b>
cmpb   $0x65,0x26(%rsp)
je     1365 <main+0x185>
movdqa %xmm0,0x10(%rsp)
cmpb   $0x4f,0x10(%rsp)
jne    1353 <main+0x173>
cmpb   $0x4b,0x11(%rsp)
je     12a0 <main+0xc0>
mov    0x2c76(%rip),%rax
mov    (%rax),%edi
lea    0xd80(%rip),%rsi
jmp    1399 <main+0x1b9>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
lea    0xd14(%rip),%rsi
jmp    1399 <main+0x1b9>
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2c1f(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc43(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
lea    0xc4e(%rip),%rsi
jmp    1399 <main+0x1b9>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
lea    0xc52(%rip),%rsi
jmp    1399 <main+0x1b9>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
lea    0xc61(%rip),%rsi
jmp    1399 <main+0x1b9>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [41 x i8] c"usage %s <server-ip-addr> <server-port>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [22 x i8] c"ERROR opening socket\0A\00"
@.str.2 = [33 x i8] c"ERROR invalid server IP address\0A\00"
@.str.3 = [18 x i8] c"ERROR connecting\0A\00"
@.str.4 = [21 x i8] c"Connected to server\0A\00"
@.str.5 = [41 x i8] c"Please enter the message to the server: \00"
@stdin = global i32 0
@.str.6 = [25 x i8] c"ERROR writing to socket\0A\00"
@.str.7 = [27 x i8] c"ERROR reading from socket\0A\00"
@.str.8 = [20 x i8] c"Server replied: %s\0A\00"
@.str.9 = [31 x i8] c"ERROR wrong reply from server\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 %struct.sockaddr_in
%10 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %20
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %20
%35 = bitcast %struct.sockaddr_in* %9 to i8*
%36 = call i32 @bzero(i8* %35, i32 12)
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %37, i32* %38
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%43 = call i32 @inet_aton(i8* %41, i32* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %34
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %34
%50 = load i32, i32* %7
%51 = call i32 @htons(i32 %50)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %51, i32* %52
%53 = load i32, i32* %6
%54 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%55 = call i64 @connect(i32 %53, %struct.sockaddr* %54, i32 12)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %49
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %49
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %63
63: ; preds = %180, %61
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%66 = call i32 @bzero(i8* %65, i32 256)
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%68 = load i32, i32* @stdin
%69 = call i32 @fgets(i8* %67, i32 255, i32 %68)
%70 = load i32, i32* %6
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%73 = call i32 @strlen(i8* %72)
%74 = call i32 @write(i32 %70, i8* %71, i32 %73)
store i32 %74, i32* %8
%75 = load i32, i32* %8
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %63
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %63
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%83 = call i32 @bzero(i8* %82, i32 256)
%84 = load i32, i32* %6
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%86 = call i32 @read(i32 %84, i8* %85, i32 255)
store i32 %86, i32* %8
%87 = load i32, i32* %8
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %81
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %81
%94 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %94)
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 71
br i1 %99, label %100, label %130
100: ; preds = %93
%101 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 1
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 111
br i1 %104, label %105, label %130
105: ; preds = %100
%106 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 2
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %108, 111
br i1 %109, label %110, label %130
110: ; preds = %105
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 3
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 100
br i1 %114, label %115, label %130
115: ; preds = %110
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 4
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = icmp eq i32 %118, 98
br i1 %119, label %120, label %130
120: ; preds = %115
%121 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 5
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = icmp eq i32 %123, 121
br i1 %124, label %125, label %130
125: ; preds = %120
%126 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 6
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp eq i32 %128, 101
br i1 %129, label %144, label %130
130: ; preds = %125, %120, %115, %110, %105, %100, %93
%131 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 79
br i1 %134, label %135, label %140
135: ; preds = %130
%136 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 1
%137 = load i8, i8* %136
%138 = sext i8 %137 to i32
%139 = icmp eq i32 %138, 75
br i1 %139, label %144, label %140
140: ; preds = %135, %130
%141 = load i32, i32* @stderr
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%143 = call i32 @exit(i32 1)
unreachable
144: ; preds = %135, %125
br label %145
145: ; preds = %144
%146 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = icmp eq i32 %148, 71
br i1 %149, label %150, label %180
150: ; preds = %145
%151 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 1
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = icmp eq i32 %153, 111
br i1 %154, label %155, label %180
155: ; preds = %150
%156 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 2
%157 = load i8, i8* %156
%158 = sext i8 %157 to i32
%159 = icmp eq i32 %158, 111
br i1 %159, label %160, label %180
160: ; preds = %155
%161 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 3
%162 = load i8, i8* %161
%163 = sext i8 %162 to i32
%164 = icmp eq i32 %163, 100
br i1 %164, label %165, label %180
165: ; preds = %160
%166 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 4
%167 = load i8, i8* %166
%168 = sext i8 %167 to i32
%169 = icmp eq i32 %168, 98
br i1 %169, label %170, label %180
170: ; preds = %165
%171 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 5
%172 = load i8, i8* %171
%173 = sext i8 %172 to i32
%174 = icmp eq i32 %173, 121
br i1 %174, label %175, label %180
175: ; preds = %170
%176 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 6
%177 = load i8, i8* %176
%178 = sext i8 %177 to i32
%179 = icmp eq i32 %178, 101
br label %180
180: ; preds = %175, %170, %165, %160, %155, %150, %145
%181 = phi i1 [ false, %170 ], [ false, %165 ], [ false, %160 ], [ false, %155 ], [ false, %150 ], [ false, %145 ], [ %179, %175 ]
%182 = xor i1 %181, true
br i1 %182, label %63, label %183
183: ; preds = %180
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [41 x i8] c"usage %s <server-ip-addr> <server-port>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [22 x i8] c"ERROR opening socket\0A\00"
@.str.2 = [33 x i8] c"ERROR invalid server IP address\0A\00"
@.str.3 = [18 x i8] c"ERROR connecting\0A\00"
@.str.5 = [41 x i8] c"Please enter the message to the server: \00"
@stdin = global i32 0
@.str.6 = [25 x i8] c"ERROR writing to socket\0A\00"
@.str.7 = [27 x i8] c"ERROR reading from socket\0A\00"
@.str.8 = [20 x i8] c"Server replied: %s\0A\00"
@.str.9 = [31 x i8] c"ERROR wrong reply from server\0A\00"
@str = [20 x i8] c"Connected to server\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%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 %25
21: ; preds = %13
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %13
%26 = call i32 @bzero(i8* %5, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %27, i32* %28
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%32 = call i32 @inet_aton(i8* %30, i32* %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %25
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %25
%39 = call i32 @htons(i32 %16)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %39, i32* %40
%41 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%42 = call i64 @connect(i32 %19, %struct.sockaddr* %41, i32 12)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %38
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 4
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 5
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 6
%53 = bitcast [256 x i8]* %4 to <4 x i8>*
br label %54
54: ; preds = %89, %48
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @bzero(i8* %6, i32 256)
%57 = load i32, i32* @stdin
%58 = call i32 @fgets(i8* %6, i32 255, i32 %57)
%59 = call i32 @strlen(i8* %6)
%60 = call i32 @write(i32 %19, i8* %6, i32 %59)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %54
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %54
%67 = call i32 @bzero(i8* %6, i32 256)
%68 = call i32 @read(i32 %19, i8* %6, i32 255)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %66
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%76 = load <4 x i8>, <4 x i8>* %53
%77 = freeze <4 x i8> %76
%78 = bitcast <4 x i8> %77 to i32
%79 = icmp eq i32 %78, 1685024583
%80 = load i8, i8* %50
%81 = icmp eq i8 %80, 98
%82 = select i1 %79, i1 %81, i1 false
%83 = load i8, i8* %51
%84 = icmp eq i8 %83, 121
%85 = select i1 %82, i1 %84, i1 false
%86 = load i8, i8* %52
%87 = icmp eq i8 %86, 101
%88 = select i1 %85, i1 %87, i1 false
br i1 %88, label %99, label %89
89: ; preds = %74
%90 = extractelement <4 x i8> %77, i64 0
%91 = icmp eq i8 %90, 79
%92 = extractelement <4 x i8> %77, i64 1
%93 = icmp eq i8 %92, 75
%94 = and i1 %91, %93
br i1 %94, label %54, label %95
95: ; preds = %89
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
%98 = call i32 @exit(i32 1)
unreachable
99: ; preds = %74
ret i32 0
}