#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 timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
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*/ serveraddr;
typedef int /*<<< orphan*/ on;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_ERROR;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
char errno;
int /*<<< orphan*/ exit(int);
int getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int write(int, char *, int);
int main() {
  int sd, sd2, rc, length = sizeof(int);
  int totalcnt = 0, on = 1;
  char temp;
  char buffer[257];
  struct sockaddr_in serveraddr;
  struct sockaddr_in their_addr;
  fd_set read_fd;
  struct timeval timeout;
  timeout.tv_sec = 15;
  timeout.tv_usec = 0;
  if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("server-socket() error");
    exit(-1);
  } else
    printf("server-socket() is ok\n");
  if ((rc = setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on))) <
      0) {
    perror("server-sersockopt() error");
    close(sd);
    exit(-1);
  } else {
    printf("server-setsockopt() is ok\n");
  }
  printf("server-setsockopt() is ok\n");
  memset(&serveraddr, 0x00, sizeof(struct sockaddr_in));
  serveraddr.sin_family = AF_INET;
  serveraddr.sin_port = htons(3111);
  serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
  printf("Using %s, listening  at %d\n", inet_ntoa(serveraddr.sin_addr), 3111);
  if ((rc = bind(sd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))) < 0) {
    perror("server-bind() error");
    close(sd);
    exit(-1);
  } else
    printf("server-bind() is ok\n");
  if ((rc = listen(sd, 10)) < 0) {
    perror("server-listen() error");
    close(sd);
    exit(-1);
  } else
    printf("server-ready for client connection...\n");
  int sin_size = sizeof(struct sockaddr_in);
  if ((sd2 = accept(sd, (struct sockaddr *)&their_addr, &sin_size)) < 0) {
    perror("server-accept() error");
    close(sd);
    exit(-1);
  } else
    printf("server-accept is ok...\n");
  printf("server-new socket, sd2 is ok...\n");
  printf("got connection from the client:%s\n", inet_ntoa(their_addr.sin_addr));
  FD_ZERO(&read_fd);
  FD_SET(sd2, &read_fd);
  rc = select(sd2 + 1, &read_fd, NULL, NULL, &timeout);
  if ((rc == 1) && (FD_ISSET(sd2, &read_fd))) {
    totalcnt = 0;
    while (totalcnt < 257) {
      rc = read(sd2, &buffer[totalcnt], (257 - totalcnt));
      if (rc < 0) {
        perror("server-read() error");
        close(sd);
        close(sd2);
        exit(-1);
      } else if (rc == 0) {
        printf("client program has issued a close()\n");
        close(sd);
        close(sd2);
        exit(-1);
      } else {
        totalcnt += rc;
        printf("server-read() is ok\n");
      }
    }
  } else if (rc < 0) {
    perror("server-select() error");
    close(sd);
    close(sd2);
    exit(-1);
  } else {
    printf("server-select() time out.\n");
    close(sd);
    close(sd2);
    exit(-1);
  }
  printf("received data from client: %s\n", buffer);
  printf("server-Echoing back to client...\n");
  rc = write(sd2, buffer, totalcnt);
  if (rc != totalcnt) {
    perror("Server-write() error");
    rc = getsockopt(sd2, SOL_SOCKET, SO_ERROR, &temp, &length);
    if (rc == 0) {
      errno = temp;
      perror("SO_ERROR was:");
    } else
      printf("server-write() is ok\n");
    close(sd);
    close(sd2);
    exit(-1);
  }
  close(sd2);
  close(sd);
  exit(0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0xf,-0x158(%rbp)
movq   $0x0,-0x150(%rbp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    12b7 <main+0x77>
lea    0xd58(%rip),%rdi
call   1120 <perror@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
mov    0x2d19(%rip),%rax
mov    (%rax),%esi
mov    0x2cd8(%rip),%rax
mov    (%rax),%edx
lea    -0x1c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1313 <main+0xd3>
lea    0xd31(%rip),%rdi
call   1120 <perror@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x128(%rbp)
mov    $0xc27,%edi
call   1070 <htons@plt>
mov    %eax,-0x12c(%rbp)
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,-0x130(%rbp)
mov    -0x130(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xcd8(%rip),%rdi
mov    $0xc27,%edx
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0xc,%edx
call   1110 <bind@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    13d4 <main+0x194>
lea    0xcc1(%rip),%rdi
call   1120 <perror@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    0xcb7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0xa,%esi
call   1100 <listen@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1419 <main+0x1d9>
lea    0xca5(%rip),%rdi
call   1120 <perror@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    0xc9d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xc,-0x15c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x140(%rbp),%rsi
lea    -0x15c(%rbp),%rdx
call   1130 <accept@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1471 <main+0x231>
lea    0xc8a(%rip),%rdi
call   1120 <perror@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x140(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x144(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
mov    -0xc(%rbp),%edi
lea    -0x144(%rbp),%rsi
call   1150 <FD_SET@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
lea    -0x144(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x158(%rbp),%r8
mov    %rcx,%rdx
call   10f0 <select@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    15c7 <main+0x387>
mov    -0xc(%rbp),%edi
lea    -0x144(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     15c7 <main+0x387>
movl   $0x0,-0x18(%rbp)
cmpl   $0x101,-0x18(%rbp)
jge    15c2 <main+0x382>
mov    -0xc(%rbp),%edi
movslq -0x18(%rbp),%rax
lea    -0x120(%rbp),%rsi
add    %rax,%rsi
mov    $0x101,%edx
sub    -0x18(%rbp),%edx
call   10c0 <read@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    156f <main+0x32f>
lea    0xc06(%rip),%rdi
call   1120 <perror@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    -0xc(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
cmpl   $0x0,-0x10(%rbp)
jne    15a1 <main+0x361>
lea    0xbea(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    -0xc(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    15bd <main+0x37d>
jmp    1511 <main+0x2d1>
jmp    161f <main+0x3df>
cmpl   $0x0,-0x10(%rbp)
jge    15f7 <main+0x3b7>
lea    0xbcc(%rip),%rdi
call   1120 <perror@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    -0xc(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    -0xc(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
lea    -0x120(%rbp),%rsi
lea    0xba8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xbb9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     16e3 <main+0x4a3>
lea    0xbac(%rip),%rdi
call   1120 <perror@plt>
mov    -0xc(%rbp),%edi
mov    0x296f(%rip),%rax
mov    (%rax),%esi
mov    0x2936(%rip),%rax
mov    (%rax),%edx
lea    -0x1d(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   10d0 <getsockopt@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    16bb <main+0x47b>
mov    -0x1d(%rbp),%cl
mov    0x2918(%rip),%rax
mov    %cl,(%rax)
lea    0xb7a(%rip),%rdi
call   1120 <perror@plt>
jmp    16c9 <main+0x489>
lea    0xb77(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
mov    -0xc(%rbp),%edi
call   10b0 <close@plt>
mov    $0xffffffff,%edi
call   1140 <exit@plt>
mov    -0xc(%rbp),%edi
call   10b0 <close@plt>
mov    -0x8(%rbp),%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   1140 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x160,%rsp
movl   $0x4,0x1c(%rsp)
movl   $0x1,0x18(%rsp)
movl   $0xf,0x30(%rsp)
movq   $0x0,0x38(%rsp)
mov    0x2d59(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
test   %eax,%eax
js     153e <main+0x2ee>
mov    %eax,%r14d
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d30(%rip),%r12
mov    (%r12),%esi
mov    0x2ced(%rip),%rax
mov    (%rax),%edx
lea    0x18(%rsp),%rcx
mov    %r14d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %eax,%eax
js     1554 <main+0x304>
lea    0xe4a(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10b0 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    $0xc27,%edi
call   1080 <htons@plt>
mov    %eax,0x24(%rsp)
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
call   10a0 <htonl@plt>
mov    %eax,0x20(%rsp)
mov    %eax,%edi
call   1070 <inet_ntoa@plt>
lea    0xcf0(%rip),%rdi
mov    %rax,%rsi
mov    $0xc27,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1120 <bind@plt>
test   %eax,%eax
js     155d <main+0x30d>
lea    0xddd(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
mov    $0xa,%esi
call   1110 <listen@plt>
test   %eax,%eax
js     1566 <main+0x316>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
movl   $0xc,0x10(%rsp)
lea    0x40(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
call   1140 <accept@plt>
test   %eax,%eax
js     156f <main+0x31f>
mov    %eax,%r15d
lea    0xdc5(%rip),%rdi
call   1030 <puts@plt>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
mov    0x40(%rsp),%edi
call   1070 <inet_ntoa@plt>
lea    0xcab(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x14(%rsp),%rbx
mov    %rbx,%rdi
call   10f0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1160 <FD_SET@plt>
mov    %r15d,%edi
add    $0x1,%edi
lea    0x30(%rsp),%r8
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1100 <select@plt>
cmp    $0x1,%eax
jne    1580 <main+0x330>
lea    0x14(%rsp),%rsi
mov    %r15d,%edi
call   1060 <FD_ISSET@plt>
test   %rax,%rax
je     1590 <main+0x340>
xor    %ebx,%ebx
lea    0xdca(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rsi
add    $0x50,%rsi
mov    $0x101,%edx
sub    %eax,%edx
mov    %r15d,%edi
call   10d0 <read@plt>
test   %eax,%eax
js     1527 <main+0x2d7>
je     1530 <main+0x2e0>
add    %eax,%ebx
mov    %rbp,%rdi
call   1030 <puts@plt>
cmp    $0x101,%ebx
jl     1450 <main+0x200>
lea    0xc48(%rip),%rdi
lea    0x50(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd2f(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1050 <write@plt>
cmp    %ebx,%eax
je     1599 <main+0x349>
lea    0xc30(%rip),%rdi
call   1130 <perror@plt>
mov    (%r12),%esi
mov    0x2ae0(%rip),%rax
mov    (%rax),%edx
lea    0xf(%rsp),%rcx
lea    0x1c(%rsp),%r8
mov    %r15d,%edi
call   10e0 <getsockopt@plt>
test   %eax,%eax
jne    15b0 <main+0x360>
mov    0xf(%rsp),%al
mov    0x2ac1(%rip),%rcx
mov    %al,(%rcx)
lea    0xc05(%rip),%rdi
call   1130 <perror@plt>
mov    %r14d,%edi
call   10c0 <close@plt>
mov    %r15d,%edi
call   10c0 <close@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
lea    0xb81(%rip),%rdi
jmp    1508 <main+0x2b8>
lea    0xce9(%rip),%rdi
call   1030 <puts@plt>
jmp    150d <main+0x2bd>
lea    0xabb(%rip),%rdi
call   1130 <perror@plt>
mov    $0xffffffff,%edi
call   1150 <exit@plt>
lea    0xabb(%rip),%rdi
jmp    1576 <main+0x326>
lea    0xae8(%rip),%rdi
jmp    1576 <main+0x326>
lea    0xaf3(%rip),%rdi
jmp    1576 <main+0x326>
lea    0xb00(%rip),%rdi
call   1130 <perror@plt>
mov    %r14d,%edi
jmp    1518 <main+0x2c8>
test   %eax,%eax
jns    1590 <main+0x340>
lea    0xb38(%rip),%rdi
jmp    1508 <main+0x2b8>
lea    0xc25(%rip),%rdi
jmp    1537 <main+0x2e7>
mov    %r15d,%edi
call   10c0 <close@plt>
mov    %r14d,%edi
call   10c0 <close@plt>
xor    %edi,%edi
call   1150 <exit@plt>
lea    0xc40(%rip),%rdi
jmp    1537 <main+0x2e7>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"server-socket() error\00"
@.str.1 = [23 x i8] c"server-socket() is ok\0A\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [26 x i8] c"server-sersockopt() error\00"
@.str.3 = [27 x i8] c"server-setsockopt() is ok\0A\00"
@INADDR_ANY = global i32 0
@.str.4 = [28 x i8] c"Using %s, listening at %d\0A\00"
@.str.5 = [20 x i8] c"server-bind() error\00"
@.str.6 = [21 x i8] c"server-bind() is ok\0A\00"
@.str.7 = [22 x i8] c"server-listen() error\00"
@.str.8 = [39 x i8] c"server-ready for client connection...\0A\00"
@.str.9 = [22 x i8] c"server-accept() error\00"
@.str.10 = [24 x i8] c"server-accept is ok...\0A\00"
@.str.11 = [33 x i8] c"server-new socket, sd2 is ok...\0A\00"
@.str.12 = [35 x i8] c"got connection from the client:%s\0A\00"
@.str.13 = [20 x i8] c"server-read() error\00"
@.str.14 = [37 x i8] c"client program has issued a close()\0A\00"
@.str.15 = [21 x i8] c"server-read() is ok\0A\00"
@.str.16 = [22 x i8] c"server-select() error\00"
@.str.17 = [27 x i8] c"server-select() time out.\0A\00"
@.str.18 = [31 x i8] c"received data from client: %s\0A\00"
@.str.19 = [34 x i8] c"server-Echoing back to client...\0A\00"
@.str.20 = [21 x i8] c"Server-write() error\00"
@SO_ERROR = global i32 0
@errno = global i8 0
@.str.21 = [14 x i8] c"SO_ERROR was:\00"
@.str.22 = [22 x i8] c"server-write() is ok\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca [257 x i8]
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca %struct.timeval
%14 = alloca i32
store i32 0, i32* %1
store i32 4, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 15, i32* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store i64 0, i64* %16
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = call i32 @socket(i32 %17, i32 %18, i32 0)
store i32 %19, i32* %2
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24
%27 = load i32, i32* %2
%28 = load i32, i32* @SOL_SOCKET
%29 = load i32, i32* @SO_REUSEADDR
%30 = bitcast i32* %7 to i8*
%31 = call i32 @setsockopt(i32 %27, i32 %28, i32 %29, i8* %30, i32 4)
store i32 %31, i32* %4
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %26
%34 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* %2
%36 = call i32 @close(i32 %35)
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %26
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @memset(%struct.sockaddr_in* %10, i32 0, i32 12)
%43 = load i32, i32* @AF_INET
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %43, i32* %44
%45 = call i32 @htons(i32 3111)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %45, i32* %46
%47 = load i32, i32* @INADDR_ANY
%48 = call i32 @htonl(i32 %47)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%50 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %49, i32 0, i32 0
store i32 %48, i32* %50
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%52 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %51, i32 0, i32 0
%53 = load i32, i32* %52
%54 = call i8* @inet_ntoa(i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %54, i32 3111)
%56 = load i32, i32* %2
%57 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%58 = call i32 @bind(i32 %56, %struct.sockaddr* %57, i32 12)
store i32 %58, i32* %4
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %40
%61 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%62 = load i32, i32* %2
%63 = call i32 @close(i32 %62)
%64 = call i32 @exit(i32 -1)
unreachable
65: ; preds = %40
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %67
67: ; preds = %65
%68 = load i32, i32* %2
%69 = call i32 @listen(i32 %68, i32 10)
store i32 %69, i32* %4
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %67
%72 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%73 = load i32, i32* %2
%74 = call i32 @close(i32 %73)
%75 = call i32 @exit(i32 -1)
unreachable
76: ; preds = %67
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %78
78: ; preds = %76
store i32 12, i32* %14
%79 = load i32, i32* %2
%80 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%81 = call i32 @accept(i32 %79, %struct.sockaddr* %80, i32* %14)
store i32 %81, i32* %3
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %88
83: ; preds = %78
%84 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%85 = load i32, i32* %2
%86 = call i32 @close(i32 %85)
%87 = call i32 @exit(i32 -1)
unreachable
88: ; preds = %78
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %90
90: ; preds = %88
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%92 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%93 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = call i8* @inet_ntoa(i32 %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0), i8* %95)
%97 = call i32 @FD_ZERO(i32* %12)
%98 = load i32, i32* %3
%99 = call i32 @FD_SET(i32 %98, i32* %12)
%100 = load i32, i32* %3
%101 = add nsw i32 %100, 1
%102 = call i32 @select(i32 %101, i32* %12, i32* null, i32* null, %struct.timeval* %13)
store i32 %102, i32* %4
%103 = load i32, i32* %4
%104 = icmp eq i32 %103, 1
br i1 %104, label %105, label %148
105: ; preds = %90
%106 = load i32, i32* %3
%107 = call i64 @FD_ISSET(i32 %106, i32* %12)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %148
109: ; preds = %105
store i32 0, i32* %6
br label %110
110: ; preds = %146, %109
%111 = load i32, i32* %6
%112 = icmp slt i32 %111, 257
br i1 %112, label %113, label %147
113: ; preds = %110
%114 = load i32, i32* %3
%115 = load i32, i32* %6
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [257 x i8], [257 x i8]* %9, i64 0, i64 %116
%118 = load i32, i32* %6
%119 = sub nsw i32 257, %118
%120 = call i32 @read(i32 %114, i8* %117, i32 %119)
store i32 %120, i32* %4
%121 = load i32, i32* %4
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %130
123: ; preds = %113
%124 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%125 = load i32, i32* %2
%126 = call i32 @close(i32 %125)
%127 = load i32, i32* %3
%128 = call i32 @close(i32 %127)
%129 = call i32 @exit(i32 -1)
unreachable
130: ; preds = %113
%131 = load i32, i32* %4
%132 = icmp eq i32 %131, 0
br i1 %132, label %133, label %140
133: ; preds = %130
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0))
%135 = load i32, i32* %2
%136 = call i32 @close(i32 %135)
%137 = load i32, i32* %3
%138 = call i32 @close(i32 %137)
%139 = call i32 @exit(i32 -1)
unreachable
140: ; preds = %130
%141 = load i32, i32* %4
%142 = load i32, i32* %6
%143 = add nsw i32 %142, %141
store i32 %143, i32* %6
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
br label %145
145: ; preds = %140
br label %146
146: ; preds = %145
br label %110
147: ; preds = %110
br label %165
148: ; preds = %105, %90
%149 = load i32, i32* %4
%150 = icmp slt i32 %149, 0
br i1 %150, label %151, label %158
151: ; preds = %148
%152 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.16, i64 0, i64 0))
%153 = load i32, i32* %2
%154 = call i32 @close(i32 %153)
%155 = load i32, i32* %3
%156 = call i32 @close(i32 %155)
%157 = call i32 @exit(i32 -1)
unreachable
158: ; preds = %148
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0))
%160 = load i32, i32* %2
%161 = call i32 @close(i32 %160)
%162 = load i32, i32* %3
%163 = call i32 @close(i32 %162)
%164 = call i32 @exit(i32 -1)
unreachable
165: ; preds = %147
%166 = getelementptr inbounds [257 x i8], [257 x i8]* %9, i64 0, i64 0
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0), i8* %166)
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0))
%169 = load i32, i32* %3
%170 = getelementptr inbounds [257 x i8], [257 x i8]* %9, i64 0, i64 0
%171 = load i32, i32* %6
%172 = call i32 @write(i32 %169, i8* %170, i32 %171)
store i32 %172, i32* %4
%173 = load i32, i32* %4
%174 = load i32, i32* %6
%175 = icmp ne i32 %173, %174
br i1 %175, label %176, label %195
176: ; preds = %165
%177 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%178 = load i32, i32* %3
%179 = load i32, i32* @SOL_SOCKET
%180 = load i32, i32* @SO_ERROR
%181 = call i32 @getsockopt(i32 %178, i32 %179, i32 %180, i8* %8, i32* %5)
store i32 %181, i32* %4
%182 = load i32, i32* %4
%183 = icmp eq i32 %182, 0
br i1 %183, label %184, label %187
184: ; preds = %176
%185 = load i8, i8* %8
store i8 %185, i8* @errno
%186 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0))
br label %189
187: ; preds = %176
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.22, i64 0, i64 0))
br label %189
189: ; preds = %187, %184
%190 = load i32, i32* %2
%191 = call i32 @close(i32 %190)
%192 = load i32, i32* %3
%193 = call i32 @close(i32 %192)
%194 = call i32 @exit(i32 -1)
unreachable
195: ; preds = %165
%196 = load i32, i32* %3
%197 = call i32 @close(i32 %196)
%198 = load i32, i32* %2
%199 = call i32 @close(i32 %198)
%200 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [22 x i8] c"server-socket() error\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [26 x i8] c"server-sersockopt() error\00"
@INADDR_ANY = global i32 0
@.str.4 = [28 x i8] c"Using %s, listening at %d\0A\00"
@.str.5 = [20 x i8] c"server-bind() error\00"
@.str.7 = [22 x i8] c"server-listen() error\00"
@.str.9 = [22 x i8] c"server-accept() error\00"
@.str.12 = [35 x i8] c"got connection from the client:%s\0A\00"
@.str.13 = [20 x i8] c"server-read() error\00"
@.str.16 = [22 x i8] c"server-select() error\00"
@.str.18 = [31 x i8] c"received data from client: %s\0A\00"
@.str.20 = [21 x i8] c"Server-write() error\00"
@SO_ERROR = global i32 0
@errno = global i8 0
@.str.21 = [14 x i8] c"SO_ERROR was:\00"
@str = [22 x i8] c"server-socket() is ok\00"
@str.24 = [26 x i8] c"server-setsockopt() is ok\00"
@str.25 = [20 x i8] c"server-bind() is ok\00"
@str.26 = [38 x i8] c"server-ready for client connection...\00"
@str.27 = [23 x i8] c"server-accept is ok...\00"
@str.28 = [32 x i8] c"server-new socket, sd2 is ok...\00"
@str.29 = [26 x i8] c"server-select() time out.\00"
@str.30 = [33 x i8] c"server-Echoing back to client...\00"
@str.31 = [21 x i8] c"server-write() is ok\00"
@str.32 = [20 x i8] c"server-read() is ok\00"
@str.33 = [36 x i8] c"client program has issued a close()\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca [257 x i8]
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca %struct.timeval
%9 = alloca i32
%10 = bitcast i32* %1 to i8*
store i32 4, i32* %1
%11 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%12 = getelementptr inbounds [257 x i8], [257 x i8]* %4, i64 0, i64 0
%13 = bitcast %struct.sockaddr_in* %5 to i8*
%14 = bitcast %struct.sockaddr_in* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast %struct.timeval* %8 to i8*
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
store i32 15, i32* %17
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
store i64 0, i64* %18
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = tail call i32 @socket(i32 %19, i32 %20, i32 0)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %0
%24 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 @exit(i32 -1)
unreachable
26: ; preds = %0
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%28 = load i32, i32* @SOL_SOCKET
%29 = load i32, i32* @SO_REUSEADDR
%30 = call i32 @setsockopt(i32 %21, i32 %28, i32 %29, i8* %11, i32 4)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @close(i32 %21)
%35 = call i32 @exit(i32 -1)
unreachable
36: ; preds = %26
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.24, i64 0, i64 0))
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.24, i64 0, i64 0))
%39 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%40 = load i32, i32* @AF_INET
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %40, i32* %41
%42 = call i32 @htons(i32 3111)
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %42, i32* %43
%44 = load i32, i32* @INADDR_ANY
%45 = call i32 @htonl(i32 %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %45, i32* %46
%47 = call i8* @inet_ntoa(i32 %45)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %47, i32 3111)
%49 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%50 = call i32 @bind(i32 %21, %struct.sockaddr* %49, i32 12)
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %36
%53 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%54 = call i32 @close(i32 %21)
%55 = call i32 @exit(i32 -1)
unreachable
56: ; preds = %36
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.25, i64 0, i64 0))
%58 = call i32 @listen(i32 %21, i32 10)
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%62 = call i32 @close(i32 %21)
%63 = call i32 @exit(i32 -1)
unreachable
64: ; preds = %56
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.26, i64 0, i64 0))
%66 = bitcast i32* %9 to i8*
store i32 12, i32* %9
%67 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%68 = call i32 @accept(i32 %21, %struct.sockaddr* %67, i32* %9)
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %64
%71 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%72 = call i32 @close(i32 %21)
%73 = call i32 @exit(i32 -1)
unreachable
74: ; preds = %64
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.27, i64 0, i64 0))
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.28, i64 0, i64 0))
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
%78 = load i32, i32* %77
%79 = call i8* @inet_ntoa(i32 %78)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.12, i64 0, i64 0), i8* %79)
%81 = call i32 @FD_ZERO(i32* %7)
%82 = call i32 @FD_SET(i32 %68, i32* %7)
%83 = add nuw nsw i32 %68, 1
%84 = call i32 @select(i32 %83, i32* %7, i32* null, i32* null, %struct.timeval* %8)
%85 = icmp eq i32 %84, 1
br i1 %85, label %86, label %112
86: ; preds = %74
%87 = call i64 @FD_ISSET(i32 %68, i32* %7)
%88 = icmp eq i64 %87, 0
br i1 %88, label %119, label %89
89: ; preds = %86, %108
%90 = phi i32 [ %109, %108 ], [ 0, %86 ]
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [257 x i8], [257 x i8]* %4, i64 0, i64 %91
%93 = sub nsw i32 257, %90
%94 = call i32 @read(i32 %68, i8* %92, i32 %93)
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %101
96: ; preds = %89
%97 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%98 = call i32 @close(i32 %21)
%99 = call i32 @close(i32 %68)
%100 = call i32 @exit(i32 -1)
unreachable
101: ; preds = %89
%102 = icmp eq i32 %94, 0
br i1 %102, label %103, label %108
103: ; preds = %101
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.33, i64 0, i64 0))
%105 = call i32 @close(i32 %21)
%106 = call i32 @close(i32 %68)
%107 = call i32 @exit(i32 -1)
unreachable
108: ; preds = %101
%109 = add nsw i32 %94, %90
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.32, i64 0, i64 0))
%111 = icmp slt i32 %109, 257
br i1 %111, label %89, label %124
112: ; preds = %74
%113 = icmp slt i32 %84, 0
br i1 %113, label %114, label %119
114: ; preds = %112
%115 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.16, i64 0, i64 0))
%116 = call i32 @close(i32 %21)
%117 = call i32 @close(i32 %68)
%118 = call i32 @exit(i32 -1)
unreachable
119: ; preds = %86, %112
%120 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.29, i64 0, i64 0))
%121 = call i32 @close(i32 %21)
%122 = call i32 @close(i32 %68)
%123 = call i32 @exit(i32 -1)
unreachable
124: ; preds = %108
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.18, i64 0, i64 0), i8* %12)
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.30, i64 0, i64 0))
%127 = call i32 @write(i32 %68, i8* %12, i32 %109)
%128 = icmp eq i32 %127, %109
br i1 %128, label %144, label %129
129: ; preds = %124
%130 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%131 = load i32, i32* @SOL_SOCKET
%132 = load i32, i32* @SO_ERROR
%133 = call i32 @getsockopt(i32 %68, i32 %131, i32 %132, i8* %3, i32* %1)
%134 = icmp eq i32 %133, 0
br i1 %134, label %135, label %138
135: ; preds = %129
%136 = load i8, i8* %3
store i8 %136, i8* @errno
%137 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0))
br label %140
138: ; preds = %129
%139 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.31, i64 0, i64 0))
br label %140
140: ; preds = %138, %135
%141 = call i32 @close(i32 %21)
%142 = call i32 @close(i32 %68)
%143 = call i32 @exit(i32 -1)
unreachable
144: ; preds = %124
%145 = call i32 @close(i32 %68)
%146 = call i32 @close(i32 %21)
%147 = call i32 @exit(i32 0)
unreachable
}