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

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ address;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
char *getenv(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ strncmp(char *, char *, int);
int main(void) {
  int sockfd;
  FILE *fd;
  int len;
  struct sockaddr_in address;
  int result;
  int jpglength;
  int cameranumber;
  char garbage1[80] = "";
  char garbage2[30] = "";
  char chbuffer[40000] = "";
  char *querystr;
  printf("HTTP/1.1 200 OK\n");
  printf("Content-Type: text/html\n\n");
  printf("WORKS!");
  printf("WORKS!");
  printf("WORKS!");
  printf("WORKS!");
  querystr = getenv("QUERY_STRING");
  sscanf(querystr, "%d", &cameranumber);
  if (cameranumber < 1 || cameranumber > 13) {
    exit(0);
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = inet_addr("127.0.0.1");
  address.sin_port = htons(8080 + cameranumber);
  len = sizeof(address);
  result = connect(sockfd, (struct sockaddr *)&address, len);
  if (result == -1) {
    perror("oops: Cannot connect to Motion");
    exit(1);
  }
  fd = fdopen(sockfd, "r");
  if (fd == NULL) {
    perror("oops: Cannot connect to Motion");
    exit(1);
  }
  while (strncmp(garbage1, "Content-Length:", 15) != 0) {
    fgets(garbage1, 70, fd);
  }
  sscanf(garbage1, "%s%d", garbage2, &jpglength);
  fgets(garbage1, 70, fd);
  fread(chbuffer, 1, jpglength, fd);
  printf("Content-Type: image/jpeg\n\n");
  fwrite(chbuffer, 1, jpglength, stdout);
  fflush(stdout);
  fclose(fd);
  close(sockfd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9cf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1090 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1090 <memset@plt>
lea    -0x9ce0(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c40,%edx
call   1090 <memset@plt>
lea    0xd91(%rip),%rdi
call   1080 <printf@plt>
lea    0xd96(%rip),%rdi
call   1080 <printf@plt>
lea    0xda4(%rip),%rdi
call   1080 <printf@plt>
lea    0xd98(%rip),%rdi
call   1080 <printf@plt>
lea    0xd8c(%rip),%rdi
call   1080 <printf@plt>
lea    0xd80(%rip),%rdi
call   1080 <printf@plt>
lea    0xd7b(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x9ce8(%rbp)
mov    -0x9ce8(%rbp),%rdi
lea    0xdab(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   10e0 <sscanf@plt>
cmpl   $0x1,-0x2c(%rbp)
jl     12f0 <main+0xd0>
cmpl   $0xd,-0x2c(%rbp)
jle    12f7 <main+0xd7>
xor    %edi,%edi
call   1110 <exit@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    0x2cd1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    0xd19(%rip),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%edi
add    $0x1f90,%edi
call   1070 <htons@plt>
mov    %eax,-0x20(%rbp)
movl   $0xc,-0x14(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1120 <connect@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1378 <main+0x158>
lea    0xce0(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x8(%rbp),%edi
lea    0xce6(%rip),%rsi
call   10f0 <fdopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    13ac <main+0x18c>
lea    0xcac(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    13b1 <main+0x191>
lea    -0x80(%rbp),%rdi
lea    0xcae(%rip),%rsi
mov    $0xf,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     13e7 <main+0x1c7>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x46,%esi
call   10b0 <fgets@plt>
jmp    13b1 <main+0x191>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xc81(%rip),%rsi
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   10e0 <sscanf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x46,%esi
call   10b0 <fgets@plt>
lea    -0x9ce0(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
lea    0xc4a(%rip),%rdi
call   1080 <printf@plt>
lea    -0x9ce0(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    0x2b85(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1130 <fwrite@plt>
mov    0x2b72(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x8(%rbp),%edi
call   10a0 <close@plt>
xor    %edi,%edi
call   1110 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x9cd8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movups %xmm0,0x2e(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0x90(%rsp),%rdi
mov    $0x9c40,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0xdd3(%rip),%rdi
call   1050 <puts@plt>
lea    0xdd7(%rip),%rdi
call   1050 <puts@plt>
lea    0xd67(%rip),%rbx
mov    %rbx,%rdi
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1090 <printf@plt>
lea    0xd47(%rip),%rdi
call   1030 <getenv@plt>
lea    0xd85(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   10f0 <sscanf@plt>
mov    0x8(%rsp),%eax
add    $0xfffffff2,%eax
cmp    $0xfffffff2,%eax
jbe    1450 <main+0x220>
mov    0x2cf6(%rip),%rbx
mov    (%rbx),%edi
mov    0x2cdd(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r14d
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
lea    0xd00(%rip),%rdi
call   10d0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0x1f90,%edi
add    0x8(%rsp),%edi
call   1080 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0xffffffff,%eax
je     135a <main+0x12a>
lea    0xcf0(%rip),%rsi
mov    %r14d,%edi
call   1100 <fdopen@plt>
test   %rax,%rax
jne    1370 <main+0x140>
lea    0xcbd(%rip),%rdi
call   1110 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    %rax,%r15
lea    0xcc5(%rip),%rsi
lea    0x40(%rsp),%rdi
mov    $0xf,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     13c5 <main+0x195>
lea    0x40(%rsp),%rbp
lea    0xca5(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x46,%esi
mov    %r15,%rdx
call   10c0 <fgets@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0xf,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    13a0 <main+0x170>
lea    0xc83(%rip),%rsi
lea    0x40(%rsp),%rbx
lea    0x20(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   10f0 <sscanf@plt>
mov    %rbx,%rdi
mov    $0x46,%esi
mov    %r15,%rdx
call   10c0 <fgets@plt>
mov    0xc(%rsp),%edx
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rcx
call   1060 <fread@plt>
lea    0xc65(%rip),%rdi
call   1050 <puts@plt>
mov    0xc(%rsp),%edx
mov    0x2ba8(%rip),%rbp
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1140 <fwrite@plt>
mov    0x0(%rbp),%edi
call   10e0 <fflush@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"HTTP/1.1 200 OK\0A\00"
@.str.1 = [26 x i8] c"Content-Type: text/html\0A\0A\00"
@.str.2 = [7 x i8] c"WORKS!\00"
@.str.3 = [13 x i8] c"QUERY_STRING\00"
@.str.4 = [3 x i8] c"%d\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [10 x i8] c"127.0.0.1\00"
@.str.6 = [31 x i8] c"oops: Cannot connect to Motion\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [16 x i8] c"Content-Length:\00"
@.str.9 = [5 x i8] c"%s%d\00"
@.str.10 = [27 x i8] c"Content-Type: image/jpeg\0A\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [80 x i8]
%10 = alloca [30 x i8]
%11 = alloca [40000 x i8]
%12 = alloca i8*
store i32 0, i32* %1
%13 = bitcast [80 x i8]* %9 to i8*
%14 = bitcast [30 x i8]* %10 to i8*
%15 = bitcast [40000 x i8]* %11 to i8*
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%22 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i8* %22, i8** %12
%23 = load i8*, i8** %12
%24 = call i32 (i8*, i8*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %0
%28 = load i32, i32* %8
%29 = icmp sgt i32 %28, 13
br i1 %29, label %30, label %32
30: ; preds = %27, %0
%31 = call i32 @exit(i32 0)
unreachable
32: ; preds = %27
%33 = load i32, i32* @AF_INET
%34 = load i32, i32* @SOCK_STREAM
%35 = call i32 @socket(i32 %33, i32 %34, i32 0)
store i32 %35, i32* %2
%36 = load i32, i32* @AF_INET
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i32 %36, i32* %37
%38 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
%40 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %39, i32 0, i32 0
store i32 %38, i32* %40
%41 = load i32, i32* %8
%42 = add nsw i32 8080, %41
%43 = call i32 @htons(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
store i32 %43, i32* %44
store i32 12, i32* %4
%45 = load i32, i32* %2
%46 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%47 = load i32, i32* %4
%48 = call i32 @connect(i32 %45, %struct.sockaddr* %46, i32 %47)
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %54
51: ; preds = %32
%52 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %32
%55 = load i32, i32* %2
%56 = call i32* @fdopen(i32 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %56, i32** %3
%57 = load i32*, i32** %3
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %54
br label %63
63: ; preds = %67, %62
%64 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%65 = call i64 @strncmp(i8* %64, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 15)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %63
%68 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%69 = load i32*, i32** %3
%70 = call i32 @fgets(i8* %68, i32 70, i32* %69)
br label %63
71: ; preds = %63
%72 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%73 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%74 = call i32 (i8*, i8*, ...) @sscanf(i8* %72, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %73, i32* %7)
%75 = getelementptr inbounds [80 x i8], [80 x i8]* %9, i64 0, i64 0
%76 = load i32*, i32** %3
%77 = call i32 @fgets(i8* %75, i32 70, i32* %76)
%78 = getelementptr inbounds [40000 x i8], [40000 x i8]* %11, i64 0, i64 0
%79 = load i32, i32* %7
%80 = load i32*, i32** %3
%81 = call i32 @fread(i8* %78, i32 1, i32 %79, i32* %80)
%82 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%83 = getelementptr inbounds [40000 x i8], [40000 x i8]* %11, i64 0, i64 0
%84 = load i32, i32* %7
%85 = load i32, i32* @stdout
%86 = call i32 @fwrite(i8* %83, i32 1, i32 %84, i32 %85)
%87 = load i32, i32* @stdout
%88 = call i32 @fflush(i32 %87)
%89 = load i32*, i32** %3
%90 = call i32 @fclose(i32* %89)
%91 = load i32, i32* %2
%92 = call i32 @close(i32 %91)
%93 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str.2 = [7 x i8] c"WORKS!\00"
@.str.3 = [13 x i8] c"QUERY_STRING\00"
@.str.4 = [3 x i8] c"%d\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [10 x i8] c"127.0.0.1\00"
@.str.6 = [31 x i8] c"oops: Cannot connect to Motion\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [16 x i8] c"Content-Length:\00"
@.str.9 = [5 x i8] c"%s%d\00"
@stdout = global i32 0
@str = [16 x i8] c"HTTP/1.1 200 OK\00"
@str.11 = [25 x i8] c"Content-Type: text/html\0A\00"
@str.12 = [26 x i8] c"Content-Type: image/jpeg\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca [30 x i8]
%6 = alloca [40000 x i8]
%7 = bitcast %struct.sockaddr_in* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [40000 x i8], [40000 x i8]* %6, i64 0, i64 0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, i8*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = add i32 %21, -14
%23 = icmp ult i32 %22, -13
br i1 %23, label %24, label %26
24: ; preds = %0
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %0
%27 = load i32, i32* @AF_INET
%28 = load i32, i32* @SOCK_STREAM
%29 = call i32 @socket(i32 %27, i32 %28, i32 0)
%30 = load i32, i32* @AF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %30, i32* %31
%32 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %32, i32* %33
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 8080
%36 = call i32 @htons(i32 %35)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %36, i32* %37
%38 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%39 = call i32 @connect(i32 %29, %struct.sockaddr* %38, i32 12)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %26
%42 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %26
%45 = call i32* @fdopen(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 15)
%49 = icmp eq i64 %48, 0
br i1 %49, label %57, label %53
50: ; preds = %44
%51 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %47, %53
%54 = call i32 @fgets(i8* %10, i32 70, i32* %45)
%55 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32 15)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %53
57: ; preds = %53, %47
%58 = call i32 (i8*, i8*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %11, i32* %2)
%59 = call i32 @fgets(i8* %10, i32 70, i32* %45)
%60 = load i32, i32* %2
%61 = call i32 @fread(i8* %12, i32 1, i32 %60, i32* %45)
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
%63 = load i32, i32* %2
%64 = load i32, i32* @stdout
%65 = call i32 @fwrite(i8* %12, i32 1, i32 %63, i32 %64)
%66 = load i32, i32* @stdout
%67 = call i32 @fflush(i32 %66)
%68 = call i32 @fclose(i32* %45)
%69 = call i32 @close(i32 %29)
%70 = call i32 @exit(i32 0)
unreachable
}