#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 sockaddr_in {
  char sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct in_addr {
  int dummy;
};
struct hostent {
  char *h_name;
  char **h_addr_list;
  int h_length;
};
typedef int /*<<< orphan*/ s_address;
typedef int /*<<< orphan*/ host_url;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(struct in_addr);
char *malloc(int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
char *realloc(char *, int);
int /*<<< orphan*/ shutdown(int, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strlen(char *);
char *strstr(char *, char *);
scalar_t__ write(int, char *, int);
int s(char *host_url, int jump, char *file) {
  int port = 80;
  int soc;
  struct sockaddr_in s_address;
  struct hostent *host;
  struct in_addr **addr_list;
  char *get = NULL;
  int response;
  if (file == NULL) {
    file = malloc(sizeof("index.html"));
    if (file == NULL) {
      fprintf(stderr, "Malloc error\n");
      return 1;
    }
    memcpy(file, "index.html", strlen("index.html"));
  }
  if (jump > 5) {
    fprintf(stderr, "Too many redirections.\n");
    return 1;
  }
  char *hs;
  char *u;
  char *url;
  char *p;
  if (memcmp(host_url, "http://", 7) == 0) {
    hs = malloc(sizeof(host_url));
    memcpy(hs, host_url + 7, strlen(host_url));
  } else {
    hs = host_url;
  }
  u = strchr(hs, '/');
  if (u == 0) {
    url = malloc(sizeof(char) * 2);
    if (url == NULL) {
      fprintf(stderr, "Malloc error\n");
      return 1;
    }
    url[0] = '/';
    url[1] = '\0';
  }
  if (u != NULL) {
    url = malloc(sizeof(*u) + 1);
    if (url == NULL) {
      fprintf(stderr, "Malloc error\n");
      return 1;
    }
    memcpy(u, url, sizeof(*u));
  }
  printf("%s\n", url);
  if (u != NULL) {
    hs[strlen(hs) - strlen(url)] = '\0';
    url[strlen(url)] = '\0';
  }
  if (strlen(url) == 0) {
    url[0] = '/';
    url[1] = '\0';
  }
  p = strchr(hs, ':');
  if (p != NULL) {
    port = atoi(p + 1);
    hs[strlen(hs) - strlen(p)] = '\0';
  }
  printf("port: %d,\nhost: %s,\nurl: %s\n", port, hs, url);
  soc = socket(PF_INET, SOCK_STREAM, 0);
  if (soc < 0) {
    fprintf(stderr, "Socket error.\n");
    return 1;
  }
  bzero(&s_address, sizeof(s_address));
  s_address.sin_family = AF_INET;
  if ((host = gethostbyname(hs)) == NULL) {
    fprintf(stderr, "Unknown host.\n");
    return 1;
  }
  printf("Official name is: %s\n", host->h_name);
  printf("<--- IP addresses --->\n");
  addr_list = (struct in_addr **)host->h_addr_list;
  for (int i = 0; addr_list[i] != NULL; i++) {
    printf("    %s\n", inet_ntoa(*addr_list[i]));
  }
  printf("\n");
  memcpy(&s_address.sin_addr, host->h_addr_list[0], host->h_length);
  s_address.sin_port = htons(port);
  if (connect(soc, (struct sockaddr *)&s_address, sizeof(s_address)) < 0) {
    fprintf(stderr, "D'OH! Server is dead.\n");
    return 1;
  }
  printf("Connected!\n\n");
  get = malloc((strlen("GET /") + strlen(url) + strlen(" HTTP/1.0\r\nHost: ") +
                strlen(hs) + strlen("\r\n\r\n")) *
               sizeof(char));
  if (get == NULL) {
    fprintf(stderr, "Malloc error\n");
    return 1;
  }
  get[0] = '\0';
  strcat(get, "GET ");
  strcat(get, url);
  strcat(get, " HTTP/1.0\r\nHost: ");
  strcat(get, host->h_name);
  strcat(get, "\r\n\r\n");
  printf("%s\n", get);
  if ((write(soc, get, strlen(get))) <= 0) {
    fprintf(stderr, "Write error.\n");
    return 1;
  }
  printf("Reading...\n");
  char *header;
  int alloc_size = 1;
  int i = 0;
  header = malloc(sizeof(char) * alloc_size);
  if (header == NULL) {
    fprintf(stderr, "Allocation error\n");
    return 1;
  }
  while (strstr(header, "\r\n\r\n") == NULL) {
    read(soc, header + i, 1);
    i++;
    if (i >= alloc_size) {
      alloc_size *= 2;
      header = realloc(header, sizeof(char) * alloc_size);
      if (header == NULL) {
        fprintf(stderr, "Reallocation error\n");
        return 1;
      }
    }
  }
  printf("Header:\n%s", header);
  response = atoi(header + 9);
  printf("Response: %d\n", response);
  char *location = NULL;
  if (response >= 300 && response < 400) {
    location = strstr(header, "Location: ") + strlen("Location: ");
    i = 0;
    char *l = strchr(location, '\r');
    l[0] = '\0';
  }
  if (response == 200) {
    printf("Downloading...\n");
    FILE *fp = fopen(file, "w");
    if (fp == NULL) {
      fprintf(stderr, "Error opening file\n");
      return 1;
    }
    char socketchar[1];
    while (read(soc, socketchar, 1) > 0) {
      fwrite(socketchar, sizeof(char), 1, fp);
    }
    fclose(fp);
  }
  if (response >= 300 && response < 400) {
    printf("Redirected...\n");
    printf("%s\n", location);
    s(location, ++jump, file);
  }
  shutdown(soc, 2);
  close(soc);
  return 0;
}


x86 assembly (clang, -O0):

:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x50,-0x24(%rbp)
movq   $0x0,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1326 <s+0x96>
mov    $0xb,%edi
call   1110 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12fa <s+0x6a>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
lea    0xd17(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
mov    -0x20(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    0xd02(%rip),%rdi
call   1070 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%edx
lea    0xced(%rip),%rsi
call   1100 <memcpy@plt>
cmpl   $0x5,-0x14(%rbp)
jle    1351 <s+0xc1>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
lea    0xcd9(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
mov    -0x10(%rbp),%rdi
lea    0xcd5(%rip),%rsi
mov    $0x7,%edx
call   10d0 <memcmp@plt>
cmp    $0x0,%rax
jne    13bb <s+0x12b>
mov    $0x8,%edi
call   1110 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0xc0(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
mov    %eax,%edx
call   1100 <memcpy@plt>
jmp    13c3 <s+0x133>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    $0x2f,%esi
call   1090 <strchr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1429 <s+0x199>
mov    $0x2,%edi
call   1110 <malloc@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    141a <s+0x18a>
mov    0x2bd8(%rip),%rax
mov    (%rax),%edi
lea    0xbf7(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
mov    -0x70(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x70(%rbp),%rax
movb   $0x0,0x1(%rax)
cmpq   $0x0,-0x68(%rbp)
je     1480 <s+0x1f0>
mov    $0x2,%edi
call   1110 <malloc@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    146e <s+0x1de>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
lea    0xba3(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    $0x1,%edx
call   1100 <memcpy@plt>
mov    -0x70(%rbp),%rsi
lea    0xc1b(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
cmpq   $0x0,-0x68(%rbp)
je     14fc <s+0x26c>
mov    -0x60(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x60(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0xdc(%rbp)
mov    -0x70(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xdc(%rbp),%ecx
mov    %eax,%edx
mov    -0xd8(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x70(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0xd0(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x70(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x0,%eax
jne    151d <s+0x28d>
mov    -0x70(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x70(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x60(%rbp),%rdi
mov    $0x3a,%esi
call   1090 <strchr@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1585 <s+0x2f5>
mov    -0x78(%rbp),%rdi
add    $0x1,%rdi
call   1160 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x60(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0xec(%rbp)
mov    -0x78(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xec(%rbp),%ecx
mov    %eax,%edx
mov    -0xe8(%rbp),%rax
sub    %edx,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%esi
mov    -0x60(%rbp),%rdx
mov    -0x70(%rbp),%rcx
lea    0xaa2(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    0x2a23(%rip),%rax
mov    (%rax),%edi
mov    0x2a22(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11b0 <socket@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    15e5 <s+0x355>
mov    0x2a0d(%rip),%rax
mov    (%rax),%edi
lea    0xa82(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
lea    -0x38(%rbp),%rdi
mov    $0xc,%esi
call   1150 <bzero@plt>
mov    0x29ee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x60(%rbp),%rdi
call   10e0 <gethostbyname@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1637 <s+0x3a7>
mov    0x29bb(%rip),%rax
mov    (%rax),%edi
lea    0xa3f(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xa2f(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0xa37(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x7c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     16b2 <s+0x422>
mov    -0x48(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xa05(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    166d <s+0x3dd>
lea    0xa13(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rsi
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edx
call   1100 <memcpy@plt>
mov    -0x24(%rbp),%edi
call   1080 <htons@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   1180 <connect@plt>
cmp    $0x0,%rax
jge    1722 <s+0x492>
mov    0x28d0(%rip),%rax
mov    (%rax),%edi
lea    0x999(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
lea    0x998(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
lea    0x997(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,-0xfc(%rbp)
mov    -0x70(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0xfc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xf8(%rbp)
lea    0x972(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0xf8(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xf4(%rbp)
mov    -0x60(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0xf4(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xf0(%rbp)
lea    0x94f(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0xf0(%rbp),%eax
add    %ecx,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1110 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    17e3 <s+0x553>
mov    0x280f(%rip),%rax
mov    (%rax),%edi
lea    0x82e(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rdi
lea    0x8f6(%rip),%rsi
call   1170 <strcat@plt>
mov    -0x50(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1170 <strcat@plt>
mov    -0x50(%rbp),%rdi
lea    0x8c2(%rip),%rsi
call   1170 <strcat@plt>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
call   1170 <strcat@plt>
mov    -0x50(%rbp),%rdi
lea    0x8b4(%rip),%rsi
call   1170 <strcat@plt>
mov    -0x50(%rbp),%rsi
lea    0x864(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x10c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x10c(%rbp),%edi
mov    -0x108(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jg     18a5 <s+0x615>
mov    0x274d(%rip),%rax
mov    (%rax),%edi
lea    0x85c(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
lea    0x852(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
movl   $0x1,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
movslq -0x8c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1110 <malloc@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    190f <s+0x67f>
mov    0x26e3(%rip),%rax
mov    (%rax),%edi
lea    0x80c(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
jmp    1914 <s+0x684>
mov    -0x88(%rbp),%rdi
lea    0x7c4(%rip),%rsi
call   11a0 <strstr@plt>
cmp    $0x0,%rax
jne    19d8 <s+0x748>
mov    -0x28(%rbp),%edi
mov    -0x88(%rbp),%rsi
movslq -0x90(%rbp),%rax
add    %rax,%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x8c(%rbp),%eax
jl     19d3 <s+0x743>
mov    -0x8c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x88(%rbp),%rdi
movslq -0x8c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1130 <realloc@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    19ce <s+0x73e>
mov    0x2624(%rip),%rax
mov    (%rax),%edi
lea    0x75f(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
jmp    19d3 <s+0x743>
jmp    1914 <s+0x684>
mov    -0x88(%rbp),%rsi
lea    0x74a(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x88(%rbp),%rdi
add    $0x9,%rdi
call   1160 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
lea    0x731(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
movq   $0x0,-0x98(%rbp)
cmpl   $0x12c,-0x54(%rbp)
jl     1a9e <s+0x80e>
cmpl   $0x190,-0x54(%rbp)
jge    1a9e <s+0x80e>
mov    -0x88(%rbp),%rdi
lea    0x705(%rip),%rsi
call   11a0 <strstr@plt>
mov    %rax,-0x118(%rbp)
lea    0x6f2(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x118(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x98(%rbp)
movl   $0x0,-0x90(%rbp)
mov    -0x98(%rbp),%rdi
mov    $0xd,%esi
call   1090 <strchr@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rax
movb   $0x0,(%rax)
cmpl   $0xc8,-0x54(%rbp)
jne    1b4d <s+0x8bd>
lea    0x6a2(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0x6a0(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    1aff <s+0x86f>
mov    0x24f3(%rip),%rax
mov    (%rax),%edi
lea    0x678(%rip),%rsi
call   10f0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1bbf <s+0x92f>
jmp    1b04 <s+0x874>
mov    -0x28(%rbp),%edi
lea    -0xa9(%rbp),%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
cmp    $0x0,%rax
jle    1b41 <s+0x8b1>
lea    -0xa9(%rbp),%rdi
mov    -0xa8(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1190 <fwrite@plt>
jmp    1b04 <s+0x874>
mov    -0xa8(%rbp),%rdi
call   1050 <fclose@plt>
cmpl   $0x12c,-0x54(%rbp)
jl     1ba3 <s+0x913>
cmpl   $0x190,-0x54(%rbp)
jge    1ba3 <s+0x913>
lea    0x60c(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x98(%rbp),%rsi
lea    0x523(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x98(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
mov    -0x20(%rbp),%rdx
call   1120 <s@plt>
mov    -0x28(%rbp),%edi
mov    $0x2,%esi
call   1060 <shutdown@plt>
mov    -0x28(%rbp),%edi
call   10b0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):

:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%r13
test   %rdx,%rdx
je     12e5 <s+0x35>
cmp    $0x6,%ebp
jl     131c <s+0x6c>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
jmp    1758 <s+0x4a8>
mov    $0xb,%edi
call   1140 <malloc@plt>
test   %rax,%rax
je     1700 <s+0x450>
mov    %rax,%r12
lea    0xd0c(%rip),%rbx
mov    %rbx,%rdi
call   1090 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1130 <memcpy@plt>
cmp    $0x6,%ebp
jge    12d0 <s+0x20>
lea    0xd0e(%rip),%rsi
mov    %r13,%rdi
mov    $0x7,%edx
call   1100 <memcmp@plt>
test   %rax,%rax
jne    135e <s+0xae>
mov    $0x8,%edi
call   1140 <malloc@plt>
mov    %rax,%rbx
lea    0x7(%r13),%r14
mov    %r13,%rdi
call   1090 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1130 <memcpy@plt>
mov    %rbx,%r13
mov    %r13,%rdi
mov    $0x2f,%esi
call   10b0 <strchr@plt>
mov    %rax,%rbx
mov    $0x2,%edi
call   1140 <malloc@plt>
mov    %rax,%r15
test   %rbx,%rbx
je     13cf <s+0x11f>
test   %r15,%r15
je     1700 <s+0x450>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1130 <memcpy@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1090 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1090 <strlen@plt>
sub    %eax,%ebx
movslq %ebx,%rax
movb   $0x0,0x0(%r13,%rax,1)
mov    %r15,%rdi
call   1090 <strlen@plt>
cltq
movb   $0x0,(%r15,%rax,1)
jmp    13e6 <s+0x136>
test   %r15,%r15
je     1700 <s+0x450>
movw   $0x2f,(%r15)
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1090 <strlen@plt>
test   %eax,%eax
jne    13f8 <s+0x148>
movw   $0x2f,(%r15)
mov    %ebp,0x14(%rsp)
mov    %r13,%rdi
mov    $0x3a,%esi
call   10b0 <strchr@plt>
test   %rax,%rax
je     143f <s+0x18f>
mov    %rax,%rbx
mov    %rax,%rdi
add    $0x1,%rdi
call   1190 <atoi@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   1090 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1090 <strlen@plt>
sub    %eax,%ebp
movslq %ebp,%rax
movb   $0x0,0x0(%r13,%rax,1)
jmp    1445 <s+0x195>
mov    $0x50,%r14d
lea    0xbed(%rip),%rdi
mov    %r14d,%esi
mov    %r13,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   10c0 <printf@plt>
mov    0x2b65(%rip),%rax
mov    (%rax),%edi
mov    0x2b64(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11d0 <socket@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     1712 <s+0x462>
mov    %r14d,0x10(%rsp)
lea    0x18(%rsp),%rdi
mov    $0xc,%esi
call   1180 <bzero@plt>
mov    0x2b4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    %r13,%rdi
call   1110 <gethostbyname@plt>
test   %rax,%rax
je     1724 <s+0x474>
mov    %rax,%r14
mov    (%rax),%rsi
lea    0xbb4(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
lea    0xc6b(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%r14),%rbp
mov    0x0(%rbp),%rax
test   %rax,%rax
je     1511 <s+0x261>
add    $0x8,%rbp
lea    0xb9f(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rax),%edi
call   1060 <inet_ntoa@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    0x0(%rbp),%rax
add    $0x8,%rbp
test   %rax,%rax
jne    14f0 <s+0x240>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%r14),%rax
mov    (%rax),%rsi
mov    0x10(%r14),%edx
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1130 <memcpy@plt>
mov    0x10(%rsp),%edi
call   10a0 <htons@plt>
mov    %eax,0x1c(%rsp)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   11b0 <connect@plt>
test   %rax,%rax
js     1736 <s+0x486>
lea    0xbef(%rip),%rdi
call   1040 <puts@plt>
lea    0xb3c(%rip),%rdi
call   1090 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1090 <strlen@plt>
add    %eax,%ebx
lea    0xb2a(%rip),%rdi
call   1090 <strlen@plt>
add    %eax,%ebx
mov    %r13,%rdi
call   1090 <strlen@plt>
add    %eax,%ebx
lea    0xb24(%rip),%rdi
call   1090 <strlen@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1140 <malloc@plt>
test   %rax,%rax
je     1700 <s+0x450>
mov    %rax,%rbp
movb   $0x0,(%rax)
lea    0xb05(%rip),%rsi
mov    %rax,%rdi
call   11a0 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   11a0 <strcat@plt>
lea    0xad4(%rip),%rsi
mov    %rbp,%rdi
call   11a0 <strcat@plt>
mov    (%r14),%rsi
mov    %rbp,%rdi
call   11a0 <strcat@plt>
lea    0xacc(%rip),%rsi
mov    %rbp,%rdi
call   11a0 <strcat@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1090 <strlen@plt>
mov    0xc(%rsp),%r13d
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <write@plt>
test   %rax,%rax
jle    1748 <s+0x498>
lea    0xb2d(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    $0x1,%edi
call   1140 <malloc@plt>
test   %rax,%rax
je     1773 <s+0x4c3>
mov    %rax,%r15
lea    0xa6b(%rip),%rsi
mov    %rax,%rdi
call   11c0 <strstr@plt>
test   %rax,%rax
je     181b <s+0x56b>
lea    0xa91(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
lea    0x9(%r15),%rdi
call   1190 <atoi@plt>
mov    %eax,%ebp
lea    0xa80(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
lea    -0x12c(%rbp),%eax
cmp    $0x64,%eax
jae    178a <s+0x4da>
lea    0xa6f(%rip),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
call   11c0 <strstr@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1090 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
mov    %rbp,%rdi
mov    $0xd,%esi
call   10b0 <strchr@plt>
movb   $0x0,(%rax)
lea    0xa8b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    0x14(%rsp),%esi
add    $0x1,%esi
mov    %rbp,%rdi
mov    %r12,%rdx
call   1150 <s@plt>
jmp    17ff <s+0x54f>
mov    0x28d1(%rip),%rax
mov    (%rax),%edi
lea    0x8f0(%rip),%rsi
jmp    1758 <s+0x4a8>
mov    0x28bf(%rip),%rax
mov    (%rax),%edi
lea    0x934(%rip),%rsi
jmp    1758 <s+0x4a8>
mov    0x28ad(%rip),%rax
mov    (%rax),%edi
lea    0x931(%rip),%rsi
jmp    1758 <s+0x4a8>
mov    0x289b(%rip),%rax
mov    (%rax),%edi
lea    0x94c(%rip),%rsi
jmp    1758 <s+0x4a8>
mov    0x2889(%rip),%rax
mov    (%rax),%edi
lea    0x973(%rip),%rsi
call   1120 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x285e(%rip),%rax
mov    (%rax),%edi
lea    0x956(%rip),%rsi
call   1120 <fprintf@plt>
jmp    1762 <s+0x4b2>
cmp    $0xc8,%ebp
jne    17ff <s+0x54f>
lea    0x9dc(%rip),%rdi
call   1040 <puts@plt>
lea    0x97e(%rip),%rsi
mov    %r12,%rdi
call   1170 <fopen@plt>
test   %rax,%rax
je     1884 <s+0x5d4>
mov    %rax,%rbx
lea    0xb(%rsp),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   10f0 <read@plt>
test   %rax,%rax
jle    17f7 <s+0x547>
lea    0xb(%rsp),%rbp
movsbl 0xb(%rsp),%edi
mov    %rbx,%rsi
call   10e0 <fputc@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10f0 <read@plt>
test   %rax,%rax
jg     17d5 <s+0x525>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    %r13d,%edi
mov    $0x2,%esi
call   1080 <shutdown@plt>
mov    %r13d,%edi
call   10d0 <close@plt>
xor    %ebp,%ebp
jmp    1762 <s+0x4b2>
mov    $0x1,%ebp
xor    %ebx,%ebx
lea    0x898(%rip),%r14
jmp    1843 <s+0x593>
mov    %r15,%rdi
mov    %r14,%rsi
call   11c0 <strstr@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1667 <s+0x3b7>
lea    (%r15,%rbx,1),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   10f0 <read@plt>
lea    0x1(%rbx),%eax
cmp    %eax,%ebp
jg     182b <s+0x57b>
add    %ebp,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
call   1160 <realloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    182b <s+0x57b>
mov    0x2762(%rip),%rax
mov    (%rax),%edi
lea    0x86c(%rip),%rsi
jmp    1758 <s+0x4a8>
mov    0x274d(%rip),%rax
mov    (%rax),%edi
lea    0x891(%rip),%rsi
jmp    1758 <s+0x4a8>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8, i32, i32 }
%struct.hostent = type { i8*, i8**, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [14 x i8] c"Malloc error\0A\00"
@.str.1 = [11 x i8] c"index.html\00"
@.str.2 = [24 x i8] c"Too many redirections.\0A\00"
@.str.3 = [8 x i8] c"http://\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [29 x i8] c"port: %d,\0Ahost: %s,\0Aurl: %s\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.6 = [15 x i8] c"Socket error.\0A\00"
@AF_INET = global i32 0
@.str.7 = [15 x i8] c"Unknown host.\0A\00"
@.str.8 = [22 x i8] c"Official name is: %s\0A\00"
@.str.9 = [24 x i8] c"<--- IP addresses --->\0A\00"
@.str.10 = [8 x i8] c" %s\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [23 x i8] c"D'OH! Server is dead.\0A\00"
@.str.13 = [13 x i8] c"Connected!\0A\0A\00"
@.str.14 = [6 x i8] c"GET /\00"
@.str.15 = [18 x i8] c" HTTP/1.0\0D\0AHost: \00"
@.str.16 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.17 = [5 x i8] c"GET \00"
@.str.18 = [14 x i8] c"Write error.\0A\00"
@.str.19 = [12 x i8] c"Reading...\0A\00"
@.str.20 = [18 x i8] c"Allocation error\0A\00"
@.str.21 = [20 x i8] c"Reallocation error\0A\00"
@.str.22 = [11 x i8] c"Header:\0A%s\00"
@.str.23 = [14 x i8] c"Response: %d\0A\00"
@.str.24 = [11 x i8] c"Location: \00"
@.str.25 = [16 x i8] c"Downloading...\0A\00"
@.str.26 = [2 x i8] c"w\00"
@.str.27 = [20 x i8] c"Error opening file\0A\00"
@.str.28 = [15 x i8] c"Redirected...\0A\00"
define i32 @s(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca %struct.in_addr**
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i32*
%26 = alloca [1 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 80, i32* %8
store i8* null, i8** %13
%27 = load i8*, i8** %7
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %40
29: ; preds = %3
%30 = call i8* @malloc(i32 11)
store i8* %30, i8** %7
%31 = load i8*, i8** %7
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %374
36: ; preds = %29
%37 = load i8*, i8** %7
%38 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @memcpy(i8* %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %36, %3
%41 = load i32, i32* %6
%42 = icmp sgt i32 %41, 5
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %374
46: ; preds = %40
%47 = load i8*, i8** %5
%48 = call i64 @memcmp(i8* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %46
%51 = call i8* @malloc(i32 8)
store i8* %51, i8** %15
%52 = load i8*, i8** %15
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 7
%55 = load i8*, i8** %5
%56 = call i32 @strlen(i8* %55)
%57 = call i32 @memcpy(i8* %52, i8* %54, i32 %56)
br label %60
58: ; preds = %46
%59 = load i8*, i8** %5
store i8* %59, i8** %15
br label %60
60: ; preds = %58, %50
%61 = load i8*, i8** %15
%62 = call i8* @strchr(i8* %61, i8 signext 47)
store i8* %62, i8** %16
%63 = load i8*, i8** %16
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %77
65: ; preds = %60
%66 = call i8* @malloc(i32 2)
store i8* %66, i8** %17
%67 = load i8*, i8** %17
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %374
72: ; preds = %65
%73 = load i8*, i8** %17
%74 = getelementptr inbounds i8, i8* %73, i64 0
store i8 47, i8* %74
%75 = load i8*, i8** %17
%76 = getelementptr inbounds i8, i8* %75, i64 1
store i8 0, i8* %76
br label %77
77: ; preds = %72, %60
%78 = load i8*, i8** %16
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %91
80: ; preds = %77
%81 = call i8* @malloc(i32 2)
store i8* %81, i8** %17
%82 = load i8*, i8** %17
%83 = icmp eq i8* %82, null
br i1 %83, label %84, label %87
84: ; preds = %80
%85 = load i32, i32* @stderr
%86 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %374
87: ; preds = %80
%88 = load i8*, i8** %16
%89 = load i8*, i8** %17
%90 = call i32 @memcpy(i8* %88, i8* %89, i32 1)
br label %91
91: ; preds = %87, %77
%92 = load i8*, i8** %17
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %92)
%94 = load i8*, i8** %16
%95 = icmp ne i8* %94, null
br i1 %95, label %96, label %110
96: ; preds = %91
%97 = load i8*, i8** %15
%98 = load i8*, i8** %15
%99 = call i32 @strlen(i8* %98)
%100 = load i8*, i8** %17
%101 = call i32 @strlen(i8* %100)
%102 = sub nsw i32 %99, %101
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i8, i8* %97, i64 %103
store i8 0, i8* %104
%105 = load i8*, i8** %17
%106 = load i8*, i8** %17
%107 = call i32 @strlen(i8* %106)
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %105, i64 %108
store i8 0, i8* %109
br label %110
110: ; preds = %96, %91
%111 = load i8*, i8** %17
%112 = call i32 @strlen(i8* %111)
%113 = icmp eq i32 %112, 0
br i1 %113, label %114, label %119
114: ; preds = %110
%115 = load i8*, i8** %17
%116 = getelementptr inbounds i8, i8* %115, i64 0
store i8 47, i8* %116
%117 = load i8*, i8** %17
%118 = getelementptr inbounds i8, i8* %117, i64 1
store i8 0, i8* %118
br label %119
119: ; preds = %114, %110
%120 = load i8*, i8** %15
%121 = call i8* @strchr(i8* %120, i8 signext 58)
store i8* %121, i8** %18
%122 = load i8*, i8** %18
%123 = icmp ne i8* %122, null
br i1 %123, label %124, label %136
124: ; preds = %119
%125 = load i8*, i8** %18
%126 = getelementptr inbounds i8, i8* %125, i64 1
%127 = call i32 @atoi(i8* %126)
store i32 %127, i32* %8
%128 = load i8*, i8** %15
%129 = load i8*, i8** %15
%130 = call i32 @strlen(i8* %129)
%131 = load i8*, i8** %18
%132 = call i32 @strlen(i8* %131)
%133 = sub nsw i32 %130, %132
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %128, i64 %134
store i8 0, i8* %135
br label %136
136: ; preds = %124, %119
%137 = load i32, i32* %8
%138 = load i8*, i8** %15
%139 = load i8*, i8** %17
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %137, i8* %138, i8* %139)
%141 = load i32, i32* @PF_INET
%142 = load i32, i32* @SOCK_STREAM
%143 = call i32 @socket(i32 %141, i32 %142, i32 0)
store i32 %143, i32* %9
%144 = load i32, i32* %9
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %149
146: ; preds = %136
%147 = load i32, i32* @stderr
%148 = call i32 @fprintf(i32 %147, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %4
br label %374
149: ; preds = %136
%150 = call i32 @bzero(%struct.sockaddr_in* %10, i32 12)
%151 = load i32, i32* @AF_INET
%152 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %151, i32* %152
%153 = load i8*, i8** %15
%154 = call %struct.hostent* @gethostbyname(i8* %153)
store %struct.hostent* %154, %struct.hostent** %11
%155 = icmp eq %struct.hostent* %154, null
br i1 %155, label %156, label %159
156: ; preds = %149
%157 = load i32, i32* @stderr
%158 = call i32 @fprintf(i32 %157, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %4
br label %374
159: ; preds = %149
%160 = load %struct.hostent*, %struct.hostent** %11
%161 = getelementptr inbounds %struct.hostent, %struct.hostent* %160, i32 0, i32 0
%162 = load i8*, i8** %161
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %162)
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%165 = load %struct.hostent*, %struct.hostent** %11
%166 = getelementptr inbounds %struct.hostent, %struct.hostent* %165, i32 0, i32 1
%167 = load i8**, i8*** %166
%168 = bitcast i8** %167 to %struct.in_addr**
store %struct.in_addr** %168, %struct.in_addr*** %12
store i32 0, i32* %19
br label %169
169: ; preds = %186, %159
%170 = load %struct.in_addr**, %struct.in_addr*** %12
%171 = load i32, i32* %19
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds %struct.in_addr*, %struct.in_addr** %170, i64 %172
%174 = load %struct.in_addr*, %struct.in_addr** %173
%175 = icmp ne %struct.in_addr* %174, null
br i1 %175, label %176, label %189
176: ; preds = %169
%177 = load %struct.in_addr**, %struct.in_addr*** %12
%178 = load i32, i32* %19
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds %struct.in_addr*, %struct.in_addr** %177, i64 %179
%181 = load %struct.in_addr*, %struct.in_addr** %180
%182 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %181, i32 0, i32 0
%183 = load i32, i32* %182
%184 = call i8* @inet_ntoa(i32 %183)
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %184)
br label %186
186: ; preds = %176
%187 = load i32, i32* %19
%188 = add nsw i32 %187, 1
store i32 %188, i32* %19
br label %169
189: ; preds = %169
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%191 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%192 = load %struct.hostent*, %struct.hostent** %11
%193 = getelementptr inbounds %struct.hostent, %struct.hostent* %192, i32 0, i32 1
%194 = load i8**, i8*** %193
%195 = getelementptr inbounds i8*, i8** %194, i64 0
%196 = load i8*, i8** %195
%197 = load %struct.hostent*, %struct.hostent** %11
%198 = getelementptr inbounds %struct.hostent, %struct.hostent* %197, i32 0, i32 2
%199 = load i32, i32* %198
%200 = call i32 @memcpy(i8* %191, i8* %196, i32 %199)
%201 = load i32, i32* %8
%202 = call i32 @htons(i32 %201)
%203 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %202, i32* %203
%204 = load i32, i32* %9
%205 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%206 = call i64 @connect(i32 %204, %struct.sockaddr* %205, i32 12)
%207 = icmp slt i64 %206, 0
br i1 %207, label %208, label %211
208: ; preds = %189
%209 = load i32, i32* @stderr
%210 = call i32 @fprintf(i32 %209, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
store i32 1, i32* %4
br label %374
211: ; preds = %189
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%213 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%214 = load i8*, i8** %17
%215 = call i32 @strlen(i8* %214)
%216 = add nsw i32 %213, %215
%217 = call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%218 = add nsw i32 %216, %217
%219 = load i8*, i8** %15
%220 = call i32 @strlen(i8* %219)
%221 = add nsw i32 %218, %220
%222 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%223 = add nsw i32 %221, %222
%224 = sext i32 %223 to i64
%225 = mul i64 %224, 1
%226 = trunc i64 %225 to i32
%227 = call i8* @malloc(i32 %226)
store i8* %227, i8** %13
%228 = load i8*, i8** %13
%229 = icmp eq i8* %228, null
br i1 %229, label %230, label %233
230: ; preds = %211
%231 = load i32, i32* @stderr
%232 = call i32 @fprintf(i32 %231, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %374
233: ; preds = %211
%234 = load i8*, i8** %13
%235 = getelementptr inbounds i8, i8* %234, i64 0
store i8 0, i8* %235
%236 = load i8*, i8** %13
%237 = call i32 @strcat(i8* %236, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0))
%238 = load i8*, i8** %13
%239 = load i8*, i8** %17
%240 = call i32 @strcat(i8* %238, i8* %239)
%241 = load i8*, i8** %13
%242 = call i32 @strcat(i8* %241, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%243 = load i8*, i8** %13
%244 = load %struct.hostent*, %struct.hostent** %11
%245 = getelementptr inbounds %struct.hostent, %struct.hostent* %244, i32 0, i32 0
%246 = load i8*, i8** %245
%247 = call i32 @strcat(i8* %243, i8* %246)
%248 = load i8*, i8** %13
%249 = call i32 @strcat(i8* %248, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%250 = load i8*, i8** %13
%251 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %250)
%252 = load i32, i32* %9
%253 = load i8*, i8** %13
%254 = load i8*, i8** %13
%255 = call i32 @strlen(i8* %254)
%256 = call i64 @write(i32 %252, i8* %253, i32 %255)
%257 = icmp sle i64 %256, 0
br i1 %257, label %258, label %261
258: ; preds = %233
%259 = load i32, i32* @stderr
%260 = call i32 @fprintf(i32 %259, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0))
store i32 1, i32* %4
br label %374
261: ; preds = %233
%262 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
store i32 1, i32* %21
store i32 0, i32* %22
%263 = load i32, i32* %21
%264 = sext i32 %263 to i64
%265 = mul i64 1, %264
%266 = trunc i64 %265 to i32
%267 = call i8* @malloc(i32 %266)
store i8* %267, i8** %20
%268 = load i8*, i8** %20
%269 = icmp eq i8* %268, null
br i1 %269, label %270, label %273
270: ; preds = %261
%271 = load i32, i32* @stderr
%272 = call i32 @fprintf(i32 %271, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.20, i64 0, i64 0))
store i32 1, i32* %4
br label %374
273: ; preds = %261
br label %274
274: ; preds = %305, %273
%275 = load i8*, i8** %20
%276 = call i8* @strstr(i8* %275, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%277 = icmp eq i8* %276, null
br i1 %277, label %278, label %306
278: ; preds = %274
%279 = load i32, i32* %9
%280 = load i8*, i8** %20
%281 = load i32, i32* %22
%282 = sext i32 %281 to i64
%283 = getelementptr inbounds i8, i8* %280, i64 %282
%284 = call i64 @read(i32 %279, i8* %283, i32 1)
%285 = load i32, i32* %22
%286 = add nsw i32 %285, 1
store i32 %286, i32* %22
%287 = load i32, i32* %22
%288 = load i32, i32* %21
%289 = icmp sge i32 %287, %288
br i1 %289, label %290, label %305
290: ; preds = %278
%291 = load i32, i32* %21
%292 = mul nsw i32 %291, 2
store i32 %292, i32* %21
%293 = load i8*, i8** %20
%294 = load i32, i32* %21
%295 = sext i32 %294 to i64
%296 = mul i64 1, %295
%297 = trunc i64 %296 to i32
%298 = call i8* @realloc(i8* %293, i32 %297)
store i8* %298, i8** %20
%299 = load i8*, i8** %20
%300 = icmp eq i8* %299, null
br i1 %300, label %301, label %304
301: ; preds = %290
%302 = load i32, i32* @stderr
%303 = call i32 @fprintf(i32 %302, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.21, i64 0, i64 0))
store i32 1, i32* %4
br label %374
304: ; preds = %290
br label %305
305: ; preds = %304, %278
br label %274
306: ; preds = %274
%307 = load i8*, i8** %20
%308 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0), i8* %307)
%309 = load i8*, i8** %20
%310 = getelementptr inbounds i8, i8* %309, i64 9
%311 = call i32 @atoi(i8* %310)
store i32 %311, i32* %14
%312 = load i32, i32* %14
%313 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.23, i64 0, i64 0), i32 %312)
store i8* null, i8** %23
%314 = load i32, i32* %14
%315 = icmp sge i32 %314, 300
br i1 %315, label %316, label %329
316: ; preds = %306
%317 = load i32, i32* %14
%318 = icmp slt i32 %317, 400
br i1 %318, label %319, label %329
319: ; preds = %316
%320 = load i8*, i8** %20
%321 = call i8* @strstr(i8* %320, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0))
%322 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0))
%323 = sext i32 %322 to i64
%324 = getelementptr inbounds i8, i8* %321, i64 %323
store i8* %324, i8** %23
store i32 0, i32* %22
%325 = load i8*, i8** %23
%326 = call i8* @strchr(i8* %325, i8 signext 13)
store i8* %326, i8** %24
%327 = load i8*, i8** %24
%328 = getelementptr inbounds i8, i8* %327, i64 0
store i8 0, i8* %328
br label %329
329: ; preds = %319, %316, %306
%330 = load i32, i32* %14
%331 = icmp eq i32 %330, 200
br i1 %331, label %332, label %354
332: ; preds = %329
%333 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0))
%334 = load i8*, i8** %7
%335 = call i32* @fopen(i8* %334, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.26, i64 0, i64 0))
store i32* %335, i32** %25
%336 = load i32*, i32** %25
%337 = icmp eq i32* %336, null
br i1 %337, label %338, label %341
338: ; preds = %332
%339 = load i32, i32* @stderr
%340 = call i32 @fprintf(i32 %339, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.27, i64 0, i64 0))
store i32 1, i32* %4
br label %374
341: ; preds = %332
br label %342
342: ; preds = %347, %341
%343 = load i32, i32* %9
%344 = getelementptr inbounds [1 x i8], [1 x i8]* %26, i64 0, i64 0
%345 = call i64 @read(i32 %343, i8* %344, i32 1)
%346 = icmp sgt i64 %345, 0
br i1 %346, label %347, label %351
347: ; preds = %342
%348 = getelementptr inbounds [1 x i8], [1 x i8]* %26, i64 0, i64 0
%349 = load i32*, i32** %25
%350 = call i32 @fwrite(i8* %348, i32 1, i32 1, i32* %349)
br label %342
351: ; preds = %342
%352 = load i32*, i32** %25
%353 = call i32 @fclose(i32* %352)
br label %354
354: ; preds = %351, %329
%355 = load i32, i32* %14
%356 = icmp sge i32 %355, 300
br i1 %356, label %357, label %369
357: ; preds = %354
%358 = load i32, i32* %14
%359 = icmp slt i32 %358, 400
br i1 %359, label %360, label %369
360: ; preds = %357
%361 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.28, i64 0, i64 0))
%362 = load i8*, i8** %23
%363 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %362)
%364 = load i8*, i8** %23
%365 = load i32, i32* %6
%366 = add nsw i32 %365, 1
store i32 %366, i32* %6
%367 = load i8*, i8** %7
%368 = call i32 @s(i8* %364, i32 %366, i8* %367)
br label %369
369: ; preds = %360, %357, %354
%370 = load i32, i32* %9
%371 = call i32 @shutdown(i32 %370, i32 2)
%372 = load i32, i32* %9
%373 = call i32 @close(i32 %372)
store i32 0, i32* %4
br label %374
374: ; preds = %369, %338, %301, %270, %258, %230, %208, %156, %146, %84, %69, %43, %33
%375 = load i32, i32* %4
ret i32 %375
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8, i32, i32 }
%struct.hostent = type { i8*, i8**, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [14 x i8] c"Malloc error\0A\00"
@.str.1 = [11 x i8] c"index.html\00"
@.str.2 = [24 x i8] c"Too many redirections.\0A\00"
@.str.3 = [8 x i8] c"http://\00"
@.str.5 = [29 x i8] c"port: %d,\0Ahost: %s,\0Aurl: %s\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.6 = [15 x i8] c"Socket error.\0A\00"
@AF_INET = global i32 0
@.str.7 = [15 x i8] c"Unknown host.\0A\00"
@.str.8 = [22 x i8] c"Official name is: %s\0A\00"
@.str.10 = [8 x i8] c" %s\0A\00"
@.str.12 = [23 x i8] c"D'OH! Server is dead.\0A\00"
@.str.14 = [6 x i8] c"GET /\00"
@.str.15 = [18 x i8] c" HTTP/1.0\0D\0AHost: \00"
@.str.16 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.17 = [5 x i8] c"GET \00"
@.str.18 = [14 x i8] c"Write error.\0A\00"
@.str.20 = [18 x i8] c"Allocation error\0A\00"
@.str.21 = [20 x i8] c"Reallocation error\0A\00"
@.str.22 = [11 x i8] c"Header:\0A%s\00"
@.str.23 = [14 x i8] c"Response: %d\0A\00"
@.str.24 = [11 x i8] c"Location: \00"
@.str.26 = [2 x i8] c"w\00"
@.str.27 = [20 x i8] c"Error opening file\0A\00"
@str = [23 x i8] c"<--- IP addresses --->\00"
@str.29 = [12 x i8] c"Connected!\0A\00"
@str.30 = [11 x i8] c"Reading...\00"
@str.31 = [14 x i8] c"Redirected...\00"
@str.32 = [15 x i8] c"Downloading...\00"
define i32 @s(i8* %0, i32 %1, i8* %2) {
%4 = alloca %struct.sockaddr_in
%5 = alloca [1 x i8]
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%7 = icmp eq i8* %2, null
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = tail call dereferenceable_or_null(11) i8* @malloc(i32 11)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %233
14: ; preds = %8
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @memcpy(i8* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %3
%18 = phi i8* [ %9, %14 ], [ %2, %3 ]
%19 = icmp sgt i32 %1, 5
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %233
23: ; preds = %17
%24 = tail call i64 @memcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%28 = getelementptr inbounds i8, i8* %0, i64 7
%29 = tail call i32 @strlen(i8* %0)
%30 = tail call i32 @memcpy(i8* %27, i8* %28, i32 %29)
br label %31
31: ; preds = %23, %26
%32 = phi i8* [ %27, %26 ], [ %0, %23 ]
%33 = tail call i8* @strchr(i8* dereferenceable(1) %32, i8 signext 47)
%34 = icmp eq i8* %33, null
%35 = tail call dereferenceable_or_null(2) i8* @malloc(i32 2)
%36 = icmp eq i8* %35, null
br i1 %34, label %37, label %44
37: ; preds = %31
br i1 %36, label %38, label %41
38: ; preds = %37
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %233
41: ; preds = %37
store i8 47, i8* %35
%42 = getelementptr inbounds i8, i8* %35, i64 1
store i8 0, i8* %42
%43 = tail call i32 @puts(i8* dereferenceable(1) %35)
br label %59
44: ; preds = %31
br i1 %36, label %45, label %48
45: ; preds = %44
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %233
48: ; preds = %44
%49 = tail call i32 @memcpy(i8* %33, i8* %35, i32 1)
%50 = tail call i32 @puts(i8* dereferenceable(1) %35)
%51 = tail call i32 @strlen(i8* %32)
%52 = tail call i32 @strlen(i8* %35)
%53 = sub nsw i32 %51, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %32, i64 %54
store i8 0, i8* %55
%56 = tail call i32 @strlen(i8* %35)
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %35, i64 %57
store i8 0, i8* %58
br label %59
59: ; preds = %41, %48
%60 = tail call i32 @strlen(i8* %35)
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
store i8 47, i8* %35
%63 = getelementptr inbounds i8, i8* %35, i64 1
store i8 0, i8* %63
br label %64
64: ; preds = %62, %59
%65 = tail call i8* @strchr(i8* dereferenceable(1) %32, i8 signext 58)
%66 = icmp eq i8* %65, null
br i1 %66, label %75, label %67
67: ; preds = %64
%68 = getelementptr inbounds i8, i8* %65, i64 1
%69 = tail call i32 @atoi(i8* %68)
%70 = tail call i32 @strlen(i8* %32)
%71 = tail call i32 @strlen(i8* %65)
%72 = sub nsw i32 %70, %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %32, i64 %73
store i8 0, i8* %74
br label %75
75: ; preds = %67, %64
%76 = phi i32 [ %69, %67 ], [ 80, %64 ]
%77 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %76, i8* %32, i8* %35)
%78 = load i32, i32* @PF_INET
%79 = load i32, i32* @SOCK_STREAM
%80 = tail call i32 @socket(i32 %78, i32 %79, i32 0)
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = load i32, i32* @stderr
%84 = tail call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %233
85: ; preds = %75
%86 = call i32 @bzero(%struct.sockaddr_in* %4, i32 12)
%87 = load i32, i32* @AF_INET
%88 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %87, i32* %88
%89 = tail call %struct.hostent* @gethostbyname(i8* %32)
%90 = icmp eq %struct.hostent* %89, null
br i1 %90, label %91, label %94
91: ; preds = %85
%92 = load i32, i32* @stderr
%93 = tail call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %233
94: ; preds = %85
%95 = getelementptr inbounds %struct.hostent, %struct.hostent* %89, i64 0, i32 0
%96 = load i8*, i8** %95
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %96)
%98 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%99 = getelementptr inbounds %struct.hostent, %struct.hostent* %89, i64 0, i32 1
%100 = bitcast i8*** %99 to %struct.in_addr***
%101 = load %struct.in_addr**, %struct.in_addr*** %100
%102 = load %struct.in_addr*, %struct.in_addr** %101
%103 = icmp eq %struct.in_addr* %102, null
br i1 %103, label %104, label %116
104: ; preds = %116, %94
%105 = tail call i32 @putchar(i32 10)
%106 = load i8**, i8*** %99
%107 = load i8*, i8** %106
%108 = getelementptr inbounds %struct.hostent, %struct.hostent* %89, i64 0, i32 2
%109 = load i32, i32* %108
%110 = call i32 @memcpy(i8* %6, i8* %107, i32 %109)
%111 = call i32 @htons(i32 %76)
%112 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %111, i32* %112
%113 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%114 = call i64 @connect(i32 %80, %struct.sockaddr* %113, i32 12)
%115 = icmp slt i64 %114, 0
br i1 %115, label %127, label %130
116: ; preds = %94, %116
%117 = phi i64 [ %123, %116 ], [ 0, %94 ]
%118 = phi %struct.in_addr* [ %125, %116 ], [ %102, %94 ]
%119 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %118, i64 0, i32 0
%120 = load i32, i32* %119
%121 = tail call i8* @inet_ntoa(i32 %120)
%122 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %121)
%123 = add nuw i64 %117, 1
%124 = getelementptr inbounds %struct.in_addr*, %struct.in_addr** %101, i64 %123
%125 = load %struct.in_addr*, %struct.in_addr** %124
%126 = icmp eq %struct.in_addr* %125, null
br i1 %126, label %104, label %116
127: ; preds = %104
%128 = load i32, i32* @stderr
%129 = call i32 @fprintf(i32 %128, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.12, i64 0, i64 0))
br label %233
130: ; preds = %104
%131 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.29, i64 0, i64 0))
%132 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%133 = call i32 @strlen(i8* %35)
%134 = add nsw i32 %133, %132
%135 = call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%136 = add nsw i32 %134, %135
%137 = call i32 @strlen(i8* %32)
%138 = add nsw i32 %136, %137
%139 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%140 = add nsw i32 %138, %139
%141 = call i8* @malloc(i32 %140)
%142 = icmp eq i8* %141, null
br i1 %142, label %143, label %146
143: ; preds = %130
%144 = load i32, i32* @stderr
%145 = call i32 @fprintf(i32 %144, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %233
146: ; preds = %130
store i8 0, i8* %141
%147 = call i32 @strcat(i8* %141, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0))
%148 = call i32 @strcat(i8* %141, i8* %35)
%149 = call i32 @strcat(i8* %141, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%150 = load i8*, i8** %95
%151 = call i32 @strcat(i8* %141, i8* %150)
%152 = call i32 @strcat(i8* %141, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%153 = call i32 @puts(i8* %141)
%154 = call i32 @strlen(i8* %141)
%155 = call i64 @write(i32 %80, i8* %141, i32 %154)
%156 = icmp slt i64 %155, 1
br i1 %156, label %157, label %160
157: ; preds = %146
%158 = load i32, i32* @stderr
%159 = call i32 @fprintf(i32 %158, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0))
br label %233
160: ; preds = %146
%161 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.30, i64 0, i64 0))
%162 = call dereferenceable_or_null(1) i8* @malloc(i32 1)
%163 = icmp eq i8* %162, null
br i1 %163, label %167, label %164
164: ; preds = %160
%165 = call i8* @strstr(i8* dereferenceable(1) %162, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%166 = icmp eq i8* %165, null
br i1 %166, label %170, label %191
167: ; preds = %160
%168 = load i32, i32* @stderr
%169 = call i32 @fprintf(i32 %168, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.20, i64 0, i64 0))
br label %233
170: ; preds = %164, %186
%171 = phi i64 [ %176, %186 ], [ 0, %164 ]
%172 = phi i32 [ %188, %186 ], [ 1, %164 ]
%173 = phi i8* [ %187, %186 ], [ %162, %164 ]
%174 = getelementptr inbounds i8, i8* %173, i64 %171
%175 = call i64 @read(i32 %80, i8* %174, i32 1)
%176 = add nuw i64 %171, 1
%177 = trunc i64 %176 to i32
%178 = icmp sgt i32 %172, %177
br i1 %178, label %186, label %179
179: ; preds = %170
%180 = shl nsw i32 %172, 1
%181 = call i8* @realloc(i8* %173, i32 %180)
%182 = icmp eq i8* %181, null
br i1 %182, label %183, label %186
183: ; preds = %179
%184 = load i32, i32* @stderr
%185 = call i32 @fprintf(i32 %184, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.21, i64 0, i64 0))
br label %233
186: ; preds = %179, %170
%187 = phi i8* [ %181, %179 ], [ %173, %170 ]
%188 = phi i32 [ %180, %179 ], [ %172, %170 ]
%189 = call i8* @strstr(i8* dereferenceable(1) %187, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%190 = icmp eq i8* %189, null
br i1 %190, label %170, label %191
191: ; preds = %186, %164
%192 = phi i8* [ %162, %164 ], [ %187, %186 ]
%193 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.22, i64 0, i64 0), i8* %192)
%194 = getelementptr inbounds i8, i8* %192, i64 9
%195 = call i32 @atoi(i8* %194)
%196 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.23, i64 0, i64 0), i32 %195)
%197 = add i32 %195, -300
%198 = icmp ult i32 %197, 100
br i1 %198, label %220, label %199
199: ; preds = %191
%200 = icmp eq i32 %195, 200
br i1 %200, label %201, label %230
201: ; preds = %199
%202 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.32, i64 0, i64 0))
%203 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.26, i64 0, i64 0))
%204 = icmp eq i32* %203, null
br i1 %204, label %205, label %208
205: ; preds = %201
%206 = load i32, i32* @stderr
%207 = call i32 @fprintf(i32 %206, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.27, i64 0, i64 0))
br label %233
208: ; preds = %201
%209 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%210 = call i64 @read(i32 %80, i8* %209, i32 1)
%211 = icmp sgt i64 %210, 0
br i1 %211, label %212, label %218
212: ; preds = %208, %212
%213 = load i8, i8* %209
%214 = sext i8 %213 to i32
%215 = call i32 @fputc(i32 %214, i32* %203)
%216 = call i64 @read(i32 %80, i8* %209, i32 1)
%217 = icmp sgt i64 %216, 0
br i1 %217, label %212, label %218
218: ; preds = %212, %208
%219 = call i32 @fclose(i32* %203)
br label %230
220: ; preds = %191
%221 = call i8* @strstr(i8* dereferenceable(1) %192, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0))
%222 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0))
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds i8, i8* %221, i64 %223
%225 = call i8* @strchr(i8* dereferenceable(1) %224, i8 signext 13)
store i8 0, i8* %225
%226 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.31, i64 0, i64 0))
%227 = call i32 @puts(i8* dereferenceable(1) %224)
%228 = add nsw i32 %1, 1
%229 = call i32 @s(i8* %224, i32 %228, i8* %18)
br label %230
230: ; preds = %218, %199, %220
%231 = call i32 @shutdown(i32 %80, i32 2)
%232 = call i32 @close(i32 %80)
br label %233
233: ; preds = %205, %38, %45, %82, %91, %127, %143, %157, %230, %183, %167, %20, %11
%234 = phi i32 [ 1, %11 ], [ 1, %20 ], [ 1, %38 ], [ 1, %45 ], [ 1, %82 ], [ 1, %91 ], [ 1, %127 ], [ 1, %143 ], [ 1, %157 ], [ 1, %167 ], [ 1, %183 ], [ 0, %230 ], [ 1, %205 ]
ret i32 %234
}