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

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *gai_strerror(int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int getResource(int socketArray[], int fileHandlerArray[], int rangeCount,
                char *path, char *host, long contentLength,
                int useWindowStyle) {
  int retValue = 0;
  char *windowsNewLine = "\r\n";
  char *linuxNewLine = "\n";
  char *newLine = useWindowStyle ? windowsNewLine : linuxNewLine;
  if (path != NULL && host != NULL && socketArray != NULL &&
      fileHandlerArray != NULL) {
    char writeBuffer[8192];
    int size = 8192;
    for (int i = 0; i < rangeCount; i++) {
      char *cursor = writeBuffer;
      int offset = 0;
      long begin = contentLength / rangeCount * i;
      long end = contentLength / rangeCount * (i + 1) - 1;
      if (i == rangeCount - 1) {
        end = contentLength - 1;
      }
      printf("output range %ld -- %ld \n", begin, end);
      offset = sprintf(cursor, "GET %s HTTP/1.1%s", path, newLine);
      cursor += offset;
      offset = sprintf(cursor, "Host: %s%s", host, newLine);
      cursor += offset;
      offset = sprintf(cursor, "Range: bytes=%ld-%ld%s", begin, end, newLine);
      cursor += offset;
      offset = sprintf(cursor, "Connection: close%s", newLine);
      cursor += offset;
      offset = sprintf(cursor, "%s", newLine);
      cursor += offset;
      *cursor = '\0';
      int sock = socketArray[i];
      if (sock >= 0) {
        int count = write(sock, writeBuffer, (cursor - writeBuffer));
        if (count < 0) {
          fprintf(stderr, "write: %d : %s\n", count, gai_strerror(count));
        }
      }
    }
    printf("\ndownloading");
    long recvSocketBitmap = 0;
    for (int i = 0; i < rangeCount; i++) {
      recvSocketBitmap |= 1 << i;
    }
    do {
      fd_set read_set;
      struct timeval timeout;
      timeout.tv_sec = 10;
      timeout.tv_usec = 0;
      FD_ZERO(&read_set);
      int maxFd = -1;
      for (int i = 0; i < rangeCount; i++) {
        FD_SET(socketArray[i], &read_set);
        if (socketArray[i] > maxFd) {
          maxFd = socketArray[i];
        }
      }
      int r = select(maxFd + 1, &read_set, NULL, NULL, &timeout);
      if (r < 0) {
        fprintf(stderr, "poll errorrom socket \n");
      }
      if (r == 0) {
        fprintf(stderr, "tiemout rom socket \n");
      }
      if (r > 0) {
        for (int i = 0; i < rangeCount; i++) {
          int sock = socketArray[i];
          int fd = fileHandlerArray[i];
          if (FD_ISSET(sock, &read_set)) {
            char rdBuffer[4096];
            int count;
            count = read(sock, rdBuffer, 4096);
            if (count > 0) {
              int wcount = write(fd, rdBuffer, count);
              printf(".");
            }
            if (count == 0) {
              recvSocketBitmap &= ~(1 << i);
            }
          }
        }
      }
    } while (recvSocketBitmap != 0);
  }
  return retValue;
}


x86 assembly (clang, -O0):
<getResource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30e0,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe2d(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe23(%rip),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,0x10(%rbp)
je     11fc <getResource+0x5c>
mov    -0x40(%rbp),%rax
mov    %rax,-0x30d0(%rbp)
jmp    1207 <getResource+0x67>
mov    -0x48(%rbp),%rax
mov    %rax,-0x30d0(%rbp)
mov    -0x30d0(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     179c <getResource+0x5fc>
cmpq   $0x0,-0x28(%rbp)
je     179c <getResource+0x5fc>
cmpq   $0x0,-0x8(%rbp)
je     179c <getResource+0x5fc>
cmpq   $0x0,-0x10(%rbp)
je     179c <getResource+0x5fc>
movl   $0x2000,-0x2054(%rbp)
movl   $0x0,-0x2058(%rbp)
mov    -0x2058(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    14f6 <getResource+0x356>
lea    -0x2050(%rbp),%rax
mov    %rax,-0x2060(%rbp)
movl   $0x0,-0x2064(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
movslq -0x2058(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x2070(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
mov    -0x2058(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
sub    $0x1,%rax
mov    %rax,-0x2078(%rbp)
mov    -0x2058(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12e3 <getResource+0x143>
mov    -0x30(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x2078(%rbp)
mov    -0x2070(%rbp),%rsi
mov    -0x2078(%rbp),%rdx
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2060(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    0xd08(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    %eax,-0x2064(%rbp)
mov    -0x2064(%rbp),%ecx
mov    -0x2060(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2060(%rbp)
mov    -0x2060(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    0xcdd(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    %eax,-0x2064(%rbp)
mov    -0x2064(%rbp),%ecx
mov    -0x2060(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2060(%rbp)
mov    -0x2060(%rbp),%rdi
mov    -0x2070(%rbp),%rdx
mov    -0x2078(%rbp),%rcx
mov    -0x50(%rbp),%r8
lea    0xca1(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    %eax,-0x2064(%rbp)
mov    -0x2064(%rbp),%ecx
mov    -0x2060(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2060(%rbp)
mov    -0x2060(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xc7f(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    %eax,-0x2064(%rbp)
mov    -0x2064(%rbp),%ecx
mov    -0x2060(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2060(%rbp)
mov    -0x2060(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xc21(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    %eax,-0x2064(%rbp)
mov    -0x2064(%rbp),%ecx
mov    -0x2060(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x2060(%rbp)
mov    -0x2060(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movslq -0x2058(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x207c(%rbp)
cmpl   $0x0,-0x207c(%rbp)
jl     14dd <getResource+0x33d>
mov    -0x207c(%rbp),%edi
lea    -0x2050(%rbp),%rsi
mov    -0x2060(%rbp),%rax
lea    -0x2050(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x2080(%rbp)
cmpl   $0x0,-0x2080(%rbp)
jge    14d8 <getResource+0x338>
mov    0x2b44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30d8(%rbp)
mov    -0x2080(%rbp),%eax
mov    %eax,-0x30d4(%rbp)
mov    -0x2080(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    -0x30d8(%rbp),%edi
mov    -0x30d4(%rbp),%edx
mov    %rax,%rcx
lea    0xb94(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    14dd <getResource+0x33d>
jmp    14e2 <getResource+0x342>
mov    -0x2058(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2058(%rbp)
jmp    1252 <getResource+0xb2>
lea    0xb78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x2088(%rbp)
movl   $0x0,-0x208c(%rbp)
mov    -0x208c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1559 <getResource+0x3b9>
mov    -0x208c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
or     -0x2088(%rbp),%rax
mov    %rax,-0x2088(%rbp)
mov    -0x208c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208c(%rbp)
jmp    1519 <getResource+0x379>
jmp    155e <getResource+0x3be>
movl   $0xa,-0x20a0(%rbp)
movq   $0x0,-0x2098(%rbp)
lea    -0x2090(%rbp),%rdi
call   1090 <FD_ZERO@plt>
movl   $0xffffffff,-0x20a4(%rbp)
ff ff ff
movl   $0x0,-0x20a8(%rbp)
mov    -0x20a8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1603 <getResource+0x463>
mov    -0x8(%rbp),%rax
movslq -0x20a8(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    -0x2090(%rbp),%rsi
call   10c0 <FD_SET@plt>
mov    -0x8(%rbp),%rax
movslq -0x20a8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x20a4(%rbp),%eax
jle    15ea <getResource+0x44a>
mov    -0x8(%rbp),%rax
movslq -0x20a8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20a4(%rbp)
jmp    15ef <getResource+0x44f>
mov    -0x20a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20a8(%rbp)
jmp    1593 <getResource+0x3f3>
mov    -0x20a4(%rbp),%edi
add    $0x1,%edi
lea    -0x2090(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20a0(%rbp),%r8
mov    %rcx,%rdx
call   10a0 <select@plt>
mov    %eax,-0x20ac(%rbp)
cmpl   $0x0,-0x20ac(%rbp)
jge    1650 <getResource+0x4b0>
mov    0x29a0(%rip),%rax
mov    (%rax),%edi
lea    0xa39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0x0,-0x20ac(%rbp)
jne    1674 <getResource+0x4d4>
mov    0x297c(%rip),%rax
mov    (%rax),%edi
lea    0xa2c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0x0,-0x20ac(%rbp)
jle    1784 <getResource+0x5e4>
movl   $0x0,-0x20b0(%rbp)
mov    -0x20b0(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    177f <getResource+0x5df>
mov    -0x8(%rbp),%rax
movslq -0x20b0(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20b4(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20b0(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20b8(%rbp)
mov    -0x20b4(%rbp),%edi
lea    -0x2090(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1766 <getResource+0x5c6>
mov    -0x20b4(%rbp),%edi
lea    -0x30c0(%rbp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
mov    %eax,-0x30c4(%rbp)
cmpl   $0x0,-0x30c4(%rbp)
jle    1734 <getResource+0x594>
mov    -0x20b8(%rbp),%edi
lea    -0x30c0(%rbp),%rsi
mov    -0x30c4(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x30c8(%rbp)
lea    0x981(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x30c4(%rbp)
jne    1761 <getResource+0x5c1>
mov    -0x20b0(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
cltq
and    -0x2088(%rbp),%rax
mov    %rax,-0x2088(%rbp)
jmp    1766 <getResource+0x5c6>
jmp    176b <getResource+0x5cb>
mov    -0x20b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20b0(%rbp)
jmp    168b <getResource+0x4eb>
jmp    1784 <getResource+0x5e4>
jmp    1789 <getResource+0x5e9>
cmpq   $0x0,-0x2088(%rbp)
jne    155e <getResource+0x3be>
jmp    179c <getResource+0x5fc>
mov    -0x34(%rbp),%eax
add    $0x30e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getResource>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3088,%rsp
mov    %r8,0x28(%rsp)
mov    %rcx,0x30(%rsp)
mov    %edx,%ecx
cmpl   $0x0,0x30c0(%rsp)
lea    0xe15(%rip),%rax
lea    0xe0d(%rip),%rdx
cmove  %rax,%rdx
mov    %rdx,0x48(%rsp)
mov    %rsi,0x60(%rsp)
test   %rsi,%rsi
je     15de <getResource+0x41e>
mov    %rdi,%r12
test   %rdi,%rdi
je     15de <getResource+0x41e>
cmpq   $0x0,0x30(%rsp)
je     15de <getResource+0x41e>
cmpq   $0x0,0x28(%rsp)
je     15de <getResource+0x41e>
mov    %ecx,%r15d
test   %ecx,%ecx
mov    %rcx,0x10(%rsp)
mov    %r15,0x38(%rsp)
jle    1252 <getResource+0x92>
mov    %r9,%rax
shr    $0x20,%rax
je     1267 <getResource+0xa7>
mov    %r9,%rax
cqto
idiv   %r15
jmp    126f <getResource+0xaf>
lea    0xe1c(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1489 <getResource+0x2c9>
mov    %r9d,%eax
xor    %edx,%edx
div    %r15d
mov    %rax,0x18(%rsp)
lea    -0x1(%rcx),%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
xor    %ecx,%ecx
mov    %r9,0x40(%rsp)
mov    0x48(%rsp),%r14
jmp    12ad <getResource+0xed>
nopl   0x0(%rax)
mov    0x38(%rsp),%r15
mov    0x58(%rsp),%rcx
cmp    %rcx,%r15
mov    0x40(%rsp),%r9
mov    0x8(%rsp),%rax
je     13dd <getResource+0x21d>
mov    %rcx,0x50(%rsp)
mov    %rax,%r15
lea    0x1(%rcx),%rax
mov    %rax,0x58(%rsp)
mov    0x18(%rsp),%rax
lea    (%rax,%r15,1),%rbx
cmp    %rcx,0x20(%rsp)
mov    %rbx,0x8(%rsp)
cmove  %r9,%rbx
add    $0xffffffffffffffff,%rbx
lea    0xd23(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x80(%rsp),%rdi
lea    0xd21(%rip),%rsi
mov    0x30(%rsp),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
cltq
lea    (%rsp,%rax,1),%rbp
add    $0x80,%rbp
mov    %rbp,%rdi
lea    0xd0d(%rip),%rsi
mov    0x28(%rsp),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
movslq %eax,%r13
add    %rbp,%r13
mov    %r13,%rdi
lea    0xcf9(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   10d0 <sprintf@plt>
movslq %eax,%rbx
add    %r13,%rbx
mov    %rbx,%rdi
lea    0xcf0(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10d0 <sprintf@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <stpcpy@plt>
sub    %ebp,%eax
cltq
movb   $0x0,(%rax,%rbp,1)
mov    0x50(%rsp),%rcx
mov    (%r12,%rcx,4),%edi
test   %edi,%edi
js     1290 <getResource+0xd0>
add    %rax,%rbp
lea    0x80(%rsp),%rsi
sub    %esi,%ebp
mov    %ebp,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    1290 <getResource+0xd0>
mov    %eax,%ebp
mov    0x2c26(%rip),%rax
mov    (%rax),%ebx
mov    %ebp,%edi
call   1080 <gai_strerror@plt>
mov    %ebx,%edi
lea    0xc99(%rip),%rsi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1290 <getResource+0xd0>
lea    0xc91(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rcx
test   %ecx,%ecx
jle    1407 <getResource+0x247>
mov    %ecx,%eax
and    $0x3,%eax
cmpl   $0x3,0x20(%rsp)
jae    140b <getResource+0x24b>
xor    %ebp,%ebp
jmp    146c <getResource+0x2ac>
xor    %ebp,%ebp
jmp    1489 <getResource+0x2c9>
mov    %ecx,%edx
and    $0xfffffffc,%edx
xor    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%esi
mov    %r14d,%ecx
shl    %cl,%esi
lea    0x1(%r14),%ecx
mov    $0x1,%edi
shl    %cl,%edi
movslq %esi,%rsi
or     %rbp,%rsi
movslq %edi,%rdi
lea    0x2(%r14),%ecx
mov    $0x1,%ebx
shl    %cl,%ebx
movslq %ebx,%rbx
or     %rdi,%rbx
or     %rsi,%rbx
lea    0x3(%r14),%ecx
mov    $0x1,%esi
shl    %cl,%esi
movslq %esi,%rbp
or     %rbx,%rbp
add    $0x4,%r14d
cmp    %edx,%r14d
jne    1420 <getResource+0x260>
test   %eax,%eax
je     1489 <getResource+0x2c9>
mov    $0x1,%edx
mov    %r14d,%ecx
shl    %cl,%edx
movslq %edx,%rcx
or     %rcx,%rbp
add    $0x1,%r14d
add    $0xffffffff,%eax
jne    1470 <getResource+0x2b0>
mov    %rbp,0x8(%rsp)
lea    0x6c(%rsp),%r13
jmp    14bc <getResource+0x2fc>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmpq   $0x0,0x8(%rsp)
je     15de <getResource+0x41e>
movl   $0xa,0x70(%rsp)
movq   $0x0,0x78(%rsp)
mov    %r13,%rdi
call   10b0 <FD_ZERO@plt>
cmpl   $0x0,0x10(%rsp)
jle    1510 <getResource+0x350>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,4),%edi
mov    %r13,%rsi
call   10e0 <FD_SET@plt>
mov    (%r12,%rbx,4),%eax
cmp    %ebp,%eax
cmovg  %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    14f0 <getResource+0x330>
jmp    1515 <getResource+0x355>
mov    $0xffffffff,%ebp
add    $0x1,%ebp
mov    %ebp,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0x70(%rsp),%r8
call   10c0 <select@plt>
lea    0xb50(%rip),%rsi
test   %eax,%eax
js     14a0 <getResource+0x2e0>
lea    0xb58(%rip),%rsi
je     14a0 <getResource+0x2e0>
cmpl   $0x0,0x10(%rsp)
jle    14b0 <getResource+0x2f0>
xor    %ebp,%ebp
jmp    158a <getResource+0x3ca>
cs nopw 0x0(%rax,%rax,1)
mov    $0xfffffffe,%eax
mov    %ebp,%ecx
rol    %cl,%eax
neg    %r15d
sbb    %ecx,%ecx
or     %eax,%ecx
movslq %ecx,%rax
and    %rax,0x8(%rsp)
mov    0x38(%rsp),%r15
add    $0x1,%rbp
cmp    %rbp,%r15
je     14b0 <getResource+0x2f0>
mov    (%r12,%rbp,4),%ebx
mov    0x60(%rsp),%rax
mov    (%rax,%rbp,4),%r14d
mov    %ebx,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     157d <getResource+0x3bd>
mov    %ebx,%edi
lea    0x2080(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1090 <read@plt>
mov    %eax,%r15d
test   %eax,%eax
jle    1560 <getResource+0x3a0>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <write@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
jmp    1560 <getResource+0x3a0>
xor    %eax,%eax
add    $0x3088,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [26 x i8] c"output range %ld -- %ld \0A\00"
@.str.3 = [18 x i8] c"GET %s HTTP/1.1%s\00"
@.str.4 = [11 x i8] c"Host: %s%s\00"
@.str.5 = [23 x i8] c"Range: bytes=%ld-%ld%s\00"
@.str.6 = [20 x i8] c"Connection: close%s\00"
@stderr = global i32 0
@.str.8 = [16 x i8] c"write: %d : %s\0A\00"
@.str.9 = [13 x i8] c"\0Adownloading\00"
@.str.10 = [23 x i8] c"poll errorrom socket \0A\00"
@.str.11 = [21 x i8] c"tiemout rom socket \0A\00"
define i32 @getResource(i32* %0, i32* %1, i32 %2, i8* %3, i8* %4, i64 %5, i32 %6) {
%8 = alloca [8192 x i8]
%9 = alloca i32
%10 = alloca %struct.timeval
%11 = alloca [4096 x i8]
%12 = icmp eq i32 %6, 0
%13 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%14 = icmp ne i8* %3, null
%15 = icmp ne i8* %4, null
%16 = and i1 %14, %15
%17 = icmp ne i32* %0, null
%18 = and i1 %17, %16
%19 = icmp ne i32* %1, null
%20 = and i1 %19, %18
br i1 %20, label %21, label %187
21: ; preds = %7
%22 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 0
%23 = icmp sgt i32 %2, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %99
26: ; preds = %21
%27 = zext i32 %2 to i64
%28 = sdiv i64 %5, %27
%29 = add nsw i32 %2, -1
%30 = ptrtoint [8192 x i8]* %8 to i64
%31 = zext i32 %29 to i64
%32 = zext i32 %2 to i64
br label %41
33: ; preds = %82
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br i1 %23, label %35, label %99
35: ; preds = %33
%36 = add i32 %2, -1
%37 = and i32 %2, 3
%38 = icmp ult i32 %36, 3
br i1 %38, label %84, label %39
39: ; preds = %35
%40 = and i32 %2, -4
br label %108
41: ; preds = %26, %82
%42 = phi i64 [ 0, %26 ], [ %44, %82 ]
%43 = mul nsw i64 %28, %42
%44 = add nuw nsw i64 %42, 1
%45 = mul nsw i64 %28, %44
%46 = icmp eq i64 %42, %31
%47 = select i1 %46, i64 %5, i64 %45
%48 = add nsw i64 %47, -1
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 %43, i64 %48)
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %13)
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [8192 x i8], [8192 x i8]* %8, i64 0, i64 %51
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* %13)
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* %55, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i64 %43, i64 %48, i8* %13)
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = call i32 (i8*, i8*, ...) @sprintf(i8* %58, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = call i8* @stpcpy(i8* %61, i8* %13)
%63 = ptrtoint i8* %62 to i64
%64 = ptrtoint i8* %61 to i64
%65 = sub i64 %63, %64
%66 = shl i64 %65, 32
%67 = ashr exact i64 %66, 32
%68 = getelementptr inbounds i8, i8* %61, i64 %67
store i8 0, i8* %68
%69 = getelementptr inbounds i32, i32* %0, i64 %42
%70 = load i32, i32* %69
%71 = icmp sgt i32 %70, -1
br i1 %71, label %72, label %82
72: ; preds = %41
%73 = ptrtoint i8* %68 to i64
%74 = sub i64 %73, %30
%75 = trunc i64 %74 to i32
%76 = call i32 @write(i32 %70, i8* %22, i32 %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %72
%79 = load i32, i32* @stderr
%80 = call i8* @gai_strerror(i32 %76)
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 %76, i8* %80)
br label %82
82: ; preds = %72, %78, %41
%83 = icmp eq i64 %44, %32
br i1 %83, label %33, label %41
84: ; preds = %108, %35
%85 = phi i64 [ undef, %35 ], [ %126, %108 ]
%86 = phi i64 [ 0, %35 ], [ %126, %108 ]
%87 = phi i32 [ 0, %35 ], [ %127, %108 ]
%88 = icmp eq i32 %37, 0
br i1 %88, label %99, label %89
89: ; preds = %84, %89
%90 = phi i64 [ %95, %89 ], [ %86, %84 ]
%91 = phi i32 [ %96, %89 ], [ %87, %84 ]
%92 = phi i32 [ %97, %89 ], [ 0, %84 ]
%93 = shl nuw i32 1, %91
%94 = sext i32 %93 to i64
%95 = or i64 %90, %94
%96 = add nuw nsw i32 %91, 1
%97 = add i32 %92, 1
%98 = icmp eq i32 %97, %37
br i1 %98, label %99, label %89
99: ; preds = %84, %89, %24, %33
%100 = phi i64 [ 0, %33 ], [ 0, %24 ], [ %85, %84 ], [ %95, %89 ]
%101 = bitcast i32* %9 to i8*
%102 = bitcast %struct.timeval* %10 to i8*
%103 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%104 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%105 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%106 = zext i32 %2 to i64
%107 = zext i32 %2 to i64
br label %130
108: ; preds = %108, %39
%109 = phi i64 [ 0, %39 ], [ %126, %108 ]
%110 = phi i32 [ 0, %39 ], [ %127, %108 ]
%111 = phi i32 [ 0, %39 ], [ %128, %108 ]
%112 = shl nuw i32 1, %110
%113 = sext i32 %112 to i64
%114 = or i64 %109, %113
%115 = or i32 %110, 1
%116 = shl nuw i32 1, %115
%117 = sext i32 %116 to i64
%118 = or i64 %114, %117
%119 = or i32 %110, 2
%120 = shl nuw i32 1, %119
%121 = sext i32 %120 to i64
%122 = or i64 %118, %121
%123 = or i32 %110, 3
%124 = shl nuw i32 1, %123
%125 = sext i32 %124 to i64
%126 = or i64 %122, %125
%127 = add nuw nsw i32 %110, 4
%128 = add i32 %111, 4
%129 = icmp eq i32 %128, %40
br i1 %129, label %84, label %108
130: ; preds = %99, %183
%131 = phi i64 [ %184, %183 ], [ %100, %99 ]
store i32 10, i32* %103
store i64 0, i64* %104
%132 = call i32 @FD_ZERO(i32* %9)
br i1 %23, label %138, label %133
133: ; preds = %138, %130
%134 = phi i32 [ -1, %130 ], [ %146, %138 ]
%135 = add nsw i32 %134, 1
%136 = call i32 @select(i32 %135, i32* %9, i32* null, i32* null, %struct.timeval* %10)
%137 = icmp slt i32 %136, 0
br i1 %137, label %179, label %149
138: ; preds = %130, %138
%139 = phi i64 [ %147, %138 ], [ 0, %130 ]
%140 = phi i32 [ %146, %138 ], [ -1, %130 ]
%141 = getelementptr inbounds i32, i32* %0, i64 %139
%142 = load i32, i32* %141
%143 = call i32 @FD_SET(i32 %142, i32* %9)
%144 = load i32, i32* %141
%145 = icmp sgt i32 %144, %140
%146 = select i1 %145, i32 %144, i32 %140
%147 = add nuw nsw i64 %139, 1
%148 = icmp eq i64 %147, %106
br i1 %148, label %133, label %138
149: ; preds = %133
%150 = icmp eq i32 %136, 0
br i1 %150, label %179, label %151
151: ; preds = %149
br i1 %23, label %152, label %183
152: ; preds = %151, %175
%153 = phi i64 [ %177, %175 ], [ 0, %151 ]
%154 = phi i64 [ %176, %175 ], [ %131, %151 ]
%155 = getelementptr inbounds i32, i32* %0, i64 %153
%156 = load i32, i32* %155
%157 = getelementptr inbounds i32, i32* %1, i64 %153
%158 = load i32, i32* %157
%159 = call i64 @FD_ISSET(i32 %156, i32* %9)
%160 = icmp eq i64 %159, 0
br i1 %160, label %175, label %161
161: ; preds = %152
%162 = call i32 @read(i32 %156, i8* %105, i32 4096)
%163 = icmp sgt i32 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %161
%165 = call i32 @write(i32 %158, i8* %105, i32 %162)
%166 = call i32 @putchar(i32 46)
br label %167
167: ; preds = %164, %161
%168 = icmp eq i32 %162, 0
%169 = trunc i64 %153 to i32
%170 = shl nuw i32 1, %169
%171 = xor i32 %170, -1
%172 = select i1 %168, i32 %171, i32 -1
%173 = sext i32 %172 to i64
%174 = and i64 %154, %173
br label %175
175: ; preds = %167, %152
%176 = phi i64 [ %174, %167 ], [ %154, %152 ]
%177 = add nuw nsw i64 %153, 1
%178 = icmp eq i64 %177, %107
br i1 %178, label %183, label %152
179: ; preds = %149, %133
%180 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), %133 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), %149 ]
%181 = load i32, i32* @stderr
%182 = call i32 (i32, i8*, ...) @fprintf(i32 %181, i8* %180)
br label %183
183: ; preds = %175, %179, %151
%184 = phi i64 [ %131, %151 ], [ %131, %179 ], [ %176, %175 ]
%185 = icmp eq i64 %184, 0
br i1 %185, label %186, label %130
186: ; preds = %183
br label %187
187: ; preds = %186, %7
ret i32 0
}