#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 {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ *h_addr_list;
};
typedef size_t ssize_t;
typedef int /*<<< orphan*/ recv_buff;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
unsigned int count_words_in_sentence(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
scalar_t__ make_http_get_request(int, char *, char *);
int /*<<< orphan*/ make_http_post_request(int, char *, char *, char *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ puts(char *);
size_t recv(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *strstr(char *, char *);
int main(void) {
  int sockfd;
  struct hostent *task_host;
  struct sockaddr_in addr;
  char uri_buff[1024];
  char recv_buff[1024];
  ssize_t recv_len;
  char *secret;
  char *sentence;
  unsigned int words_in_sentence;
  char answer_buff[20];
  char *server_justice;
  task_host = gethostbyname("pb-homework.appspot.com");
  if (task_host == NULL) {
    perror("Can't resolve host name");
    exit(EXIT_FAILURE);
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  addr.sin_family = AF_INET;
  addr.sin_port = htons(80);
  memcpy(&addr.sin_addr, task_host->h_addr_list[0], task_host->h_length);
  if (connect(sockfd, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
    perror("Can't connect");
    exit(EXIT_FAILURE);
  }
  if (make_http_get_request(sockfd,
                            "/var/"
                            "5",
                            "pb-homework.appspot.com") < 0) {
    perror("Can't request secret");
    exit(EXIT_FAILURE);
  }
  recv_len = recv(sockfd, recv_buff,
                  (sizeof(recv_buff) / sizeof((recv_buff)[0])) - 1, 0);
  recv_buff[recv_len] = '\0';
  secret = strstr(recv_buff, "\r\n"
                             "\r\n"
                             "secret=");
  if (secret == NULL) {
    perror("Can't find secret =( Maybe, buffer is not big enough");
    exit(EXIT_FAILURE);
  }
  secret += strlen("\r\n"
                   "\r\n"
                   "secret=");
  printf("Secret is \"%s\"\n", secret);
  sprintf(uri_buff,
          "/var/"
          "5"
          "?secret=%s",
          secret);
  if (make_http_get_request(sockfd, uri_buff, "pb-homework.appspot.com") < 0) {
    perror("Can't request data");
    exit(EXIT_FAILURE);
  }
  recv_len = recv(sockfd, recv_buff,
                  (sizeof(recv_buff) / sizeof((recv_buff)[0])) - 1, 0);
  recv_buff[recv_len] = '\0';
  sentence = strstr(recv_buff, "\r\n"
                               "\r\n");
  if (sentence == NULL) {
    perror("Can't find data =) Maybe, buffer is not big enough");
    exit(EXIT_FAILURE);
  }
  sentence += strlen("\r\n"
                     "\r\n");
  words_in_sentence = count_words_in_sentence(sentence);
  printf("Sentence is \"%s\" and it has %d words\n", sentence,
         words_in_sentence);
  strcpy(uri_buff, "/var/"
                   "5");
  sprintf(answer_buff, "result=%d", words_in_sentence);
  make_http_post_request(sockfd, uri_buff, "pb-homework.appspot.com",
                         answer_buff);
  recv_len = recv(sockfd, recv_buff,
                  (sizeof(recv_buff) / sizeof((recv_buff)[0])) - 1, 0);
  recv_buff[recv_len] = '\0';
  server_justice = strstr(recv_buff, "\r\n"
                                     "\r\n"
                                     "Failure!");
  if (server_justice != NULL) {
    puts("Failure, for some reason");
  } else {
    server_justice = strstr(recv_buff, "\r\n"
                                       "\r\n"
                                       "Success!");
    if (server_justice != NULL) {
      puts("Did that");
    } else {
      puts("Not \"Success!\" nor \"Failure!\" found. Shitty client"
           "deserved shitty result");
    }
  }
  close(sockfd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xdc7(%rip),%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1267 <main+0x47>
lea    0xdc4(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x50,%edi
call   1070 <htons@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
call   10b0 <memcpy@plt>
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1110 <connect@plt>
cmp    $0x0,%rax
je     12ea <main+0xca>
lea    0xd59(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%edi
lea    0xd4a(%rip),%rsi
lea    0xd05(%rip),%rdx
call   10d0 <make_http_get_request@plt>
cmp    $0x0,%rax
jge    1324 <main+0x104>
lea    0xd34(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
lea    -0x820(%rbp),%rdi
lea    0xcfc(%rip),%rsi
call   1120 <strstr@plt>
mov    %rax,-0x830(%rbp)
cmpq   $0x0,-0x830(%rbp)
jne    1392 <main+0x172>
lea    0xce7(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xcc1(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x830(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x830(%rbp)
mov    -0x830(%rbp),%rsi
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x420(%rbp),%rdi
mov    -0x830(%rbp),%rdx
lea    0xccd(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
lea    0xc0a(%rip),%rdx
call   10d0 <make_http_get_request@plt>
cmp    $0x0,%rax
jge    141f <main+0x1ff>
lea    0xcb0(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
lea    -0x820(%rbp),%rdi
lea    0xc76(%rip),%rsi
call   1120 <strstr@plt>
mov    %rax,-0x838(%rbp)
cmpq   $0x0,-0x838(%rbp)
jne    148d <main+0x26d>
lea    0xc5a(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xc3b(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x838(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x838(%rbp)
mov    -0x838(%rbp),%rdi
call   10c0 <count_words_in_sentence@plt>
mov    %eax,-0x83c(%rbp)
mov    -0x838(%rbp),%rsi
mov    -0x83c(%rbp),%edx
lea    0xc32(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x420(%rbp),%rdi
lea    0xb54(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x850(%rbp),%rdi
mov    -0x83c(%rbp),%edx
lea    0xc2a(%rip),%rsi
mov    $0x0,%al
call   10f0 <sprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
lea    -0x850(%rbp),%rcx
lea    0xade(%rip),%rdx
call   1130 <make_http_post_request@plt>
mov    -0x8(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x828(%rbp)
mov    -0x828(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
lea    -0x820(%rbp),%rdi
lea    0xbd6(%rip),%rsi
call   1120 <strstr@plt>
mov    %rax,-0x858(%rbp)
cmpq   $0x0,-0x858(%rbp)
je     158c <main+0x36c>
lea    0xbc2(%rip),%rdi
call   1050 <puts@plt>
jmp    15d6 <main+0x3b6>
lea    -0x820(%rbp),%rdi
lea    0xbc3(%rip),%rsi
call   1120 <strstr@plt>
mov    %rax,-0x858(%rbp)
cmpq   $0x0,-0x858(%rbp)
je     15c5 <main+0x3a5>
lea    0xbaf(%rip),%rdi
call   1050 <puts@plt>
jmp    15d1 <main+0x3b1>
lea    0xba7(%rip),%rdi
call   1050 <puts@plt>
jmp    15d6 <main+0x3b6>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    0x29e3(%rip),%rax
mov    (%rax),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x838,%rsp
lea    0xdcc(%rip),%rdi
call   10a0 <gethostbyname@plt>
test   %rax,%rax
je     147e <main+0x25e>
mov    %rax,%rbx
mov    0x2d9c(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d82(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    $0x50,%edi
call   1070 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10b0 <memcpy@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1110 <connect@plt>
test   %rax,%rax
jne    1487 <main+0x267>
lea    0xd94(%rip),%rsi
lea    0xd4f(%rip),%rdx
mov    %r14d,%edi
call   10d0 <make_http_get_request@plt>
test   %rax,%rax
js     1490 <main+0x270>
lea    0x30(%rsp),%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xd75(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strstr@plt>
test   %rax,%rax
je     1499 <main+0x279>
mov    %rax,%rbx
lea    0xd5a(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%rbx
lea    0xd8a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd89(%rip),%rsi
lea    0x430(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10f0 <sprintf@plt>
lea    0xcc2(%rip),%rdx
mov    %r14d,%edi
mov    %rbp,%rsi
call   10d0 <make_http_get_request@plt>
test   %rax,%rax
js     14a2 <main+0x282>
lea    0x30(%rsp),%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xd5a(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strstr@plt>
test   %rax,%rax
je     14ab <main+0x28b>
mov    %rax,%rbx
lea    0xd3f(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
call   10c0 <count_words_in_sentence@plt>
mov    %eax,%ebp
lea    0xd5c(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc80(%rip),%rsi
lea    0x430(%rsp),%r15
mov    %r15,%rdi
call   1040 <strcpy@plt>
lea    0xd58(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   10f0 <sprintf@plt>
lea    0xc13(%rip),%rdx
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rcx
call   1130 <make_http_post_request@plt>
lea    0x30(%rsp),%rbx
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xd19(%rip),%rsi
mov    %rbx,%rdi
call   1120 <strstr@plt>
test   %rax,%rax
je     1434 <main+0x214>
lea    0xd12(%rip),%rdi
jmp    145a <main+0x23a>
lea    0xd22(%rip),%rsi
lea    0x30(%rsp),%rdi
call   1120 <strstr@plt>
test   %rax,%rax
lea    0xd24(%rip),%rax
lea    0xd14(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@plt>
mov    %r14d,%edi
call   1090 <close@plt>
mov    0x2b5a(%rip),%rax
mov    (%rax),%eax
add    $0x838,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb93(%rip),%rdi
jmp    14b2 <main+0x292>
lea    0xba2(%rip),%rdi
jmp    14b2 <main+0x292>
lea    0xbae(%rip),%rdi
jmp    14b2 <main+0x292>
lea    0xbc6(%rip),%rdi
jmp    14b2 <main+0x292>
lea    0xc13(%rip),%rdi
jmp    14b2 <main+0x292>
lea    0xc22(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b12(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i32, i32* }
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [24 x i8] c"pb-homework.appspot.com\00"
@.str.1 = [24 x i8] c"Can't resolve host name\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [14 x i8] c"Can't connect\00"
@.str.3 = [7 x i8] c"/var/5\00"
@.str.4 = [21 x i8] c"Can't request secret\00"
@.str.5 = [12 x i8] c"\0D\0A\0D\0Asecret=\00"
@.str.6 = [53 x i8] c"Can't find secret =( Maybe, buffer is not big enough\00"
@.str.7 = [16 x i8] c"Secret is \22%s\22\0A\00"
@.str.8 = [17 x i8] c"/var/5?secret=%s\00"
@.str.9 = [19 x i8] c"Can't request data\00"
@.str.10 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.11 = [51 x i8] c"Can't find data =) Maybe, buffer is not big enough\00"
@.str.12 = [38 x i8] c"Sentence is \22%s\22 and it has %d words\0A\00"
@.str.13 = [10 x i8] c"result=%d\00"
@.str.14 = [13 x i8] c"\0D\0A\0D\0AFailure!\00"
@.str.15 = [25 x i8] c"Failure, for some reason\00"
@.str.16 = [13 x i8] c"\0D\0A\0D\0ASuccess!\00"
@.str.17 = [9 x i8] c"Did that\00"
@.str.18 = [73 x i8] c"Not \22Success!\22 nor \22Failure!\22 found. Shitty clientdeserved shitty result\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.hostent*
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [20 x i8]
%12 = alloca i8*
store i32 0, i32* %1
%13 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store %struct.hostent* %13, %struct.hostent** %3
%14 = load %struct.hostent*, %struct.hostent** %3
%15 = icmp eq %struct.hostent* %14, null
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %0
%21 = load i32, i32* @AF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %2
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %24, i32* %25
%26 = call i32 @htons(i32 80)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%29 = load %struct.hostent*, %struct.hostent** %3
%30 = getelementptr inbounds %struct.hostent, %struct.hostent* %29, i32 0, i32 1
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 0
%33 = load i32, i32* %32
%34 = load %struct.hostent*, %struct.hostent** %3
%35 = getelementptr inbounds %struct.hostent, %struct.hostent* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 @memcpy(i32* %28, i32 %33, i32 %36)
%38 = load i32, i32* %2
%39 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%40 = call i64 @connect(i32 %38, %struct.sockaddr* %39, i32 12)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %20
%43 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %20
%47 = load i32, i32* %2
%48 = call i64 @make_http_get_request(i32 %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %46
%55 = load i32, i32* %2
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%57 = call i64 @recv(i32 %55, i8* %56, i32 1023, i32 0)
store i64 %57, i64* %7
%58 = load i64, i64* %7
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %58
store i8 0, i8* %59
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%61 = call i8* @strstr(i8* %60, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i8* %61, i8** %8
%62 = load i8*, i8** %8
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %68
64: ; preds = %54
%65 = call i32 @perror(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %54
%69 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%70 = load i8*, i8** %8
%71 = sext i32 %69 to i64
%72 = getelementptr inbounds i8, i8* %70, i64 %71
store i8* %72, i8** %8
%73 = load i8*, i8** %8
%74 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %73)
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%76 = load i8*, i8** %8
%77 = call i32 (i8*, i8*, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %76)
%78 = load i32, i32* %2
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%80 = call i64 @make_http_get_request(i32 %78, i8* %79, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %68
%83 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%84 = load i32, i32* @EXIT_FAILURE
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %68
%87 = load i32, i32* %2
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%89 = call i64 @recv(i32 %87, i8* %88, i32 1023, i32 0)
store i64 %89, i64* %7
%90 = load i64, i64* %7
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %90
store i8 0, i8* %91
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%93 = call i8* @strstr(i8* %92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
store i8* %93, i8** %9
%94 = load i8*, i8** %9
%95 = icmp eq i8* %94, null
br i1 %95, label %96, label %100
96: ; preds = %86
%97 = call i32 @perror(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i64 0, i64 0))
%98 = load i32, i32* @EXIT_FAILURE
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %86
%101 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%102 = load i8*, i8** %9
%103 = sext i32 %101 to i64
%104 = getelementptr inbounds i8, i8* %102, i64 %103
store i8* %104, i8** %9
%105 = load i8*, i8** %9
%106 = call i32 @count_words_in_sentence(i8* %105)
store i32 %106, i32* %10
%107 = load i8*, i8** %9
%108 = load i32, i32* %10
%109 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i8* %107, i32 %108)
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%111 = call i32 @strcpy(i8* %110, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%112 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%113 = load i32, i32* %10
%114 = call i32 (i8*, i8*, ...) @sprintf(i8* %112, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %113)
%115 = load i32, i32* %2
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%117 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%118 = call i32 @make_http_post_request(i32 %115, i8* %116, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %117)
%119 = load i32, i32* %2
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%121 = call i64 @recv(i32 %119, i8* %120, i32 1023, i32 0)
store i64 %121, i64* %7
%122 = load i64, i64* %7
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %122
store i8 0, i8* %123
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%125 = call i8* @strstr(i8* %124, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
store i8* %125, i8** %12
%126 = load i8*, i8** %12
%127 = icmp ne i8* %126, null
br i1 %127, label %128, label %130
128: ; preds = %100
%129 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
br label %140
130: ; preds = %100
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%132 = call i8* @strstr(i8* %131, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0))
store i8* %132, i8** %12
%133 = load i8*, i8** %12
%134 = icmp ne i8* %133, null
br i1 %134, label %135, label %137
135: ; preds = %130
%136 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0))
br label %139
137: ; preds = %130
%138 = call i32 @puts(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.18, i64 0, i64 0))
br label %139
139: ; preds = %137, %135
br label %140
140: ; preds = %139, %128
%141 = load i32, i32* %2
%142 = call i32 @close(i32 %141)
%143 = load i32, i32* @EXIT_SUCCESS
ret i32 %143
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i32* }
%struct.sockaddr = type { i32 }
@.str = [24 x i8] c"pb-homework.appspot.com\00"
@.str.1 = [24 x i8] c"Can't resolve host name\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [14 x i8] c"Can't connect\00"
@.str.3 = [7 x i8] c"/var/5\00"
@.str.4 = [21 x i8] c"Can't request secret\00"
@.str.5 = [12 x i8] c"\0D\0A\0D\0Asecret=\00"
@.str.6 = [53 x i8] c"Can't find secret =( Maybe, buffer is not big enough\00"
@.str.7 = [16 x i8] c"Secret is \22%s\22\0A\00"
@.str.8 = [17 x i8] c"/var/5?secret=%s\00"
@.str.9 = [19 x i8] c"Can't request data\00"
@.str.10 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.11 = [51 x i8] c"Can't find data =) Maybe, buffer is not big enough\00"
@.str.12 = [38 x i8] c"Sentence is \22%s\22 and it has %d words\0A\00"
@.str.13 = [10 x i8] c"result=%d\00"
@.str.14 = [13 x i8] c"\0D\0A\0D\0AFailure!\00"
@.str.15 = [25 x i8] c"Failure, for some reason\00"
@.str.16 = [13 x i8] c"\0D\0A\0D\0ASuccess!\00"
@.str.17 = [9 x i8] c"Did that\00"
@.str.18 = [73 x i8] c"Not \22Success!\22 nor \22Failure!\22 found. Shitty clientdeserved shitty result\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [20 x i8]
%5 = bitcast %struct.sockaddr_in* %1 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq %struct.hostent* %9, null
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = load i32, i32* @AF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %19, i32* %20
%21 = tail call i32 @htons(i32 80)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%24 = getelementptr inbounds %struct.hostent, %struct.hostent* %9, i64 0, i32 1
%25 = load i32*, i32** %24
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.hostent, %struct.hostent* %9, i64 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @memcpy(i32* %23, i32 %26, i32 %28)
%30 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%31 = call i64 @connect(i32 %18, %struct.sockaddr* %30, i32 12)
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %15
%34 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %15
%38 = call i64 @make_http_get_request(i32 %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %37
%45 = call i64 @recv(i32 %18, i8* %7, i32 1023, i32 0)
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %45
store i8 0, i8* %46
%47 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %53
49: ; preds = %44
%50 = call i32 @perror(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.6, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %44
%54 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %47, i64 %55
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %56)
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* %56)
%59 = call i64 @make_http_get_request(i32 %18, i8* %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %53
%62 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %53
%66 = call i64 @recv(i32 %18, i8* %7, i32 1023, i32 0)
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %66
store i8 0, i8* %67
%68 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%69 = icmp eq i8* %68, null
br i1 %69, label %70, label %74
70: ; preds = %65
%71 = call i32 @perror(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %65
%75 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %68, i64 %76
%78 = call i32 @count_words_in_sentence(i8* %77)
%79 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0), i8* %77, i32 %78)
%80 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%81 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %78)
%82 = call i32 @make_http_post_request(i32 %18, i8* %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8)
%83 = call i64 @recv(i32 %18, i8* %7, i32 1023, i32 0)
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %83
store i8 0, i8* %84
%85 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%86 = icmp eq i8* %85, null
br i1 %86, label %87, label %91
87: ; preds = %74
%88 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i64 0, i64 0))
%89 = icmp eq i8* %88, null
%90 = select i1 %89, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0)
br label %91
91: ; preds = %87, %74
%92 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), %74 ], [ %90, %87 ]
%93 = call i32 @puts(i8* dereferenceable(1) %92)
%94 = call i32 @close(i32 %18)
%95 = load i32, i32* @EXIT_SUCCESS
ret i32 %95
}