#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;
};
typedef int /*<<< orphan*/ ret;
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_server_error(int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int sockfd;
  int len;
  struct sockaddr_in address;
  int ret;
  const int LINE_LEN = 512;
  char line[LINE_LEN];
  if (argc < 4)
    return EXIT_FAILURE;
  sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = inet_addr(argv[1]);
  address.sin_port = htons(2220);
  len = sizeof(address);
  ret = connect(sockfd, (struct sockaddr *)&address, len);
  if (ret == -1) {
    perror("Unable to connect to server");
    exit(1);
  }
  if (strcmp(argv[2], "-a") == 0) {
    sprintf(line, "A%s\na", argv[3]);
  } else if (strcmp(argv[2], "-d") == 0) {
    sprintf(line, "A%s\nd", argv[3]);
  } else if (strcmp(argv[2], "-c") == 0) {
    if (argc < 5) {
      close(sockfd);
      return EXIT_FAILURE;
    }
    sprintf(line, "A%s\nc%s", argv[3], argv[4]);
  } else if (strcmp(argv[2], "-l") == 0) {
    sprintf(line, "A%s\nl", argv[3]);
  } else if (strcmp(argv[2], "-s") == 0) {
    sprintf(line, "A%s\ns", argv[3]);
  } else {
    close(sockfd);
    return EXIT_FAILURE;
  }
  write(sockfd, line, strlen(line));
  read(sockfd, &ret, sizeof(ret));
  printf("result from server = %d\n", ret);
  print_server_error(ret);
  while ((len = read(sockfd, line, LINE_LEN)) > 0) {
    line[len] = 0;
    printf("%s", line);
  };
  close(sockfd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x200,-0x30(%rbp)
mov    %rsp,%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1229 <main+0x49>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1500 <main+0x320>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
mov    0x2d9e(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    $0x8ac,%edi
call   1060 <htons@plt>
mov    %eax,-0x28(%rbp)
movl   $0xc,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   10f0 <connect@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    12ae <main+0xce>
lea    0xd61(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd5f(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    12ee <main+0x10e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    -0x240(%rbp),%rdi
lea    0xd3d(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1454 <main+0x274>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd28(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    132e <main+0x14e>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    -0x240(%rbp),%rdi
lea    0xd06(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    144f <main+0x26f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcf1(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    13a0 <main+0x1c0>
cmpl   $0x5,-0x8(%rbp)
jge    1376 <main+0x196>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1500 <main+0x320>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rcx
lea    -0x240(%rbp),%rdi
lea    0xc9d(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    144a <main+0x26a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc8a(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    13e0 <main+0x200>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    -0x240(%rbp),%rdi
lea    0xc68(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1445 <main+0x265>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xc53(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    1420 <main+0x240>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    -0x240(%rbp),%rdi
lea    0xc31(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1440 <main+0x260>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    0x2b99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    1500 <main+0x320>
jmp    1445 <main+0x265>
jmp    144a <main+0x26a>
jmp    144f <main+0x26f>
jmp    1454 <main+0x274>
mov    -0x14(%rbp),%eax
mov    %eax,-0x244(%rbp)
lea    -0x240(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x244(%rbp),%edi
mov    %eax,%edx
lea    -0x240(%rbp),%rsi
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1090 <read@plt>
mov    -0x2c(%rbp),%esi
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1040 <print_server_error@plt>
mov    -0x14(%rbp),%edi
lea    -0x240(%rbp),%rsi
mov    $0x200,%edx
mov    $0x0,%al
call   1090 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    14f1 <main+0x311>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x240(%rbp,%rax,1)
lea    0xb58(%rip),%rdi
lea    -0x240(%rbp),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14a9 <main+0x2c9>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x220,%rsp
mov    %rsp,%r15
cmp    $0x4,%edi
jl     12f6 <main+0x116>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2de1(%rip),%r12
mov    (%r12),%edi
mov    0x2dbe(%rip),%rax
mov    (%rax),%esi
mov    0x2dc5(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
mov    %eax,%r14d
mov    (%r12),%eax
mov    %eax,0x18(%rsp)
mov    0x8(%rbx),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0x8ac,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   10f0 <connect@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     1312 <main+0x132>
mov    0x10(%rbx),%rdi
lea    0xdaa(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1328 <main+0x148>
mov    0x10(%rbx),%rdi
lea    0xd9a(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1335 <main+0x155>
mov    0x10(%rbx),%rdi
lea    0xd8a(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12e5 <main+0x105>
mov    0x10(%rbx),%rdi
lea    0xd80(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1342 <main+0x162>
mov    0x10(%rbx),%rdi
lea    0xd74(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    12ee <main+0x10e>
mov    0x18(%rbx),%rdx
lea    0xd62(%rip),%rsi
jmp    134d <main+0x16d>
cmp    $0x5,%ebp
jae    1409 <main+0x229>
mov    %r14d,%edi
call   1080 <close@plt>
mov    %r15,%rsp
mov    0x2cc8(%rip),%rax
mov    (%rax),%eax
add    $0x220,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xce7(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x18(%rbx),%rdx
lea    0xcec(%rip),%rsi
jmp    134d <main+0x16d>
mov    0x18(%rbx),%rdx
lea    0xce8(%rip),%rsi
jmp    134d <main+0x16d>
mov    0x18(%rbx),%rdx
lea    0xcef(%rip),%rsi
lea    0x20(%rsp),%rdi
xor    %eax,%eax
call   10d0 <sprintf@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1090 <read@plt>
mov    0xc(%rsp),%esi
lea    0xcb9(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%edi
call   1040 <print_server_error@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
xor    %eax,%eax
call   1090 <read@plt>
test   %eax,%eax
jle    13fa <main+0x21a>
lea    0xc77(%rip),%rbx
lea    0x20(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%eax
movb   $0x0,0x20(%rsp,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x200,%edx
xor    %eax,%eax
call   1090 <read@plt>
test   %eax,%eax
jg     13d0 <main+0x1f0>
mov    %r14d,%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    0x18(%rbx),%rdx
mov    0x20(%rbx),%rcx
lea    0xc19(%rip),%rsi
lea    0x20(%rsp),%rdi
xor    %eax,%eax
call   10d0 <sprintf@plt>
jmp    1359 <main+0x179>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [28 x i8] c"Unable to connect to server\00"
@.str.1 = [3 x i8] c"-a\00"
@.str.2 = [6 x i8] c"A%s\0Aa\00"
@.str.3 = [3 x i8] c"-d\00"
@.str.4 = [6 x i8] c"A%s\0Ad\00"
@.str.5 = [3 x i8] c"-c\00"
@.str.6 = [8 x i8] c"A%s\0Ac%s\00"
@.str.7 = [3 x i8] c"-l\00"
@.str.8 = [6 x i8] c"A%s\0Al\00"
@.str.9 = [3 x i8] c"-s\00"
@.str.10 = [6 x i8] c"A%s\0As\00"
@.str.11 = [25 x i8] c"result from server = %d\0A\00"
@.str.12 = [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 %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 512, i32* %10
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %11
%14 = alloca i8, i64 512
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
store i32 1, i32* %12
br label %139
19: ; preds = %2
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_STREAM
%22 = load i32, i32* @IPPROTO_TCP
%23 = call i32 @socket(i32 %20, i32 %21, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %24, i32* %25
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @inet_addr(i8* %28)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
store i32 %29, i32* %31
%32 = call i32 @htons(i32 2220)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %32, i32* %33
store i32 12, i32* %7
%34 = load i32, i32* %6
%35 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%36 = load i32, i32* %7
%37 = call i32 @connect(i32 %34, %struct.sockaddr* %35, i32 %36)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %43
40: ; preds = %19
%41 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %19
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 2
%46 = load i8*, i8** %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 3
%52 = load i8*, i8** %51
%53 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %116
54: ; preds = %43
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %63)
br label %115
65: ; preds = %54
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 2
%68 = load i8*, i8** %67
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %86
71: ; preds = %65
%72 = load i32, i32* %4
%73 = icmp slt i32 %72, 5
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = load i32, i32* %6
%76 = call i32 @close(i32 %75)
%77 = load i32, i32* @EXIT_FAILURE
store i32 %77, i32* %3
store i32 1, i32* %12
br label %139
78: ; preds = %71
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 3
%81 = load i8*, i8** %80
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 4
%84 = load i8*, i8** %83
%85 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %81, i8* %84)
br label %114
86: ; preds = %65
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 2
%89 = load i8*, i8** %88
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %92, label %97
92: ; preds = %86
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 3
%95 = load i8*, i8** %94
%96 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %95)
br label %113
97: ; preds = %86
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 2
%100 = load i8*, i8** %99
%101 = call i64 @strcmp(i8* %100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%102 = icmp eq i64 %101, 0
br i1 %102, label %103, label %108
103: ; preds = %97
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 3
%106 = load i8*, i8** %105
%107 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %106)
br label %112
108: ; preds = %97
%109 = load i32, i32* %6
%110 = call i32 @close(i32 %109)
%111 = load i32, i32* @EXIT_FAILURE
store i32 %111, i32* %3
store i32 1, i32* %12
br label %139
112: ; preds = %103
br label %113
113: ; preds = %112, %92
br label %114
114: ; preds = %113, %78
br label %115
115: ; preds = %114, %60
br label %116
116: ; preds = %115, %49
%117 = load i32, i32* %6
%118 = call i32 @strlen(i8* %14)
%119 = call i32 @write(i32 %117, i8* %14, i32 %118)
%120 = load i32, i32* %6
%121 = call i32 (i32, ...) @read(i32 %120, i32* %9, i64 4)
%122 = load i32, i32* %9
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i32 %122)
%124 = load i32, i32* %9
%125 = call i32 @print_server_error(i32 %124)
br label %126
126: ; preds = %130, %116
%127 = load i32, i32* %6
%128 = call i32 (i32, ...) @read(i32 %127, i8* %14, i32 512)
store i32 %128, i32* %7
%129 = icmp sgt i32 %128, 0
br i1 %129, label %130, label %135
130: ; preds = %126
%131 = load i32, i32* %7
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8, i8* %14, i64 %132
store i8 0, i8* %133
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %14)
br label %126
135: ; preds = %126
%136 = load i32, i32* %6
%137 = call i32 @close(i32 %136)
%138 = call i32 @exit(i32 0)
unreachable
139: ; preds = %108, %74, %17
%140 = load i8*, i8** %11
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [28 x i8] c"Unable to connect to server\00"
@.str.1 = [3 x i8] c"-a\00"
@.str.2 = [6 x i8] c"A%s\0Aa\00"
@.str.3 = [3 x i8] c"-d\00"
@.str.4 = [6 x i8] c"A%s\0Ad\00"
@.str.5 = [3 x i8] c"-c\00"
@.str.6 = [8 x i8] c"A%s\0Ac%s\00"
@.str.7 = [3 x i8] c"-l\00"
@.str.8 = [6 x i8] c"A%s\0Al\00"
@.str.9 = [3 x i8] c"-s\00"
@.str.10 = [6 x i8] c"A%s\0As\00"
@.str.11 = [25 x i8] c"result from server = %d\0A\00"
@.str.12 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i8* @llvm.stacksave()
%8 = alloca [512 x i8]
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%10 = icmp slt i32 %0, 4
br i1 %10, label %97, label %11
11: ; preds = %2
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = load i32, i32* @IPPROTO_TCP
%15 = tail call i32 @socket(i32 %12, i32 %13, i32 %14)
%16 = load i32, i32* @AF_INET
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %16, i32* %17
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @inet_addr(i8* %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %20, i32* %21
%22 = tail call i32 @htons(i32 2220)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %22, i32* %23
%24 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%25 = call i32 @connect(i32 %15, %struct.sockaddr* %24, i32 12)
store i32 %25, i32* %4
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %11
%28 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %11
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = getelementptr inbounds i8*, i8** %1, i64 3
%37 = load i8*, i8** %36
%38 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %75
39: ; preds = %30
%40 = load i8*, i8** %31
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = getelementptr inbounds i8*, i8** %1, i64 3
%45 = load i8*, i8** %44
%46 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %75
47: ; preds = %39
%48 = load i8*, i8** %31
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %47
%52 = icmp ult i32 %0, 5
br i1 %52, label %95, label %53
53: ; preds = %51
%54 = getelementptr inbounds i8*, i8** %1, i64 3
%55 = load i8*, i8** %54
%56 = getelementptr inbounds i8*, i8** %1, i64 4
%57 = load i8*, i8** %56
%58 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %55, i8* %57)
br label %75
59: ; preds = %47
%60 = load i8*, i8** %31
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = getelementptr inbounds i8*, i8** %1, i64 3
%65 = load i8*, i8** %64
%66 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %65)
br label %75
67: ; preds = %59
%68 = load i8*, i8** %31
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %95
71: ; preds = %67
%72 = getelementptr inbounds i8*, i8** %1, i64 3
%73 = load i8*, i8** %72
%74 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %73)
br label %75
75: ; preds = %43, %63, %71, %53, %35
%76 = call i32 @strlen(i8* %9)
%77 = call i32 @write(i32 %15, i8* %9, i32 %76)
%78 = call i32 (i32, ...) @read(i32 %15, i32* %4, i64 4)
%79 = load i32, i32* %4
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i32 %79)
%81 = load i32, i32* %4
%82 = call i32 @print_server_error(i32 %81)
%83 = call i32 (i32, ...) @read(i32 %15, i8* %9, i32 512)
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %92
85: ; preds = %75, %85
%86 = phi i32 [ %90, %85 ], [ %83, %75 ]
%87 = zext i32 %86 to i64
%88 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 %87
store i8 0, i8* %88
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %9)
%90 = call i32 (i32, ...) @read(i32 %15, i8* %9, i32 512)
%91 = icmp sgt i32 %90, 0
br i1 %91, label %85, label %92
92: ; preds = %85, %75
%93 = call i32 @close(i32 %15)
%94 = call i32 @exit(i32 0)
unreachable
95: ; preds = %67, %51
%96 = call i32 @close(i32 %15)
br label %97
97: ; preds = %95, %2
%98 = load i32, i32* @EXIT_FAILURE
ret i32 %98
}