#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ saddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int server_fd;
  int client_fd;
  struct sockaddr_in saddr, caddr;
  int ret;
  char buf[1024] = "hello world.!";
  char buf2[1024];
  int len;
  server_fd = socket(AF_INET, SOCK_STREAM, 0);
  if (server_fd < 0) {
    printf("create socket failure. server_fd = %d\n", server_fd);
    return -1;
  }
  saddr.sin_family = AF_INET;
  saddr.sin_port = htons(8099);
  saddr.sin_addr.s_addr = htonl(INADDR_ANY);
  ret = bind(server_fd, (struct sockaddr *)(&saddr), sizeof(saddr));
  if (ret) {
    printf("bind addr & port failure. ret = %d\n", ret);
    return -1;
  }
  ret = listen(server_fd, 5);
  if (ret) {
    printf("listen error: ret = %d\n", ret);
    return -1;
  } else {
    printf("listening ...\n");
  }
  client_fd = accept(server_fd, (struct sockaddr *)(&caddr), &len);
  if (client_fd < 0) {
    printf("accept error: client_fd = %d: %s\n", client_fd, strerror(errno));
    return 0;
  }
  ret = write(client_fd, buf, 32);
  if (ret < 0) {
    printf("write error!\n");
  }
  while (1) {
    ret = read(client_fd, buf, 1024);
    if (ret < 0) {
      printf("read error!\n");
      continue;
    }
    strcpy(buf2, "you said:");
    strcat(buf2, buf);
    ret = write(client_fd, buf2, 1024);
    if (ret < 0) {
      printf("write client error!\n");
    }
    if (strcmp(buf, "exit") == 0) {
      break;
    }
  };
  strcpy(buf2, "bye!");
  ret = write(client_fd, buf2, 1024);
  if (ret < 0) {
    printf("write client error!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x440(%rbp),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x400,%edx
call   10a0 <memcpy@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1254 <main+0x74>
mov    -0x14(%rbp),%esi
lea    0x11bf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1485 <main+0x2a5>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x1fa3,%edi
call   1050 <htons@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     12b9 <main+0xd9>
mov    -0x3c(%rbp),%esi
lea    0x1181(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1485 <main+0x2a5>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10b0 <listen@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     12f0 <main+0x110>
mov    -0x3c(%rbp),%esi
lea    0x116e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1485 <main+0x2a5>
lea    0x116c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x844(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1358 <main+0x178>
mov    -0x18(%rbp),%eax
mov    %eax,-0x848(%rbp)
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x848(%rbp),%esi
mov    %rax,%rdx
lea    0x112d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1485 <main+0x2a5>
mov    -0x18(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0x20,%edx
call   1040 <write@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1387 <main+0x1a7>
lea    0x1114(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    138c <main+0x1ac>
mov    -0x18(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    13c0 <main+0x1e0>
lea    0x10ee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    138c <main+0x1ac>
lea    -0x840(%rbp),%rdi
lea    0x10e1(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x840(%rbp),%rdi
lea    -0x440(%rbp),%rsi
call   10e0 <strcat@plt>
mov    -0x18(%rbp),%edi
lea    -0x840(%rbp),%rsi
mov    $0x400,%edx
call   1040 <write@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1415 <main+0x235>
lea    0x10ab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x440(%rbp),%rdi
lea    0x10ab(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1437 <main+0x257>
jmp    143c <main+0x25c>
jmp    138c <main+0x1ac>
lea    -0x840(%rbp),%rdi
lea    0x1089(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%edi
lea    -0x840(%rbp),%rsi
mov    $0x400,%edx
call   1040 <write@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    147e <main+0x29e>
lea    0x1042(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
lea    0xdf8(%rip),%rsi
lea    0x20(%rsp),%rdi
mov    $0x400,%edx
call   10b0 <memcpy@plt>
mov    0x2dca(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1279 <main+0x89>
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    $0x1fa3,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %eax,%eax
je     1284 <main+0x94>
lea    0x11b0(%rip),%rdi
jmp    129b <main+0xab>
lea    0x1180(%rip),%rdi
mov    %ebx,%esi
jmp    129d <main+0xad>
mov    %ebx,%edi
mov    $0x5,%esi
call   10c0 <listen@plt>
test   %eax,%eax
je     12bd <main+0xcd>
lea    0x11b0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x11d5(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebx,%edi
call   10e0 <accept@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1300 <main+0x110>
lea    0x20(%rsp),%rsi
mov    %r12d,%edi
mov    $0x20,%edx
call   1050 <write@plt>
lea    0x11cd(%rip),%rdi
test   %eax,%eax
jns    132b <main+0x13b>
jmp    1326 <main+0x136>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0x114e(%rip),%rdi
xor    %ebx,%ebx
mov    %r12d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12a9 <main+0xb9>
call   1040 <puts@plt>
lea    0x20(%rsp),%rbx
lea    0x114e(%rip),%r15
lea    0x420(%rsp),%rbp
lea    0x1161(%rip),%r13
lea    0x1142(%rip),%r14
jmp    1360 <main+0x170>
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     13b4 <main+0x1c4>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
js     13a8 <main+0x1b8>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10f0 <strcat@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1050 <write@plt>
test   %eax,%eax
jns    1350 <main+0x160>
mov    %r13,%rdi
call   1040 <puts@plt>
jmp    1350 <main+0x160>
lea    0x110c(%rip),%rdi
jmp    1326 <main+0x136>
lea    0x10d9(%rip),%rsi
lea    0x420(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1050 <write@plt>
xor    %ebx,%ebx
test   %eax,%eax
jns    12a9 <main+0xb9>
lea    0x10bb(%rip),%rdi
call   1040 <puts@plt>
jmp    12a9 <main+0xb9>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.buf = [1024 x i8] c"hello world.!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [39 x i8] c"create socket failure. server_fd = %d\0A\00"
@INADDR_ANY = global i32 0
@.str.1 = [36 x i8] c"bind addr & port failure. ret = %d\0A\00"
@.str.2 = [24 x i8] c"listen error: ret = %d\0A\00"
@.str.3 = [15 x i8] c"listening ...\0A\00"
@.str.4 = [34 x i8] c"accept error: client_fd = %d: %s\0A\00"
@errno = global i32 0
@.str.5 = [14 x i8] c"write error!\0A\00"
@.str.6 = [13 x i8] c"read error!\0A\00"
@.str.7 = [10 x i8] c"you said:\00"
@.str.8 = [21 x i8] c"write client error!\0A\00"
@.str.9 = [5 x i8] c"exit\00"
@.str.10 = [5 x i8] c"bye!\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 %struct.sockaddr_in
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [1024 x i8]* %11 to i8*
%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 %23
20: ; preds = %2
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 -1, i32* %3
br label %108
23: ; preds = %2
%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 = call i32 @htons(i32 8099)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %26, i32* %27
%28 = load i32, i32* @INADDR_ANY
%29 = call i32 @htonl(i32 %28)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
store i32 %29, i32* %31
%32 = load i32, i32* %6
%33 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%34 = call i32 @bind(i32 %32, %struct.sockaddr* %33, i32 12)
store i32 %34, i32* %10
%35 = load i32, i32* %10
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %23
%38 = load i32, i32* %10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %38)
store i32 -1, i32* %3
br label %108
40: ; preds = %23
%41 = load i32, i32* %6
%42 = call i32 @listen(i32 %41, i32 5)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i32, i32* %10
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %46)
store i32 -1, i32* %3
br label %108
48: ; preds = %40
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %6
%52 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%53 = call i32 @accept(i32 %51, %struct.sockaddr* %52, i32* %13)
store i32 %53, i32* %7
%54 = load i32, i32* %7
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %50
%57 = load i32, i32* %7
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %57, i8* %59)
store i32 0, i32* %3
br label %108
61: ; preds = %50
%62 = load i32, i32* %7
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%64 = call i32 @write(i32 %62, i8* %63, i32 32)
store i32 %64, i32* %10
%65 = load i32, i32* %10
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %61
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %69
69: ; preds = %67, %61
br label %70
70: ; preds = %69, %76, %96
%71 = load i32, i32* %7
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%73 = call i32 @read(i32 %71, i8* %72, i32 1024)
store i32 %73, i32* %10
%74 = load i32, i32* %10
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %70
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %70
78: ; preds = %70
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%80 = call i32 @strcpy(i8* %79, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%83 = call i32 @strcat(i8* %81, i8* %82)
%84 = load i32, i32* %7
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%86 = call i32 @write(i32 %84, i8* %85, i32 1024)
store i32 %86, i32* %10
%87 = load i32, i32* %10
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %78
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %91
91: ; preds = %89, %78
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%93 = call i64 @strcmp(i8* %92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %91
br label %97
96: ; preds = %91
br label %70
97: ; preds = %95
%98 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%99 = call i32 @strcpy(i8* %98, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%100 = load i32, i32* %7
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%102 = call i32 @write(i32 %100, i8* %101, i32 1024)
store i32 %102, i32* %10
%103 = load i32, i32* %10
%104 = icmp slt i32 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %97
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %107
107: ; preds = %105, %97
store i32 0, i32* %3
br label %108
108: ; preds = %107, %56, %45, %37, %20
%109 = load i32, i32* %3
ret i32 %109
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.buf = [1024 x i8] c"hello world.!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [39 x i8] c"create socket failure. server_fd = %d\0A\00"
@INADDR_ANY = global i32 0
@.str.1 = [36 x i8] c"bind addr & port failure. ret = %d\0A\00"
@.str.2 = [24 x i8] c"listen error: ret = %d\0A\00"
@.str.4 = [34 x i8] c"accept error: client_fd = %d: %s\0A\00"
@errno = global i32 0
@.str.7 = [10 x i8] c"you said:\00"
@.str.9 = [5 x i8] c"exit\00"
@.str.10 = [5 x i8] c"bye!\00"
@str = [14 x i8] c"listening ...\00"
@str.12 = [20 x i8] c"write client error!\00"
@str.13 = [12 x i8] c"read error!\00"
@str.14 = [13 x i8] c"write error!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = bitcast i32* %7 to i8*
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %72
19: ; preds = %2
%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 = tail call i32 @htons(i32 8099)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %22, i32* %23
%24 = load i32, i32* @INADDR_ANY
%25 = tail call i32 @htonl(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %25, i32* %26
%27 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%28 = call i32 @bind(i32 %15, %struct.sockaddr* %27, i32 12)
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %19
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %72
32: ; preds = %19
%33 = call i32 @listen(i32 %15, i32 5)
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %72
37: ; preds = %32
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%39 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%40 = call i32 @accept(i32 %15, %struct.sockaddr* %39, i32* %7)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %40, i8* %44)
br label %72
46: ; preds = %37
%47 = call i32 @write(i32 %40, i8* %10, i32 32)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %53, %46
%50 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.14, i64 0, i64 0), %46 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0), %53 ]
%51 = call i32 @puts(i8* dereferenceable(1) %50)
br label %52
52: ; preds = %46, %49
br label %53
53: ; preds = %52, %63
%54 = call i32 @read(i32 %40, i8* %10, i32 1024)
%55 = icmp slt i32 %54, 0
br i1 %55, label %49, label %56
56: ; preds = %53
%57 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%58 = call i32 @strcat(i8* %11, i8* %10)
%59 = call i32 @write(i32 %40, i8* %11, i32 1024)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %53
66: ; preds = %63
%67 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%68 = call i32 @write(i32 %40, i8* %11, i32 1024)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
br label %72
72: ; preds = %66, %70, %42, %35, %30, %17
%73 = phi i32 [ -1, %17 ], [ -1, %30 ], [ -1, %35 ], [ 0, %42 ], [ 0, %70 ], [ 0, %66 ]
ret i32 %73
}