#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 addrinfo {
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  struct addrinfo *ai_next;
};
typedef int /*<<< orphan*/ host;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printWeather(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcat(char *, char *);
size_t strcspn(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *strstr(char *, char *);
int main(void) {
  struct addrinfo hints;
  struct addrinfo *wu_addr, *p;
  int socket_fd;
  int size, i = 0;
  char *s, ch;
  char host[64];
  char buff[4096];
  char city[32], state[32];
  char request[128] = "GET /api/715de8d316f47c2d/conditions/q/";
  printf("\n\nWelcome to The Weather Underground API Client!\n\t\@author "
         "Zachary Mattis\n\n");
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = IPPROTO_TCP;
  if (getaddrinfo("api.wunderground.com", "80", &hints, &wu_addr) != 0) {
    perror("Error: Failure connecting to API\n");
    exit(EXIT_FAILURE);
  } else {
    printf("Connecting to Weather Underground API...\n\n");
  }
  for (p = wu_addr; p != NULL; p = p->ai_next) {
    if ((socket_fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) ==
        -1) {
      perror("Error: Failure opening socket... Trying again\n");
      continue;
    }
    if (connect(socket_fd, p->ai_addr, p->ai_addrlen) == -1) {
      close(socket_fd);
      perror("Error: Failure connecting to server... Trying again\n");
      continue;
    }
    break;
  }
  if (p == NULL) {
    perror("Error: Client failed to connect\n");
    exit(EXIT_FAILURE);
  }
  inet_ntop(p->ai_family, p->ai_addr, host, sizeof(host));
  printf("Connection: Client connected to IP %s\n\n", host);
  freeaddrinfo(wu_addr);
  printf("What city would you like to look up?\n\n");
  printf("City: ");
  fgets(city, 32, stdin);
  city[strcspn(city, "\n")] = '\0';
  printf("\nState(US, Abbreviated) or Country(International): ");
  fgets(state, 32, stdin);
  state[strcspn(state, "\n")] = '\0';
  strcat(request, state);
  strcat(request, "/");
  strcat(request, city);
  strcat(request, ".xml HTTP/1.1\r\nHost: api.wunderground.com\r\n\r\n");
  printf("\n\nSending HTTP Request String to Server...");
  send(socket_fd, request, strlen(request), 0);
  printf("\n\nReceiving Data from Server...");
  recv(socket_fd, buff, 4095, 0);
  close(socket_fd);
  s = strstr(buff, "Content-Length");
  s = s + 16;
  while ((ch = s[i]) != '\r') {
    size = size * 10 + (ch - '0');
    i++;
  }
  if (size < 1000) {
    printf("\n\nERROR: Invalid user input");
    printf("\nUSAGE: Pittsburgh, PA");
    printf("\nUSAGE: Paris, France\n\n");
    exit(EXIT_FAILURE);
  }
  printf("\nReceived: %d bytes\n\n", size);
  printWeather(&buff[0]);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1170,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x44(%rbp)
lea    -0x1160(%rbp),%rdi
lea    0xda9(%rip),%rsi
mov    $0x80,%edx
call   10d0 <memcpy@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1090 <memset@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe21(%rip),%rdi
lea    0xe2f(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1120 <getaddrinfo@plt>
cmp    $0x0,%rax
je     12e2 <main+0xb2>
lea    0xe14(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1387 <main+0x157>
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%esi
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edx
call   1150 <socket@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
jne    133a <main+0x10a>
lea    0xe00(%rip),%rdi
call   10e0 <perror@plt>
jmp    1376 <main+0x146>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    1371 <main+0x141>
mov    -0x3c(%rbp),%edi
call   10a0 <close@plt>
lea    0xdf8(%rip),%rdi
call   10e0 <perror@plt>
jmp    1376 <main+0x146>
jmp    1387 <main+0x157>
mov    -0x38(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    12f8 <main+0xc8>
cmpq   $0x0,-0x38(%rbp)
jne    13ac <main+0x17c>
lea    0xdfb(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    -0xa0(%rbp),%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
lea    -0xa0(%rbp),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x10c0(%rbp),%rdi
mov    0x2bce(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   10c0 <fgets@plt>
lea    -0x10c0(%rbp),%rdi
lea    0xd02(%rip),%rsi
call   10b0 <strcspn@plt>
movb   $0x0,-0x10c0(%rbp,%rax,1)
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x10e0(%rbp),%rdi
mov    0x2b8b(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   10c0 <fgets@plt>
lea    -0x10e0(%rbp),%rdi
lea    0xcbf(%rip),%rsi
call   10b0 <strcspn@plt>
movb   $0x0,-0x10e0(%rbp,%rax,1)
lea    -0x1160(%rbp),%rdi
lea    -0x10e0(%rbp),%rsi
call   10f0 <strcat@plt>
lea    -0x1160(%rbp),%rdi
lea    0xda2(%rip),%rsi
call   10f0 <strcat@plt>
lea    -0x1160(%rbp),%rdi
lea    -0x10c0(%rbp),%rsi
call   10f0 <strcat@plt>
lea    -0x1160(%rbp),%rdi
lea    0xd7e(%rip),%rsi
call   10f0 <strcat@plt>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x116c(%rbp)
lea    -0x1160(%rbp),%rax
mov    %rax,-0x1168(%rbp)
lea    -0x1160(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x116c(%rbp),%edi
mov    -0x1168(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x3c(%rbp),%edi
lea    -0x10a0(%rbp),%rsi
mov    $0xfff,%edx
xor    %ecx,%ecx
call   1050 <recv@plt>
mov    -0x3c(%rbp),%edi
call   10a0 <close@plt>
lea    -0x10a0(%rbp),%rdi
lea    0xd71(%rip),%rsi
call   1130 <strstr@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x51(%rbp)
movsbl %al,%eax
cmp    $0xd,%eax
je     1596 <main+0x366>
imul   $0xa,-0x40(%rbp),%eax
movsbl -0x51(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    155e <main+0x32e>
cmpl   $0x3e8,-0x40(%rbp)
jge    15db <main+0x3ab>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x29ec(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x40(%rbp),%esi
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x10a0(%rbp),%rdi
call   1040 <printWeather@plt>
mov    0x29b9(%rip),%rax
mov    (%rax),%eax
add    $0x1170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1130,%rsp
movaps 0xe2a(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe0b(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xdec(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xdcd(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xdb1(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xd95(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xd79(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xd5d(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xfc6(%rip),%rdi
call   1060 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10a0 <memset@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x2cec(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2cef(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
lea    0xd8a(%rip),%rdi
lea    0xd98(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    %rbx,%rdx
call   1120 <getaddrinfo@plt>
test   %rax,%rax
jne    1544 <main+0x314>
lea    0xfa5(%rip),%rdi
call   1060 <puts@plt>
mov    0x8(%rsp),%rbx
test   %rbx,%rbx
je     1378 <main+0x148>
lea    0xd8a(%rip),%r14
lea    0xdb2(%rip),%r15
mov    0x10(%rbx),%esi
mov    0x4(%rbx),%edi
mov    0xc(%rbx),%edx
call   1150 <socket@plt>
mov    %r14,%rdi
cmp    $0xffffffff,%eax
je     136a <main+0x13a>
mov    %eax,%ebp
mov    (%rbx),%esi
mov    0x8(%rbx),%edx
mov    %eax,%edi
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    1384 <main+0x154>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    %r15,%rdi
call   10e0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    1337 <main+0x107>
lea    0xd9f(%rip),%rdi
jmp    154b <main+0x31b>
mov    (%rbx),%esi
mov    0x4(%rbx),%edi
lea    0xf0(%rsp),%r14
mov    %r14,%rdx
mov    $0x40,%ecx
call   1030 <inet_ntop@plt>
lea    0xd9a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%rsp),%rdi
call   1140 <freeaddrinfo@plt>
lea    0xf29(%rip),%rdi
call   1060 <puts@plt>
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2c06(%rip),%rbx
mov    (%rbx),%edx
lea    0xd0(%rsp),%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   10d0 <fgets@plt>
lea    0xd6d(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   10c0 <strcspn@plt>
movb   $0x0,0xd0(%rsp,%rax,1)
lea    0xd5c(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    (%rbx),%edx
lea    0xb0(%rsp),%r12
mov    %r12,%rdi
mov    $0x20,%esi
call   10d0 <fgets@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   10c0 <strcspn@plt>
movb   $0x0,0xb0(%rsp,%rax,1)
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   10f0 <strcat@plt>
lea    0xd48(%rip),%rsi
mov    %r15,%rdi
call   10f0 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
lea    0xd30(%rip),%rsi
mov    %r15,%rdi
call   10f0 <strcat@plt>
lea    0xd4f(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x130(%rsp),%r14
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xfff,%edx
xor    %ecx,%ecx
call   1050 <recv@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0xd48(%rip),%rsi
mov    %r14,%rdi
call   1130 <strstr@plt>
mov    0x10(%rax),%cl
add    $0x11,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %cl,%ecx
lea    (%rsi,%rsi,4),%edx
lea    (%rcx,%rdx,2),%esi
add    $0xffffffd0,%esi
movzbl (%rax),%ecx
add    $0x1,%rax
cmp    $0xd,%cl
jne    14f0 <main+0x2c0>
cmp    $0x3e7,%esi
jle    1552 <main+0x322>
lea    0xd48(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x130(%rsp),%rdi
call   1040 <printWeather@plt>
mov    0x2a86(%rip),%rax
mov    (%rax),%eax
add    $0x1130,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb4d(%rip),%rdi
call   10e0 <perror@plt>
jmp    157a <main+0x34a>
lea    0xcd3(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xce1(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd9a(%rip),%rdi
call   1060 <puts@plt>
mov    0x2a3f(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@__const.main.request = [128 x i8] c"GET /api/715de8d316f47c2d/conditions/q/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [75 x i8] c"\0A\0AWelcome to The Weather Underground API Client!\0A\09@author Zachary Mattis\0A\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.1 = [21 x i8] c"api.wunderground.com\00"
@.str.2 = [3 x i8] c"80\00"
@.str.3 = [34 x i8] c"Error: Failure connecting to API\0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [43 x i8] c"Connecting to Weather Underground API...\0A\0A\00"
@.str.5 = [47 x i8] c"Error: Failure opening socket... Trying again\0A\00"
@.str.6 = [53 x i8] c"Error: Failure connecting to server... Trying again\0A\00"
@.str.7 = [33 x i8] c"Error: Client failed to connect\0A\00"
@.str.8 = [40 x i8] c"Connection: Client connected to IP %s\0A\0A\00"
@.str.9 = [39 x i8] c"What city would you like to look up?\0A\0A\00"
@.str.10 = [7 x i8] c"City: \00"
@stdin = global i32 0
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [52 x i8] c"\0AState(US, Abbreviated) or Country(International): \00"
@.str.13 = [2 x i8] c"/\00"
@.str.14 = [46 x i8] c".xml HTTP/1.1\0D\0AHost: api.wunderground.com\0D\0A\0D\0A\00"
@.str.15 = [43 x i8] c"\0A\0ASending HTTP Request String to Server...\00"
@.str.16 = [32 x i8] c"\0A\0AReceiving Data from Server...\00"
@.str.17 = [15 x i8] c"Content-Length\00"
@.str.18 = [28 x i8] c"\0A\0AERROR: Invalid user input\00"
@.str.19 = [23 x i8] c"\0AUSAGE: Pittsburgh, PA\00"
@.str.20 = [24 x i8] c"\0AUSAGE: Paris, France\0A\0A\00"
@.str.21 = [22 x i8] c"\0AReceived: %d bytes\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.addrinfo
%3 = alloca %struct.addrinfo*
%4 = alloca %struct.addrinfo*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8
%10 = alloca [64 x i8]
%11 = alloca [4096 x i8]
%12 = alloca [32 x i8]
%13 = alloca [32 x i8]
%14 = alloca [128 x i8]
store i32 0, i32* %1
store i32 0, i32* %7
%15 = bitcast [128 x i8]* %14 to i8*
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @memset(%struct.addrinfo* %2, i32 0, i32 32)
%18 = load i32, i32* @AF_INET
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i32 0, i32 1
store i32 %18, i32* %19
%20 = load i32, i32* @SOCK_STREAM
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i32 0, i32 4
store i32 %20, i32* %21
%22 = load i32, i32* @IPPROTO_TCP
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %2, i32 0, i32 3
store i32 %22, i32* %23
%24 = call i64 @getaddrinfo(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.addrinfo* %2, %struct.addrinfo** %3)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %0
%27 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30
%33 = load %struct.addrinfo*, %struct.addrinfo** %3
store %struct.addrinfo* %33, %struct.addrinfo** %4
br label %34
34: ; preds = %66, %32
%35 = load %struct.addrinfo*, %struct.addrinfo** %4
%36 = icmp ne %struct.addrinfo* %35, null
br i1 %36, label %37, label %70
37: ; preds = %34
%38 = load %struct.addrinfo*, %struct.addrinfo** %4
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i32 0, i32 1
%40 = load i32, i32* %39
%41 = load %struct.addrinfo*, %struct.addrinfo** %4
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = load %struct.addrinfo*, %struct.addrinfo** %4
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 3
%46 = load i32, i32* %45
%47 = call i32 @socket(i32 %40, i32 %43, i32 %46)
store i32 %47, i32* %5
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %37
%50 = call i32 @perror(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %66
51: ; preds = %37
%52 = load i32, i32* %5
%53 = load %struct.addrinfo*, %struct.addrinfo** %4
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 0
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %4
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 2
%58 = load i32, i32* %57
%59 = call i32 @connect(i32 %52, i32 %55, i32 %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %51
%62 = load i32, i32* %5
%63 = call i32 @close(i32 %62)
%64 = call i32 @perror(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
br label %66
65: ; preds = %51
br label %70
66: ; preds = %61, %49
%67 = load %struct.addrinfo*, %struct.addrinfo** %4
%68 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %67, i32 0, i32 5
%69 = load %struct.addrinfo*, %struct.addrinfo** %68
store %struct.addrinfo* %69, %struct.addrinfo** %4
br label %34
70: ; preds = %65, %34
%71 = load %struct.addrinfo*, %struct.addrinfo** %4
%72 = icmp eq %struct.addrinfo* %71, null
br i1 %72, label %73, label %77
73: ; preds = %70
%74 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %70
%78 = load %struct.addrinfo*, %struct.addrinfo** %4
%79 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %78, i32 0, i32 1
%80 = load i32, i32* %79
%81 = load %struct.addrinfo*, %struct.addrinfo** %4
%82 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %81, i32 0, i32 0
%83 = load i32, i32* %82
%84 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%85 = call i32 @inet_ntop(i32 %80, i32 %83, i8* %84, i32 64)
%86 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %86)
%88 = load %struct.addrinfo*, %struct.addrinfo** %3
%89 = call i32 @freeaddrinfo(%struct.addrinfo* %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%92 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%93 = load i32, i32* @stdin
%94 = call i32 @fgets(i8* %92, i32 32, i32 %93)
%95 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%96 = call i64 @strcspn(i8* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%97 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 %96
store i8 0, i8* %97
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
%99 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%100 = load i32, i32* @stdin
%101 = call i32 @fgets(i8* %99, i32 32, i32 %100)
%102 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%103 = call i64 @strcspn(i8* %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%104 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 %103
store i8 0, i8* %104
%105 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%106 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%107 = call i32 @strcat(i8* %105, i8* %106)
%108 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%109 = call i32 @strcat(i8* %108, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%110 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%111 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%112 = call i32 @strcat(i8* %110, i8* %111)
%113 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%114 = call i32 @strcat(i8* %113, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.15, i64 0, i64 0))
%116 = load i32, i32* %5
%117 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%118 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%119 = call i32 @strlen(i8* %118)
%120 = call i32 @send(i32 %116, i8* %117, i32 %119, i32 0)
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0))
%122 = load i32, i32* %5
%123 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%124 = call i32 @recv(i32 %122, i8* %123, i32 4095, i32 0)
%125 = load i32, i32* %5
%126 = call i32 @close(i32 %125)
%127 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%128 = call i8* @strstr(i8* %127, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
store i8* %128, i8** %8
%129 = load i8*, i8** %8
%130 = getelementptr inbounds i8, i8* %129, i64 16
store i8* %130, i8** %8
br label %131
131: ; preds = %139, %77
%132 = load i8*, i8** %8
%133 = load i32, i32* %7
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %132, i64 %134
%136 = load i8, i8* %135
store i8 %136, i8* %9
%137 = sext i8 %136 to i32
%138 = icmp ne i32 %137, 13
br i1 %138, label %139, label %148
139: ; preds = %131
%140 = load i32, i32* %6
%141 = mul nsw i32 %140, 10
%142 = load i8, i8* %9
%143 = sext i8 %142 to i32
%144 = sub nsw i32 %143, 48
%145 = add nsw i32 %141, %144
store i32 %145, i32* %6
%146 = load i32, i32* %7
%147 = add nsw i32 %146, 1
store i32 %147, i32* %7
br label %131
148: ; preds = %131
%149 = load i32, i32* %6
%150 = icmp slt i32 %149, 1000
br i1 %150, label %151, label %157
151: ; preds = %148
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.18, i64 0, i64 0))
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0))
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0))
%155 = load i32, i32* @EXIT_FAILURE
%156 = call i32 @exit(i32 %155)
unreachable
157: ; preds = %148
%158 = load i32, i32* %6
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.21, i64 0, i64 0), i32 %158)
%160 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%161 = call i32 @printWeather(i8* %160)
%162 = load i32, i32* @EXIT_SUCCESS
ret i32 %162
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, %struct.addrinfo* }
@__const.main.request = [128 x i8] c"GET /api/715de8d316f47c2d/conditions/q/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.1 = [21 x i8] c"api.wunderground.com\00"
@.str.2 = [3 x i8] c"80\00"
@.str.3 = [34 x i8] c"Error: Failure connecting to API\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [47 x i8] c"Error: Failure opening socket... Trying again\0A\00"
@.str.6 = [53 x i8] c"Error: Failure connecting to server... Trying again\0A\00"
@.str.7 = [33 x i8] c"Error: Client failed to connect\0A\00"
@.str.8 = [40 x i8] c"Connection: Client connected to IP %s\0A\0A\00"
@.str.10 = [7 x i8] c"City: \00"
@stdin = global i32 0
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [52 x i8] c"\0AState(US, Abbreviated) or Country(International): \00"
@.str.13 = [2 x i8] c"/\00"
@.str.14 = [46 x i8] c".xml HTTP/1.1\0D\0AHost: api.wunderground.com\0D\0A\0D\0A\00"
@.str.15 = [43 x i8] c"\0A\0ASending HTTP Request String to Server...\00"
@.str.16 = [32 x i8] c"\0A\0AReceiving Data from Server...\00"
@.str.17 = [15 x i8] c"Content-Length\00"
@.str.18 = [28 x i8] c"\0A\0AERROR: Invalid user input\00"
@.str.19 = [23 x i8] c"\0AUSAGE: Pittsburgh, PA\00"
@.str.21 = [22 x i8] c"\0AReceived: %d bytes\0A\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [74 x i8] c"\0A\0AWelcome to The Weather Underground API Client!\0A\09@author Zachary Mattis\0A\00"
@str.22 = [42 x i8] c"Connecting to Weather Underground API...\0A\00"
@str.23 = [38 x i8] c"What city would you like to look up?\0A\00"
@str.24 = [23 x i8] c"\0AUSAGE: Paris, France\0A\00"
define i32 @main() {
%1 = alloca %struct.addrinfo
%2 = alloca %struct.addrinfo*
%3 = alloca [64 x i8]
%4 = alloca [4096 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [128 x i8]
%8 = bitcast %struct.addrinfo* %1 to i8*
%9 = bitcast %struct.addrinfo** %2 to i8*
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%16 = call i32 @memset(%struct.addrinfo* %1, i32 0, i32 32)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 1
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 4
store i32 %19, i32* %20
%21 = load i32, i32* @IPPROTO_TCP
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 3
store i32 %21, i32* %22
%23 = call i64 @getaddrinfo(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.addrinfo* %1, %struct.addrinfo** %2)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %0
%26 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.22, i64 0, i64 0))
%31 = load %struct.addrinfo*, %struct.addrinfo** %2
%32 = icmp eq %struct.addrinfo* %31, null
br i1 %32, label %58, label %33
33: ; preds = %29, %52
%34 = phi %struct.addrinfo* [ %56, %52 ], [ %31, %29 ]
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 4
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 3
%40 = load i32, i32* %39
%41 = call i32 @socket(i32 %36, i32 %38, i32 %40)
%42 = icmp eq i32 %41, -1
br i1 %42, label %52, label %43
43: ; preds = %33
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 2
%47 = load i32, i32* %46
%48 = call i32 @connect(i32 %41, i32 %45, i32 %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %62
50: ; preds = %43
%51 = call i32 @close(i32 %41)
br label %52
52: ; preds = %33, %50
%53 = phi i8* [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0), %50 ], [ getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), %33 ]
%54 = call i32 @perror(i8* %53)
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 5
%56 = load %struct.addrinfo*, %struct.addrinfo** %55
%57 = icmp eq %struct.addrinfo* %56, null
br i1 %57, label %58, label %33
58: ; preds = %52, %29
%59 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %43
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 1
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 0
%65 = load i32, i32* %63
%66 = load i32, i32* %64
%67 = call i32 @inet_ntop(i32 %65, i32 %66, i8* %10, i32 64)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %10)
%69 = load %struct.addrinfo*, %struct.addrinfo** %2
%70 = call i32 @freeaddrinfo(%struct.addrinfo* %69)
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.23, i64 0, i64 0))
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%73 = load i32, i32* @stdin
%74 = call i32 @fgets(i8* %12, i32 32, i32 %73)
%75 = call i64 @strcspn(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%76 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %75
store i8 0, i8* %76
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
%78 = load i32, i32* @stdin
%79 = call i32 @fgets(i8* %13, i32 32, i32 %78)
%80 = call i64 @strcspn(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%81 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 %80
store i8 0, i8* %81
%82 = call i32 @strcat(i8* %14, i8* %13)
%83 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%84 = call i32 @strcat(i8* %14, i8* %12)
%85 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.15, i64 0, i64 0))
%87 = call i32 @strlen(i8* %14)
%88 = call i32 @send(i32 %41, i8* %14, i32 %87, i32 0)
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0))
%90 = call i32 @recv(i32 %41, i8* %11, i32 4095, i32 0)
%91 = call i32 @close(i32 %41)
%92 = call i8* @strstr(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
%93 = getelementptr inbounds i8, i8* %92, i64 16
%94 = load i8, i8* %93
%95 = icmp ne i8 %94, 13
br label %96
96: ; preds = %62, %96
%97 = phi i64 [ %104, %96 ], [ 0, %62 ]
%98 = phi i8 [ %106, %96 ], [ %94, %62 ]
%99 = phi i32 [ %103, %96 ], [ undef, %62 ]
%100 = sext i8 %98 to i32
%101 = mul nsw i32 %99, 10
%102 = add i32 %101, -48
%103 = add i32 %102, %100
%104 = add nuw nsw i64 %97, 1
%105 = getelementptr inbounds i8, i8* %93, i64 %104
%106 = load i8, i8* %105
%107 = icmp eq i8 %106, 13
br i1 %107, label %108, label %96
108: ; preds = %96
%109 = icmp slt i32 %103, 1000
br i1 %109, label %110, label %116
110: ; preds = %108
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.18, i64 0, i64 0))
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.19, i64 0, i64 0))
%113 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.24, i64 0, i64 0))
%114 = load i32, i32* @EXIT_FAILURE
%115 = call i32 @exit(i32 %114)
unreachable
116: ; preds = %108
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.21, i64 0, i64 0), i32 %103)
%118 = call i32 @printWeather(i8* %11)
%119 = load i32, i32* @EXIT_SUCCESS
ret i32 %119
}