#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
void *atoi(char const *);
int /*<<< orphan*/ close(int);
int establish_connection();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, int *, int);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ write(int, int const *, int);
int client_handle_input(int argc, const char *argv[]) {
  int ret = 0;
  int command = -1;
  if (argc >= 2) {
    if (strcmp(argv[1], "-halt") == 0 || strcmp(argv[1], "-h") == 0) {
      command = 1;
      int sock = establish_connection();
      if (sock != -1) {
        write(sock, &command, sizeof(int));
        close(sock);
      }
    } else if (strcmp(argv[1], "-setcolor") == 0 ||
               strcmp(argv[1], "-sc") == 0) {
      command = 2;
      if (argc >= 5) {
        int sock = establish_connection();
        if (sock != -1) {
          const int red = atoi(argv[2]);
          const int green = atoi(argv[3]);
          const int blue = atoi(argv[4]);
          write(sock, &command, sizeof(int));
          write(sock, &red, sizeof(int));
          write(sock, &green, sizeof(int));
          write(sock, &blue, sizeof(int));
          close(sock);
        }
      }
    } else if (strcmp(argv[1], "-getcolor") == 0 ||
               strcmp(argv[1], "-gc") == 0) {
      command = 4;
      int sock = establish_connection();
      if (sock != -1) {
        int red;
        int green;
        int blue;
        write(sock, &command, sizeof(int));
        read(sock, &red, sizeof(int));
        read(sock, &green, sizeof(int));
        read(sock, &blue, sizeof(int));
        close(sock);
        printf("{red: %d, green: %d, blue: %d}\n", red, green, blue);
        int r = red << 16;
        int g = green << 8;
        ret = r | g | blue;
        printf("red as bits 17-24: %d\ngreen as bits 9-16: %d\nblue as bits "
               "1-8: %d\nentire color as single integer: %d\n",
               r, g, blue, ret);
      }
    } else if (strcmp(argv[1], "-getred") == 0) {
      command = 5;
      int sock = establish_connection();
      if (sock != -1) {
        int red;
        write(sock, &command, sizeof(int));
        read(sock, &red, sizeof(int));
        close(sock);
        printf("{red: %d}\n", red);
        ret = red;
      }
    } else if (strcmp(argv[1], "-getgreen") == 0) {
      command = 6;
      int sock = establish_connection();
      if (sock != -1) {
        int green;
        write(sock, &command, sizeof(int));
        read(sock, &green, sizeof(int));
        close(sock);
        printf("{green: %d}\n", green);
        ret = green;
      }
    } else if (strcmp(argv[1], "-getblue") == 0) {
      command = 7;
      int sock = establish_connection();
      if (sock != -1) {
        int blue;
        write(sock, &command, sizeof(int));
        read(sock, &blue, sizeof(int));
        close(sock);
        printf("{blue: %d}\n", blue);
        ret = blue;
      }
    } else if (strcmp(argv[1], "-setbright") == 0) {
      if (argc >= 3) {
        command = 3;
        int br = atoi(argv[2]);
        if (br > 255)
          br = 255;
        else if (br < 0)
          br = 0;
        int sock = establish_connection();
        if (sock != -1) {
          write(sock, &command, sizeof(int));
          write(sock, &br, sizeof(int));
          close(sock);
        }
      }
    } else if (strcmp(argv[1], "-getbright") == 0) {
      command = 8;
      int sock = establish_connection();
      if (sock != -1) {
        int br;
        write(sock, &command, sizeof(int));
        read(sock, &br, sizeof(int));
        close(sock);
        printf("{brightness: %d}\n", br);
        ret = br;
      }
    } else {
      printf("\n%s: invalid command\n", argv[1]);
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<client_handle_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0x2,-0x4(%rbp)
jl     16db <client_handle_input+0x56b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     11d3 <client_handle_input+0x63>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe42(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <client_handle_input+0x9c>
movl   $0x1,-0x18(%rbp)
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     1207 <client_handle_input+0x97>
mov    -0x1c(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
jmp    16d6 <client_handle_input+0x566>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdee(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1248 <client_handle_input+0xd8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdda(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12f3 <client_handle_input+0x183>
movl   $0x2,-0x18(%rbp)
cmpl   $0x5,-0x4(%rbp)
jl     12ee <client_handle_input+0x17e>
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     12e9 <client_handle_input+0x179>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
jmp    12ee <client_handle_input+0x17e>
jmp    16d1 <client_handle_input+0x561>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd15(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     132f <client_handle_input+0x1bf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd01(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    13eb <client_handle_input+0x27b>
movl   $0x4,-0x18(%rbp)
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
je     13e6 <client_handle_input+0x276>
mov    -0x30(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x30(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x30(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x30(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x30(%rbp),%edi
call   1060 <close@plt>
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
lea    0xc7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
shl    $0x10,%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
or     -0x44(%rbp),%eax
or     -0x3c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x40(%rbp),%esi
mov    -0x44(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xc66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    16cc <client_handle_input+0x55c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcb1(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    146a <client_handle_input+0x2fa>
movl   $0x5,-0x18(%rbp)
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
je     1465 <client_handle_input+0x2f5>
mov    -0x48(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x48(%rbp),%edi
lea    -0x4c(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x48(%rbp),%edi
call   1060 <close@plt>
mov    -0x4c(%rbp),%esi
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    16c7 <client_handle_input+0x557>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc45(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    14e9 <client_handle_input+0x379>
movl   $0x6,-0x18(%rbp)
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
je     14e4 <client_handle_input+0x374>
mov    -0x50(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x50(%rbp),%edi
lea    -0x54(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x50(%rbp),%edi
call   1060 <close@plt>
mov    -0x54(%rbp),%esi
lea    0xbf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    16c2 <client_handle_input+0x552>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xbdd(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1568 <client_handle_input+0x3f8>
movl   $0x7,-0x18(%rbp)
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0xffffffff,-0x58(%rbp)
je     1563 <client_handle_input+0x3f3>
mov    -0x58(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x58(%rbp),%edi
lea    -0x5c(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x58(%rbp),%edi
call   1060 <close@plt>
mov    -0x5c(%rbp),%esi
lea    0xb88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    16bd <client_handle_input+0x54d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xb73(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    161e <client_handle_input+0x4ae>
cmpl   $0x3,-0x4(%rbp)
jl     1619 <client_handle_input+0x4a9>
movl   $0x3,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0xff,-0x60(%rbp)
jle    15c0 <client_handle_input+0x450>
movl   $0xff,-0x60(%rbp)
jmp    15d6 <client_handle_input+0x466>
cmpl   $0x0,-0x60(%rbp)
jge    15d1 <client_handle_input+0x461>
movl   $0x0,-0x60(%rbp)
jmp    15d6 <client_handle_input+0x466>
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
je     1614 <client_handle_input+0x4a4>
mov    -0x64(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x64(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x64(%rbp),%edi
call   1060 <close@plt>
jmp    1619 <client_handle_input+0x4a9>
jmp    16b8 <client_handle_input+0x548>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xac8(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    169d <client_handle_input+0x52d>
movl   $0x8,-0x18(%rbp)
mov    $0x0,%al
call   1030 <establish_connection@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
je     1698 <client_handle_input+0x528>
mov    -0x68(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x68(%rbp),%edi
lea    -0x6c(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x68(%rbp),%edi
call   1060 <close@plt>
mov    -0x6c(%rbp),%esi
lea    0xa75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    16b3 <client_handle_input+0x543>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xa66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    16b8 <client_handle_input+0x548>
jmp    16bd <client_handle_input+0x54d>
jmp    16c2 <client_handle_input+0x552>
jmp    16c7 <client_handle_input+0x557>
jmp    16cc <client_handle_input+0x55c>
jmp    16d1 <client_handle_input+0x561>
jmp    16d6 <client_handle_input+0x566>
jmp    16db <client_handle_input+0x56b>
mov    -0x14(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_handle_input>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %r14d,%r14d
cmp    $0x2,%edi
jl     15ff <client_handle_input+0x48f>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12b8 <client_handle_input+0x148>
mov    0x8(%rbx),%rdi
lea    0xe57(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12b8 <client_handle_input+0x148>
mov    0x8(%rbx),%rdi
lea    0xe41(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12f2 <client_handle_input+0x182>
mov    0x8(%rbx),%rdi
lea    0xe32(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12f2 <client_handle_input+0x182>
mov    0x8(%rbx),%rdi
lea    0xe1d(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     138f <client_handle_input+0x21f>
mov    0x8(%rbx),%rdi
lea    0xe0e(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     138f <client_handle_input+0x21f>
mov    0x8(%rbx),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1445 <client_handle_input+0x2d5>
mov    0x8(%rbx),%rdi
lea    0xe79(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     149c <client_handle_input+0x32c>
mov    0x8(%rbx),%rdi
lea    0xe77(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     14f3 <client_handle_input+0x383>
mov    0x8(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     154a <client_handle_input+0x3da>
mov    0x8(%rbx),%rdi
lea    0xe65(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     15a7 <client_handle_input+0x437>
mov    0x8(%rbx),%rsi
lea    0xe69(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    15ff <client_handle_input+0x48f>
movl   $0x1,0x8(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
jmp    15ff <client_handle_input+0x48f>
movl   $0x2,0x8(%rsp)
cmp    $0x5,%ebp
jb     15ff <client_handle_input+0x48f>
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,0xc(%rsp)
mov    0x18(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    0x20(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0x14(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1040 <write@plt>
mov    %ebp,%edi
call   1060 <close@plt>
jmp    15ff <client_handle_input+0x48f>
movl   $0x4,0x8(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
lea    0x14(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0xc(%rsp),%ebx
mov    0x14(%rsp),%ebp
mov    0x10(%rsp),%r15d
lea    0xc1a(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
shl    $0x10,%ebx
shl    $0x8,%ebp
mov    %ebp,%r14d
or     %ebx,%r14d
or     %r15d,%r14d
lea    0xc16(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    15ff <client_handle_input+0x48f>
movl   $0x5,0x8(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0xc(%rsp),%r14d
lea    0xc1c(%rip),%rdi
jmp    15f5 <client_handle_input+0x485>
movl   $0x6,0x8(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0xc(%rsp),%r14d
lea    0xbda(%rip),%rdi
jmp    15f5 <client_handle_input+0x485>
movl   $0x7,0x8(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0xc(%rsp),%r14d
lea    0xb99(%rip),%rdi
jmp    15f5 <client_handle_input+0x485>
cmp    $0x3,%ebp
jb     15ff <client_handle_input+0x48f>
movl   $0x3,0x8(%rsp)
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
xor    %r14d,%r14d
test   %eax,%eax
cmovs  %r14d,%eax
cmp    $0xff,%eax
mov    $0xff,%ecx
cmovb  %eax,%ecx
mov    %ecx,0xc(%rsp)
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
jmp    12da <client_handle_input+0x16a>
movl   $0x8,0x8(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <establish_connection@plt>
cmp    $0xffffffff,%eax
je     15ff <client_handle_input+0x48f>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1070 <read@plt>
mov    %ebx,%edi
call   1060 <close@plt>
mov    0xc(%rsp),%r14d
lea    0xb0b(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"-halt\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [10 x i8] c"-setcolor\00"
@.str.3 = [4 x i8] c"-sc\00"
@.str.4 = [10 x i8] c"-getcolor\00"
@.str.5 = [4 x i8] c"-gc\00"
@.str.6 = [32 x i8] c"{red: %d, green: %d, blue: %d}\0A\00"
@.str.7 = [102 x i8] c"red as bits 17-24: %d\0Agreen as bits 9-16: %d\0Ablue as bits 1-8: %d\0Aentire color as single integer: %d\0A\00"
@.str.8 = [8 x i8] c"-getred\00"
@.str.9 = [11 x i8] c"{red: %d}\0A\00"
@.str.10 = [10 x i8] c"-getgreen\00"
@.str.11 = [13 x i8] c"{green: %d}\0A\00"
@.str.12 = [9 x i8] c"-getblue\00"
@.str.13 = [12 x i8] c"{blue: %d}\0A\00"
@.str.14 = [11 x i8] c"-setbright\00"
@.str.15 = [11 x i8] c"-getbright\00"
@.str.16 = [18 x i8] c"{brightness: %d}\0A\00"
@.str.17 = [22 x i8] c"\0A%s: invalid command\0A\00"
define i32 @client_handle_input(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
store i32 -1, i32* %6
%28 = load i32, i32* %3
%29 = icmp sge i32 %28, 2
br i1 %29, label %30, label %278
30: ; preds = %2
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %30
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %52
42: ; preds = %36, %30
store i32 1, i32* %6
%43 = call i32 (...) @establish_connection()
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = icmp ne i32 %44, -1
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load i32, i32* %7
%48 = call i32 @write(i32 %47, i32* %6, i32 4)
%49 = load i32, i32* %7
%50 = call i32 @close(i32 %49)
br label %51
51: ; preds = %46, %42
br label %277
52: ; preds = %36
%53 = load i8**, i8*** %4
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %64, label %58
58: ; preds = %52
%59 = load i8**, i8*** %4
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %99
64: ; preds = %58, %52
store i32 2, i32* %6
%65 = load i32, i32* %3
%66 = icmp sge i32 %65, 5
br i1 %66, label %67, label %98
67: ; preds = %64
%68 = call i32 (...) @establish_connection()
store i32 %68, i32* %8
%69 = load i32, i32* %8
%70 = icmp ne i32 %69, -1
br i1 %70, label %71, label %97
71: ; preds = %67
%72 = load i8**, i8*** %4
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = load i8*, i8** %73
%75 = call i8* @atoi(i8* %74)
%76 = ptrtoint i8* %75 to i32
store i32 %76, i32* %9
%77 = load i8**, i8*** %4
%78 = getelementptr inbounds i8*, i8** %77, i64 3
%79 = load i8*, i8** %78
%80 = call i8* @atoi(i8* %79)
%81 = ptrtoint i8* %80 to i32
store i32 %81, i32* %10
%82 = load i8**, i8*** %4
%83 = getelementptr inbounds i8*, i8** %82, i64 4
%84 = load i8*, i8** %83
%85 = call i8* @atoi(i8* %84)
%86 = ptrtoint i8* %85 to i32
store i32 %86, i32* %11
%87 = load i32, i32* %8
%88 = call i32 @write(i32 %87, i32* %6, i32 4)
%89 = load i32, i32* %8
%90 = call i32 @write(i32 %89, i32* %9, i32 4)
%91 = load i32, i32* %8
%92 = call i32 @write(i32 %91, i32* %10, i32 4)
%93 = load i32, i32* %8
%94 = call i32 @write(i32 %93, i32* %11, i32 4)
%95 = load i32, i32* %8
%96 = call i32 @close(i32 %95)
br label %97
97: ; preds = %71, %67
br label %98
98: ; preds = %97, %64
br label %276
99: ; preds = %58
%100 = load i8**, i8*** %4
%101 = getelementptr inbounds i8*, i8** %100, i64 1
%102 = load i8*, i8** %101
%103 = call i64 @strcmp(i8* %102, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%104 = icmp eq i64 %103, 0
br i1 %104, label %111, label %105
105: ; preds = %99
%106 = load i8**, i8*** %4
%107 = getelementptr inbounds i8*, i8** %106, i64 1
%108 = load i8*, i8** %107
%109 = call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %145
111: ; preds = %105, %99
store i32 4, i32* %6
%112 = call i32 (...) @establish_connection()
store i32 %112, i32* %12
%113 = load i32, i32* %12
%114 = icmp ne i32 %113, -1
br i1 %114, label %115, label %144
115: ; preds = %111
%116 = load i32, i32* %12
%117 = call i32 @write(i32 %116, i32* %6, i32 4)
%118 = load i32, i32* %12
%119 = call i32 @read(i32 %118, i32* %13, i32 4)
%120 = load i32, i32* %12
%121 = call i32 @read(i32 %120, i32* %14, i32 4)
%122 = load i32, i32* %12
%123 = call i32 @read(i32 %122, i32* %15, i32 4)
%124 = load i32, i32* %12
%125 = call i32 @close(i32 %124)
%126 = load i32, i32* %13
%127 = load i32, i32* %14
%128 = load i32, i32* %15
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %126, i32 %127, i32 %128)
%130 = load i32, i32* %13
%131 = shl i32 %130, 16
store i32 %131, i32* %16
%132 = load i32, i32* %14
%133 = shl i32 %132, 8
store i32 %133, i32* %17
%134 = load i32, i32* %16
%135 = load i32, i32* %17
%136 = or i32 %134, %135
%137 = load i32, i32* %15
%138 = or i32 %136, %137
store i32 %138, i32* %5
%139 = load i32, i32* %16
%140 = load i32, i32* %17
%141 = load i32, i32* %15
%142 = load i32, i32* %5
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.7, i64 0, i64 0), i32 %139, i32 %140, i32 %141, i32 %142)
br label %144
144: ; preds = %115, %111
br label %275
145: ; preds = %105
%146 = load i8**, i8*** %4
%147 = getelementptr inbounds i8*, i8** %146, i64 1
%148 = load i8*, i8** %147
%149 = call i64 @strcmp(i8* %148, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %166
151: ; preds = %145
store i32 5, i32* %6
%152 = call i32 (...) @establish_connection()
store i32 %152, i32* %18
%153 = load i32, i32* %18
%154 = icmp ne i32 %153, -1
br i1 %154, label %155, label %165
155: ; preds = %151
%156 = load i32, i32* %18
%157 = call i32 @write(i32 %156, i32* %6, i32 4)
%158 = load i32, i32* %18
%159 = call i32 @read(i32 %158, i32* %19, i32 4)
%160 = load i32, i32* %18
%161 = call i32 @close(i32 %160)
%162 = load i32, i32* %19
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %162)
%164 = load i32, i32* %19
store i32 %164, i32* %5
br label %165
165: ; preds = %155, %151
br label %274
166: ; preds = %145
%167 = load i8**, i8*** %4
%168 = getelementptr inbounds i8*, i8** %167, i64 1
%169 = load i8*, i8** %168
%170 = call i64 @strcmp(i8* %169, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%171 = icmp eq i64 %170, 0
br i1 %171, label %172, label %187
172: ; preds = %166
store i32 6, i32* %6
%173 = call i32 (...) @establish_connection()
store i32 %173, i32* %20
%174 = load i32, i32* %20
%175 = icmp ne i32 %174, -1
br i1 %175, label %176, label %186
176: ; preds = %172
%177 = load i32, i32* %20
%178 = call i32 @write(i32 %177, i32* %6, i32 4)
%179 = load i32, i32* %20
%180 = call i32 @read(i32 %179, i32* %21, i32 4)
%181 = load i32, i32* %20
%182 = call i32 @close(i32 %181)
%183 = load i32, i32* %21
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %183)
%185 = load i32, i32* %21
store i32 %185, i32* %5
br label %186
186: ; preds = %176, %172
br label %273
187: ; preds = %166
%188 = load i8**, i8*** %4
%189 = getelementptr inbounds i8*, i8** %188, i64 1
%190 = load i8*, i8** %189
%191 = call i64 @strcmp(i8* %190, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%192 = icmp eq i64 %191, 0
br i1 %192, label %193, label %208
193: ; preds = %187
store i32 7, i32* %6
%194 = call i32 (...) @establish_connection()
store i32 %194, i32* %22
%195 = load i32, i32* %22
%196 = icmp ne i32 %195, -1
br i1 %196, label %197, label %207
197: ; preds = %193
%198 = load i32, i32* %22
%199 = call i32 @write(i32 %198, i32* %6, i32 4)
%200 = load i32, i32* %22
%201 = call i32 @read(i32 %200, i32* %23, i32 4)
%202 = load i32, i32* %22
%203 = call i32 @close(i32 %202)
%204 = load i32, i32* %23
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %204)
%206 = load i32, i32* %23
store i32 %206, i32* %5
br label %207
207: ; preds = %197, %193
br label %272
208: ; preds = %187
%209 = load i8**, i8*** %4
%210 = getelementptr inbounds i8*, i8** %209, i64 1
%211 = load i8*, i8** %210
%212 = call i64 @strcmp(i8* %211, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%213 = icmp eq i64 %212, 0
br i1 %213, label %214, label %244
214: ; preds = %208
%215 = load i32, i32* %3
%216 = icmp sge i32 %215, 3
br i1 %216, label %217, label %243
217: ; preds = %214
store i32 3, i32* %6
%218 = load i8**, i8*** %4
%219 = getelementptr inbounds i8*, i8** %218, i64 2
%220 = load i8*, i8** %219
%221 = call i8* @atoi(i8* %220)
%222 = ptrtoint i8* %221 to i32
store i32 %222, i32* %24
%223 = load i32, i32* %24
%224 = icmp sgt i32 %223, 255
br i1 %224, label %225, label %226
225: ; preds = %217
store i32 255, i32* %24
br label %231
226: ; preds = %217
%227 = load i32, i32* %24
%228 = icmp slt i32 %227, 0
br i1 %228, label %229, label %230
229: ; preds = %226
store i32 0, i32* %24
br label %230
230: ; preds = %229, %226
br label %231
231: ; preds = %230, %225
%232 = call i32 (...) @establish_connection()
store i32 %232, i32* %25
%233 = load i32, i32* %25
%234 = icmp ne i32 %233, -1
br i1 %234, label %235, label %242
235: ; preds = %231
%236 = load i32, i32* %25
%237 = call i32 @write(i32 %236, i32* %6, i32 4)
%238 = load i32, i32* %25
%239 = call i32 @write(i32 %238, i32* %24, i32 4)
%240 = load i32, i32* %25
%241 = call i32 @close(i32 %240)
br label %242
242: ; preds = %235, %231
br label %243
243: ; preds = %242, %214
br label %271
244: ; preds = %208
%245 = load i8**, i8*** %4
%246 = getelementptr inbounds i8*, i8** %245, i64 1
%247 = load i8*, i8** %246
%248 = call i64 @strcmp(i8* %247, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%249 = icmp eq i64 %248, 0
br i1 %249, label %250, label %265
250: ; preds = %244
store i32 8, i32* %6
%251 = call i32 (...) @establish_connection()
store i32 %251, i32* %26
%252 = load i32, i32* %26
%253 = icmp ne i32 %252, -1
br i1 %253, label %254, label %264
254: ; preds = %250
%255 = load i32, i32* %26
%256 = call i32 @write(i32 %255, i32* %6, i32 4)
%257 = load i32, i32* %26
%258 = call i32 @read(i32 %257, i32* %27, i32 4)
%259 = load i32, i32* %26
%260 = call i32 @close(i32 %259)
%261 = load i32, i32* %27
%262 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0), i32 %261)
%263 = load i32, i32* %27
store i32 %263, i32* %5
br label %264
264: ; preds = %254, %250
br label %270
265: ; preds = %244
%266 = load i8**, i8*** %4
%267 = getelementptr inbounds i8*, i8** %266, i64 1
%268 = load i8*, i8** %267
%269 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %268)
br label %270
270: ; preds = %265, %264
br label %271
271: ; preds = %270, %243
br label %272
272: ; preds = %271, %207
br label %273
273: ; preds = %272, %186
br label %274
274: ; preds = %273, %165
br label %275
275: ; preds = %274, %144
br label %276
276: ; preds = %275, %98
br label %277
277: ; preds = %276, %51
br label %278
278: ; preds = %277, %2
%279 = load i32, i32* %5
ret i32 %279
}

LLVM IR (-O2):
@.str = [6 x i8] c"-halt\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [10 x i8] c"-setcolor\00"
@.str.3 = [4 x i8] c"-sc\00"
@.str.4 = [10 x i8] c"-getcolor\00"
@.str.5 = [4 x i8] c"-gc\00"
@.str.6 = [32 x i8] c"{red: %d, green: %d, blue: %d}\0A\00"
@.str.7 = [102 x i8] c"red as bits 17-24: %d\0Agreen as bits 9-16: %d\0Ablue as bits 1-8: %d\0Aentire color as single integer: %d\0A\00"
@.str.8 = [8 x i8] c"-getred\00"
@.str.9 = [11 x i8] c"{red: %d}\0A\00"
@.str.10 = [10 x i8] c"-getgreen\00"
@.str.11 = [13 x i8] c"{green: %d}\0A\00"
@.str.12 = [9 x i8] c"-getblue\00"
@.str.13 = [12 x i8] c"{blue: %d}\0A\00"
@.str.14 = [11 x i8] c"-setbright\00"
@.str.15 = [11 x i8] c"-getbright\00"
@.str.16 = [18 x i8] c"{brightness: %d}\0A\00"
@.str.17 = [22 x i8] c"\0A%s: invalid command\0A\00"
define i32 @client_handle_input(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = bitcast i32* %3 to i8*
%16 = icmp sgt i32 %0, 1
br i1 %16, label %17, label %181
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %17
%23 = load i8*, i8** %18
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %22, %17
store i32 1, i32* %3
%27 = tail call i32 (...) @establish_connection()
%28 = icmp eq i32 %27, -1
br i1 %28, label %181, label %29
29: ; preds = %26
%30 = call i32 @write(i32 %27, i32* %3, i32 4)
%31 = tail call i32 @close(i32 %27)
br label %181
32: ; preds = %22
%33 = load i8*, i8** %18
%34 = tail call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i8*, i8** %18
%38 = tail call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %69
40: ; preds = %36, %32
store i32 2, i32* %3
%41 = icmp ugt i32 %0, 4
br i1 %41, label %42, label %181
42: ; preds = %40
%43 = tail call i32 (...) @establish_connection()
%44 = icmp eq i32 %43, -1
br i1 %44, label %181, label %45
45: ; preds = %42
%46 = bitcast i32* %4 to i8*
%47 = getelementptr inbounds i8*, i8** %1, i64 2
%48 = load i8*, i8** %47
%49 = tail call i8* @atoi(i8* %48)
%50 = ptrtoint i8* %49 to i64
%51 = trunc i64 %50 to i32
store i32 %51, i32* %4
%52 = bitcast i32* %5 to i8*
%53 = getelementptr inbounds i8*, i8** %1, i64 3
%54 = load i8*, i8** %53
%55 = tail call i8* @atoi(i8* %54)
%56 = ptrtoint i8* %55 to i64
%57 = trunc i64 %56 to i32
store i32 %57, i32* %5
%58 = bitcast i32* %6 to i8*
%59 = getelementptr inbounds i8*, i8** %1, i64 4
%60 = load i8*, i8** %59
%61 = tail call i8* @atoi(i8* %60)
%62 = ptrtoint i8* %61 to i64
%63 = trunc i64 %62 to i32
store i32 %63, i32* %6
%64 = call i32 @write(i32 %43, i32* %3, i32 4)
%65 = call i32 @write(i32 %43, i32* %4, i32 4)
%66 = call i32 @write(i32 %43, i32* %5, i32 4)
%67 = call i32 @write(i32 %43, i32* %6, i32 4)
%68 = tail call i32 @close(i32 %43)
br label %181
69: ; preds = %36
%70 = load i8*, i8** %18
%71 = tail call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %77, label %73
73: ; preds = %69
%74 = load i8*, i8** %18
%75 = tail call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %98
77: ; preds = %73, %69
store i32 4, i32* %3
%78 = tail call i32 (...) @establish_connection()
%79 = icmp eq i32 %78, -1
br i1 %79, label %181, label %80
80: ; preds = %77
%81 = bitcast i32* %7 to i8*
%82 = bitcast i32* %8 to i8*
%83 = bitcast i32* %9 to i8*
%84 = call i32 @write(i32 %78, i32* %3, i32 4)
%85 = call i32 @read(i32 %78, i32* %7, i32 4)
%86 = call i32 @read(i32 %78, i32* %8, i32 4)
%87 = call i32 @read(i32 %78, i32* %9, i32 4)
%88 = tail call i32 @close(i32 %78)
%89 = load i32, i32* %7
%90 = load i32, i32* %8
%91 = load i32, i32* %9
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %89, i32 %90, i32 %91)
%93 = shl i32 %89, 16
%94 = shl i32 %90, 8
%95 = or i32 %94, %93
%96 = or i32 %95, %91
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([102 x i8], [102 x i8]* @.str.7, i64 0, i64 0), i32 %93, i32 %94, i32 %91, i32 %96)
br label %181
98: ; preds = %73
%99 = load i8*, i8** %18
%100 = tail call i64 @strcmp(i8* %99, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %112
102: ; preds = %98
store i32 5, i32* %3
%103 = tail call i32 (...) @establish_connection()
%104 = icmp eq i32 %103, -1
br i1 %104, label %181, label %105
105: ; preds = %102
%106 = bitcast i32* %10 to i8*
%107 = call i32 @write(i32 %103, i32* %3, i32 4)
%108 = call i32 @read(i32 %103, i32* %10, i32 4)
%109 = tail call i32 @close(i32 %103)
%110 = load i32, i32* %10
%111 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %110)
br label %181
112: ; preds = %98
%113 = load i8*, i8** %18
%114 = tail call i64 @strcmp(i8* %113, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %126
116: ; preds = %112
store i32 6, i32* %3
%117 = tail call i32 (...) @establish_connection()
%118 = icmp eq i32 %117, -1
br i1 %118, label %181, label %119
119: ; preds = %116
%120 = bitcast i32* %11 to i8*
%121 = call i32 @write(i32 %117, i32* %3, i32 4)
%122 = call i32 @read(i32 %117, i32* %11, i32 4)
%123 = tail call i32 @close(i32 %117)
%124 = load i32, i32* %11
%125 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i32 %124)
br label %181
126: ; preds = %112
%127 = load i8*, i8** %18
%128 = tail call i64 @strcmp(i8* %127, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%129 = icmp eq i64 %128, 0
br i1 %129, label %130, label %140
130: ; preds = %126
store i32 7, i32* %3
%131 = tail call i32 (...) @establish_connection()
%132 = icmp eq i32 %131, -1
br i1 %132, label %181, label %133
133: ; preds = %130
%134 = bitcast i32* %12 to i8*
%135 = call i32 @write(i32 %131, i32* %3, i32 4)
%136 = call i32 @read(i32 %131, i32* %12, i32 4)
%137 = tail call i32 @close(i32 %131)
%138 = load i32, i32* %12
%139 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %138)
br label %181
140: ; preds = %126
%141 = load i8*, i8** %18
%142 = tail call i64 @strcmp(i8* %141, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%143 = icmp eq i64 %142, 0
br i1 %143, label %144, label %164
144: ; preds = %140
%145 = icmp ugt i32 %0, 2
br i1 %145, label %146, label %181
146: ; preds = %144
store i32 3, i32* %3
%147 = bitcast i32* %13 to i8*
%148 = getelementptr inbounds i8*, i8** %1, i64 2
%149 = load i8*, i8** %148
%150 = tail call i8* @atoi(i8* %149)
%151 = ptrtoint i8* %150 to i64
%152 = trunc i64 %151 to i32
%153 = icmp sgt i32 %152, 0
%154 = select i1 %153, i32 %152, i32 0
%155 = icmp ult i32 %154, 255
%156 = select i1 %155, i32 %154, i32 255
store i32 %156, i32* %13
%157 = tail call i32 (...) @establish_connection()
%158 = icmp eq i32 %157, -1
br i1 %158, label %163, label %159
159: ; preds = %146
%160 = call i32 @write(i32 %157, i32* %3, i32 4)
%161 = call i32 @write(i32 %157, i32* %13, i32 4)
%162 = tail call i32 @close(i32 %157)
br label %163
163: ; preds = %159, %146
br label %181
164: ; preds = %140
%165 = load i8*, i8** %18
%166 = tail call i64 @strcmp(i8* %165, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%167 = icmp eq i64 %166, 0
br i1 %167, label %168, label %178
168: ; preds = %164
store i32 8, i32* %3
%169 = tail call i32 (...) @establish_connection()
%170 = icmp eq i32 %169, -1
br i1 %170, label %181, label %171
171: ; preds = %168
%172 = bitcast i32* %14 to i8*
%173 = call i32 @write(i32 %169, i32* %3, i32 4)
%174 = call i32 @read(i32 %169, i32* %14, i32 4)
%175 = tail call i32 @close(i32 %169)
%176 = load i32, i32* %14
%177 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0), i32 %176)
br label %181
178: ; preds = %164
%179 = load i8*, i8** %18
%180 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0), i8* %179)
br label %181
181: ; preds = %168, %171, %130, %133, %116, %119, %102, %105, %77, %80, %42, %45, %26, %29, %163, %144, %178, %40, %2
%182 = phi i32 [ 0, %40 ], [ 0, %163 ], [ 0, %144 ], [ 0, %178 ], [ 0, %2 ], [ 0, %29 ], [ 0, %26 ], [ 0, %45 ], [ 0, %42 ], [ %96, %80 ], [ 0, %77 ], [ %110, %105 ], [ 0, %102 ], [ %124, %119 ], [ 0, %116 ], [ %138, %133 ], [ 0, %130 ], [ %176, %171 ], [ 0, %168 ]
ret i32 %182
}