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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int const, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(char *, char, int const);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int const);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int const);
int main(int argc, char **argv) {
  const int BUF_SIZE = 255, GREETING_SIZE = 50, NAME_SIZE = 20;
  int client_len;
  int client_sockfd;
  char buf_in[BUF_SIZE];
  char buf_get[BUF_SIZE];
  char name[NAME_SIZE];
  char greeting[GREETING_SIZE];
  char *automatic;
  struct sockaddr_in clientaddr;
  if (argc != 3) {
    printf("Usage : ./client {{ip}} {{port}}\n");
    printf("Example    : ./client 127.0.0.1 4444\n");
    exit(0);
  }
  client_sockfd = socket(AF_INET, SOCK_STREAM, 0);
  clientaddr.sin_family = AF_INET;
  clientaddr.sin_addr.s_addr = inet_addr(argv[1]);
  clientaddr.sin_port = htons(atoi(argv[2]));
  client_len = sizeof(clientaddr);
  if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < 0) {
    perror("Connect error: ");
    exit(0);
  }
  printf("Welcome to socket calculation client program.\n");
  printf("author: 201122037 Taehwan Kim\n");
  printf("Please input your name. (length:~20)> ");
  fgets(name, NAME_SIZE, stdin);
  if ((strlen(name) > 0) && (name[strlen(name) - 1] == '\n'))
    name[strlen(name) - 1] = '\0';
  printf("Thanks. Connection with server is successful.\n");
  printf("But you must greet with server.\n");
  printf("If you want to greet with server.\n");
  printf("then you should type to your shell like this...\n");
  printf("Usage : name> Hello This is {{name}}\n");
  printf("Example : Tom> Hello This is {{Tom}}\n");
  printf(
      "If you type 'quit', can disconnet with server and quit this program.\n");
  while (1) {
    memset(buf_get, '\0', BUF_SIZE);
    memset(buf_in, '\0', BUF_SIZE);
    printf("%s> ", name);
    fgets(buf_in, BUF_SIZE, stdin);
    if ((strlen(buf_in) > 0) && (buf_in[strlen(buf_in) - 1] == '\n'))
      buf_in[strlen(buf_in) - 1] = '\0';
    write(client_sockfd, buf_in, BUF_SIZE);
    read(client_sockfd, buf_get, BUF_SIZE);
    if (strncmp(buf_in, "quit", 4) == 0) {
      printf("%s\n", buf_get);
      close(client_sockfd);
      exit(0);
    }
    printf("server-> %s\n", buf_get);
  }
  close(client_sockfd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xff,-0x14(%rbp)
movl   $0x32,-0x18(%rbp)
movl   $0x14,-0x1c(%rbp)
mov    %rsp,%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1252 <main+0x62>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,-0x48(%rbp)
movl   $0xc,-0x20(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1100 <connect@plt>
cmp    $0x0,%rax
jge    12d4 <main+0xe4>
lea    0xd80(%rip),%rdi
call   10d0 <perror@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edx
lea    -0x270(%rbp),%rdi
mov    $0x14,%esi
call   10b0 <fgets@plt>
lea    -0x270(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    1368 <main+0x178>
lea    -0x270(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x270(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1368 <main+0x178>
lea    -0x270(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x270(%rbp,%rax,1)
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    13cf <main+0x1df>
lea    -0x250(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1080 <memset@plt>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1080 <memset@plt>
lea    0xe07(%rip),%rdi
lea    -0x270(%rbp),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2bcf(%rip),%rax
mov    (%rax),%edx
lea    -0x150(%rbp),%rdi
mov    $0xff,%esi
call   10b0 <fgets@plt>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    1474 <main+0x284>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x150(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1474 <main+0x284>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x150(%rbp,%rax,1)
mov    -0x24(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    $0xff,%edx
call   1040 <write@plt>
mov    -0x24(%rbp),%edi
lea    -0x250(%rbp),%rsi
mov    $0xff,%edx
call   10a0 <read@plt>
lea    -0x150(%rbp),%rdi
lea    0xd5e(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    14e2 <main+0x2f2>
lea    0xd51(%rip),%rdi
lea    -0x250(%rbp),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xd24(%rip),%rdi
lea    -0x250(%rbp),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    13ca <main+0x1da>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
cmp    $0x3,%edi
jne    1285 <main+0x85>
mov    %rsi,%rbx
mov    0x2dc8(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   10d0 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    0x10(%rbx),%rdi
call   10f0 <atoi@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   1110 <connect@plt>
test   %rax,%rax
jns    12a4 <main+0xa4>
lea    0xd87(%rip),%rdi
call   10e0 <perror@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xf3d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf52(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xda3(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc5(%rip),%rdi
call   1040 <puts@plt>
lea    0xd4d(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   10c0 <fgets@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1311 <main+0x111>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1311 <main+0x111>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
lea    0xda4(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xdce(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
lea    0x30(%rsp),%rbx
lea    0x130(%rsp),%rbp
lea    0x10(%rsp),%r12
lea    0xcbe(%rip),%r13
lea    0xcbc(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1090 <memset@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1090 <memset@plt>
lea    0xc82(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0xff,%esi
call   10c0 <fgets@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1401 <main+0x201>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbp,1)
jne    1401 <main+0x201>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
call   1050 <write@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
call   10b0 <read@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1448 <main+0x248>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1390 <main+0x190>
lea    0x30(%rsp),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   10a0 <close@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [34 x i8] c"Usage : ./client {{ip}} {{port}}\0A\00"
@.str.1 = [38 x i8] c"Example : ./client 127.0.0.1 4444\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [16 x i8] c"Connect error: \00"
@.str.3 = [47 x i8] c"Welcome to socket calculation client program.\0A\00"
@.str.4 = [31 x i8] c"author: 201122037 Taehwan Kim\0A\00"
@.str.5 = [39 x i8] c"Please input your name. (length:~20)> \00"
@stdin = global i32 0
@.str.6 = [47 x i8] c"Thanks. Connection with server is successful.\0A\00"
@.str.7 = [33 x i8] c"But you must greet with server.\0A\00"
@.str.8 = [35 x i8] c"If you want to greet with server.\0A\00"
@.str.9 = [49 x i8] c"then you should type to your shell like this...\0A\00"
@.str.10 = [38 x i8] c"Usage : name> Hello This is {{name}}\0A\00"
@.str.11 = [38 x i8] c"Example : Tom> Hello This is {{Tom}}\0A\00"
@.str.12 = [70 x i8] c"If you type 'quit', can disconnet with server and quit this program.\0A\00"
@.str.13 = [5 x i8] c"%s> \00"
@.str.14 = [5 x i8] c"quit\00"
@.str.15 = [4 x i8] c"%s\0A\00"
@.str.16 = [13 x i8] c"server-> %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 i8*
%12 = alloca i8*
%13 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 255, i32* %6
store i32 50, i32* %7
store i32 20, i32* %8
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %11
%15 = alloca i8, i64 255
%16 = alloca i8, i64 255
%17 = alloca i8, i64 20
%18 = alloca i8, i64 50
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %2
%26 = load i32, i32* @AF_INET
%27 = load i32, i32* @SOCK_STREAM
%28 = call i32 @socket(i32 %26, i32 %27, i32 0)
store i32 %28, i32* %10
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i32 %29, i32* %30
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @inet_addr(i8* %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
%41 = call i32 @htons(i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
store i32 %41, i32* %42
store i32 12, i32* %9
%43 = load i32, i32* %10
%44 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%45 = load i32, i32* %9
%46 = call i64 @connect(i32 %43, %struct.sockaddr* %44, i32 %45)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %25
%49 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %25
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32, i32* @stdin
%56 = call i32 @fgets(i8* %17, i32 20, i32 %55)
%57 = call i32 @strlen(i8* %17)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %72
59: ; preds = %51
%60 = call i32 @strlen(i8* %17)
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %17, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 10
br i1 %66, label %67, label %72
67: ; preds = %59
%68 = call i32 @strlen(i8* %17)
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %17, i64 %70
store i8 0, i8* %71
br label %72
72: ; preds = %67, %59, %51
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0))
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.12, i64 0, i64 0))
br label %80
80: ; preds = %114, %72
br label %81
81: ; preds = %80
%82 = call i32 @memset(i8* %16, i8 signext 0, i32 255)
%83 = call i32 @memset(i8* %15, i8 signext 0, i32 255)
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* %17)
%85 = load i32, i32* @stdin
%86 = call i32 @fgets(i8* %15, i32 255, i32 %85)
%87 = call i32 @strlen(i8* %15)
%88 = icmp sgt i32 %87, 0
br i1 %88, label %89, label %102
89: ; preds = %81
%90 = call i32 @strlen(i8* %15)
%91 = sub nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %15, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 10
br i1 %96, label %97, label %102
97: ; preds = %89
%98 = call i32 @strlen(i8* %15)
%99 = sub nsw i32 %98, 1
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %15, i64 %100
store i8 0, i8* %101
br label %102
102: ; preds = %97, %89, %81
%103 = load i32, i32* %10
%104 = call i32 @write(i32 %103, i8* %15, i32 255)
%105 = load i32, i32* %10
%106 = call i32 @read(i32 %105, i8* %16, i32 255)
%107 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 4)
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %114
109: ; preds = %102
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %16)
%111 = load i32, i32* %10
%112 = call i32 @close(i32 %111)
%113 = call i32 @exit(i32 0)
unreachable
114: ; preds = %102
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i8* %16)
br label %80
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [16 x i8] c"Connect error: \00"
@.str.5 = [39 x i8] c"Please input your name. (length:~20)> \00"
@stdin = global i32 0
@.str.13 = [5 x i8] c"%s> \00"
@.str.14 = [5 x i8] c"quit\00"
@.str.16 = [13 x i8] c"server-> %s\0A\00"
@str = [46 x i8] c"Welcome to socket calculation client program.\00"
@str.17 = [30 x i8] c"author: 201122037 Taehwan Kim\00"
@str.18 = [46 x i8] c"Thanks. Connection with server is successful.\00"
@str.19 = [32 x i8] c"But you must greet with server.\00"
@str.20 = [34 x i8] c"If you want to greet with server.\00"
@str.21 = [48 x i8] c"then you should type to your shell like this...\00"
@str.22 = [37 x i8] c"Usage : name> Hello This is {{name}}\00"
@str.23 = [37 x i8] c"Example : Tom> Hello This is {{Tom}}\00"
@str.24 = [69 x i8] c"If you type 'quit', can disconnet with server and quit this program.\00"
@str.25 = [33 x i8] c"Usage : ./client {{ip}} {{port}}\00"
@str.26 = [37 x i8] c"Example : ./client 127.0.0.1 4444\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = icmp eq i32 %0, 3
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.25, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %20, i32* %21
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32 @inet_addr(i8* %23)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %24, i32* %25
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32 @atoi(i8* %27)
%29 = tail call i32 @htons(i32 %28)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %29, i32* %30
%31 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%32 = call i64 @connect(i32 %19, %struct.sockaddr* %31, i32 12)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %16
%35 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %16
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.17, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%41 = load i32, i32* @stdin
%42 = call i32 @fgets(i8* %7, i32 20, i32 %41)
%43 = call i32 @strlen(i8* %7)
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %57
45: ; preds = %37
%46 = call i32 @strlen(i8* %7)
%47 = add nsw i32 %46, -1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 10
br i1 %51, label %52, label %57
52: ; preds = %45
%53 = call i32 @strlen(i8* %7)
%54 = add nsw i32 %53, -1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 %55
store i8 0, i8* %56
br label %57
57: ; preds = %52, %45, %37
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0))
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.19, i64 0, i64 0))
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.20, i64 0, i64 0))
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.21, i64 0, i64 0))
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.22, i64 0, i64 0))
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.23, i64 0, i64 0))
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.24, i64 0, i64 0))
br label %65
65: ; preds = %94, %57
%66 = call i32 @memset(i8* %8, i8 signext 0, i32 255)
%67 = call i32 @memset(i8* %9, i8 signext 0, i32 255)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8* %7)
%69 = load i32, i32* @stdin
%70 = call i32 @fgets(i8* %9, i32 255, i32 %69)
%71 = call i32 @strlen(i8* %9)
%72 = icmp sgt i32 %71, 0
br i1 %72, label %73, label %85
73: ; preds = %65
%74 = call i32 @strlen(i8* %9)
%75 = add nsw i32 %74, -1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = icmp eq i8 %78, 10
br i1 %79, label %80, label %85
80: ; preds = %73
%81 = call i32 @strlen(i8* %9)
%82 = add nsw i32 %81, -1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %80, %73, %65
%86 = call i32 @write(i32 %19, i8* %9, i32 255)
%87 = call i32 @read(i32 %19, i8* %8, i32 255)
%88 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 4)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %85
%91 = call i32 @puts(i8* %8)
%92 = call i32 @close(i32 %19)
%93 = call i32 @exit(i32 0)
unreachable
94: ; preds = %85
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0), i8* %8)
br label %65
}