#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 dummy;
};
struct addrinfo {
  int dummy;
};

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ clean_stdin();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(char *, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int tcp_connect(char *, char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int sockfd, port, n, cmd, choix, BrewChoix, HowMany;
  char *HowManyMug;
  char *WhenBrew;
  char *WhenChoix;
  char *request;
  char *readSocket;
  struct sockaddr_in serv_addr;
  struct addrinfo *server;
  char buffer[1024];
  sockfd = tcp_connect("127.0.0.1", "80");
  if (sockfd < 0)
    error("ERROR opening socket");
  while (choix != 9) {
    printf("\n##\n");
    printf("## Welcome to the HTCPCP Client\n");
    printf("## This project was created for the C programming lesson of ESGI "
           "school.\n");
    printf("## The project is released under the GNU GPL v2.0 License.\n");
    printf("## Author: Dylan Dubief.\n");
    printf("## Last update: 23/02/15\n");
    printf("###################################################################"
           "#########\n");
    printf("\n\n\n");
    printf("1) Brew request\n");
    printf("2) Get request\n");
    printf("3) Propfind request\n");
    printf("9) Quitter le C&C\n");
    printf("\n\nChoix : ");
    scanf(" %d", &choix);
    if ((choix < 1 && choix != 0) || (choix > 3 && choix != 9)) {
      printf("\nMauvaise commande.\n");
      choix = 0;
    } else if (choix == 1) {
      printf("\n\nDo you want your coffee now ?\n");
      printf("1) Yeah, i need coffeeeeeee\n");
      printf("2) No, I'll tell you when.\n");
      scanf(" %d", &BrewChoix);
      if (BrewChoix == 1) {
        request = calloc(124, sizeof(char));
        readSocket = calloc(512, sizeof(char));
        HowManyMug = calloc(2, sizeof(char));
        printf("\nHow many mugs do you want ?\n");
        clean_stdin();
        scanf("%d", &HowMany);
        if (HowMany > 0 && HowMany <= 8) {
          sprintf(HowManyMug, "%d", HowMany);
          strncpy(request,
                  "BREW /pot-1 HTCPCP/1.1\r\nContent-Type: "
                  "message/coffeepot\r\nAccept-additions: "
                  "no-additions\r\nContent-Length: ",
                  105 * sizeof(char));
          strncat(request, HowManyMug, 2 * sizeof(char));
          printf("Request:\n%s", request);
          n = write(sockfd, request, strlen(request));
          if (n < 0)
            error("Error writing socket\n");
          n = read(sockfd, readSocket, 512);
          if (n < 0)
            error("Error reading socket\n");
          printf("\nResponse: %s\n", readSocket);
        }
        free(HowManyMug);
        free(request);
      } else if (BrewChoix == 2) {
        request = calloc(124, sizeof(char));
        WhenBrew = calloc(2, sizeof(char));
        HowManyMug = calloc(2, sizeof(char));
        readSocket = calloc(512, sizeof(char));
        printf("\nWhen do you want your coffee ? (Minute)\n");
        clean_stdin();
        scanf("%d", &HowMany);
        if (HowMany > 0 && HowMany < 121) {
          sprintf(WhenBrew, "%d", HowMany);
          strncpy(request, "WHEN /pot-1 HTCPCP/1.1\r\nWhen-I-Want: ", 37);
          strncat(request, WhenBrew, strlen(WhenBrew));
          strcat(request, "\r\n");
          printf("\nHow many mugs do you want ?\n");
          clean_stdin();
          scanf("%d", &HowMany);
          if (HowMany > 0 && HowMany <= 8) {
            sprintf(HowManyMug, "%d", HowMany);
            strncat(request,
                    "Content-Type: message/coffeepot\r\nAccept-additions: "
                    "no-additions\r\nContent-Length: ",
                    105 * sizeof(char));
            strncat(request, HowManyMug, 2 * sizeof(char));
            printf("\nRequest:\n%s", request);
            n = write(sockfd, request, strlen(request));
            if (n < 0)
              error("Error writing socket\n");
            n = read(sockfd, readSocket, 512);
            if (n < 0)
              error("Error reading socket\n");
            printf("\nResponse: %s\n", readSocket);
          }
        }
        free(readSocket);
        free(HowManyMug);
        free(request);
        free(WhenBrew);
      }
    } else if (choix == 2) {
      request = calloc(22, sizeof(char));
      readSocket = calloc(512, sizeof(char));
      snprintf(request, 22, "GET /pot-1 HTCPCP/1.1");
      n = write(sockfd, request, strlen(request));
      if (n < 0)
        error("Error writing socket\n");
      n = read(sockfd, readSocket, 512);
      if (n < 0)
        error("Error reading socket\n");
      printf("\nResponse: %s\n", readSocket);
      free(readSocket);
      free(request);
    } else if (choix == 3) {
      request = calloc(27, sizeof(char));
      readSocket = calloc(512, sizeof(char));
      snprintf(request, 27, "PROPFIND /pot-1 HTCPCP/1.1");
      n = write(sockfd, request, strlen(request));
      if (n < 0)
        error("Error writing socket\n");
      n = read(sockfd, readSocket, 512);
      if (n < 0)
        error("Error reading socket\n");
      printf("\nResponse: %s\n", readSocket);
      free(readSocket);
      free(request);
    } else if (choix == 9) {
      close(sockfd);
      exit(1);
    }
    sleep(2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdc0(%rip),%rdi
lea    0xdc3(%rip),%rsi
call   1060 <tcp_connect@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1265 <main+0x45>
lea    0xdad(%rip),%rdi
call   1100 <error@plt>
jmp    126a <main+0x4a>
cmpl   $0x9,-0x24(%rbp)
je     1961 <main+0x741>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe77(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   10f0 <scanf@plt>
cmpl   $0x1,-0x24(%rbp)
jge    134e <main+0x12e>
cmpl   $0x0,-0x24(%rbp)
jne    1362 <main+0x142>
cmpl   $0x3,-0x24(%rbp)
jle    137c <main+0x15c>
cmpl   $0x9,-0x24(%rbp)
je     137c <main+0x15c>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x24(%rbp)
jmp    1952 <main+0x732>
cmpl   $0x1,-0x24(%rbp)
jne    175e <main+0x53e>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xdf1(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   10f0 <scanf@plt>
cmpl   $0x1,-0x28(%rbp)
jne    1525 <main+0x305>
mov    $0x7c,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x38(%rbp)
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10a0 <clean_stdin@plt>
lea    0xd8a(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   10f0 <scanf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    150e <main+0x2ee>
cmpl   $0x8,-0x2c(%rbp)
jg     150e <main+0x2ee>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xd5f(%rip),%rsi
call   1120 <sprintf@plt>
mov    -0x50(%rbp),%rdi
lea    0xddf(%rip),%rsi
mov    $0x69,%edx
call   1040 <strncpy@plt>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x2,%edx
call   10b0 <strncat@plt>
mov    -0x50(%rbp),%rsi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x47c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x478(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x47c(%rbp),%edi
mov    -0x478(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    14d2 <main+0x2b2>
lea    0xdd6(%rip),%rdi
call   1100 <error@plt>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x200,%edx
call   10d0 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    14fc <main+0x2dc>
lea    0xdc2(%rip),%rdi
call   1100 <error@plt>
mov    -0x58(%rbp),%rsi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    1759 <main+0x539>
cmpl   $0x2,-0x28(%rbp)
jne    1754 <main+0x534>
mov    $0x7c,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x58(%rbp)
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10a0 <clean_stdin@plt>
lea    0xc12(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   10f0 <scanf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    1730 <main+0x510>
cmpl   $0x79,-0x2c(%rbp)
jge    1730 <main+0x510>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xbe7(%rip),%rsi
call   1120 <sprintf@plt>
mov    -0x50(%rbp),%rdi
lea    0xd36(%rip),%rsi
mov    $0x25,%edx
call   1040 <strncpy@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x490(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x488(%rbp)
mov    -0x40(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x490(%rbp),%rdi
mov    -0x488(%rbp),%rsi
mov    %eax,%edx
call   10b0 <strncat@plt>
mov    -0x50(%rbp),%rdi
lea    0xd13(%rip),%rsi
call   1110 <strcat@plt>
lea    0xbf4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10a0 <clean_stdin@plt>
lea    0xb6d(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   10f0 <scanf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    172b <main+0x50b>
cmpl   $0x8,-0x2c(%rbp)
jg     172b <main+0x50b>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xb42(%rip),%rsi
call   1120 <sprintf@plt>
mov    -0x50(%rbp),%rdi
lea    0xbda(%rip),%rsi
mov    $0x69,%edx
call   10b0 <strncat@plt>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x2,%edx
call   10b0 <strncat@plt>
mov    -0x50(%rbp),%rsi
lea    0xc93(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x49c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x498(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x49c(%rbp),%edi
mov    -0x498(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    16ef <main+0x4cf>
lea    0xbb9(%rip),%rdi
call   1100 <error@plt>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x200,%edx
call   10d0 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1719 <main+0x4f9>
lea    0xba5(%rip),%rdi
call   1100 <error@plt>
mov    -0x58(%rbp),%rsi
lea    0xbab(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1730 <main+0x510>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    1759 <main+0x539>
jmp    194d <main+0x72d>
cmpl   $0x2,-0x24(%rbp)
jne    1840 <main+0x620>
mov    $0x16,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    $0x16,%esi
lea    0xba0(%rip),%rdx
call   1090 <snprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4ac(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x4a8(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x4ac(%rbp),%edi
mov    -0x4a8(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    17ed <main+0x5cd>
lea    0xabb(%rip),%rdi
call   1100 <error@plt>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x200,%edx
call   10d0 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1817 <main+0x5f7>
lea    0xaa7(%rip),%rdi
call   1100 <error@plt>
mov    -0x58(%rbp),%rsi
lea    0xaad(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    1948 <main+0x728>
cmpl   $0x3,-0x24(%rbp)
jne    1922 <main+0x702>
mov    $0x1b,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0x200,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    $0x1b,%esi
lea    0xad4(%rip),%rdx
call   1090 <snprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4bc(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x4b8(%rbp)
mov    -0x50(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x4bc(%rbp),%edi
mov    -0x4b8(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    18cf <main+0x6af>
lea    0x9d9(%rip),%rdi
call   1100 <error@plt>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x200,%edx
call   10d0 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    18f9 <main+0x6d9>
lea    0x9c5(%rip),%rdi
call   1100 <error@plt>
mov    -0x58(%rbp),%rsi
lea    0x9cb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    1943 <main+0x723>
cmpl   $0x9,-0x24(%rbp)
jne    193e <main+0x71e>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
jmp    1943 <main+0x723>
jmp    1948 <main+0x728>
jmp    194d <main+0x72d>
jmp    1952 <main+0x732>
mov    $0x2,%edi
call   1140 <sleep@plt>
jmp    126a <main+0x4a>
xor    %eax,%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xde3(%rip),%rdi
lea    0xde6(%rip),%rsi
call   1070 <tcp_connect@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    1264 <main+0x34>
lea    0xdd6(%rip),%rdi
call   1110 <error@plt>
lea    0xefa(%rip),%r14
lea    0xef7(%rip),%rbx
lea    0xf10(%rip),%rbp
lea    0xdd5(%rip),%r13
lea    0xd79(%rip),%r15
jmp    12b9 <main+0x89>
nopl   0x0(%rax)
lea    0x10da(%rip),%rdi
call   1050 <puts@plt>
movl   $0x0,0x4(%rsp)
mov    $0x2,%edi
call   1150 <sleep@plt>
cmpl   $0x9,0x4(%rsp)
je     17b1 <main+0x581>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
lea    0xefa(%rip),%rdi
call   1050 <puts@plt>
lea    0xf29(%rip),%rdi
call   1050 <puts@plt>
lea    0xf36(%rip),%rdi
call   1050 <puts@plt>
lea    0xf43(%rip),%rdi
call   1050 <puts@plt>
lea    0xf84(%rip),%rdi
call   1050 <puts@plt>
lea    0xf7b(%rip),%rdi
call   1050 <puts@plt>
lea    0xf7f(%rip),%rdi
call   1050 <puts@plt>
lea    0xf82(%rip),%rdi
call   1050 <puts@plt>
lea    0xf8a(%rip),%rdi
call   1050 <puts@plt>
lea    0xd06(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r13,%rdi
lea    0x4(%rsp),%rsi
call   1100 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1290 <main+0x60>
cmp    $0x9,%eax
ja     1290 <main+0x60>
mov    %eax,%eax
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xf55(%rip),%rdi
call   1050 <puts@plt>
lea    0xf69(%rip),%rdi
call   1050 <puts@plt>
lea    0xf79(%rip),%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
lea    0x14(%rsp),%rsi
call   1100 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     15d7 <main+0x3a7>
cmp    $0x1,%eax
jne    12a4 <main+0x74>
mov    $0x7c,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%rbp
mov    $0x200,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x2,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%r14
lea    0xf56(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10b0 <clean_stdin@plt>
lea    0xc45(%rip),%rdi
mov    %rsp,%rsi
call   1100 <scanf@plt>
mov    (%rsp),%edx
lea    -0x1(%rdx),%eax
cmp    $0x7,%eax
ja     14ce <main+0x29e>
mov    %r14,%rdi
lea    0xc24(%rip),%rsi
call   1130 <sprintf@plt>
mov    %rbp,%rdi
lea    0xc18(%rip),%rsi
mov    $0x69,%edx
call   1040 <strncpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   10c0 <strncat@plt>
lea    0xcc6(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
test   %eax,%eax
jns    1491 <main+0x261>
lea    0xc37(%rip),%rdi
call   1110 <error@plt>
mov    %r12d,%edi
mov    0x8(%rsp),%r13
mov    %r13,%rsi
mov    $0x200,%edx
call   10e0 <read@plt>
test   %eax,%eax
jns    14b6 <main+0x286>
lea    0xc28(%rip),%rdi
call   1110 <error@plt>
lea    0xc32(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xb87(%rip),%r13
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xc80(%rip),%r14
lea    0xc9d(%rip),%rbp
jmp    12a4 <main+0x74>
mov    $0x16,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%rbp
mov    $0x200,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x16,%esi
lea    0xc10(%rip),%rdx
jmp    1559 <main+0x329>
mov    $0x1b,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%rbp
mov    $0x200,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x1b,%esi
lea    0xbf1(%rip),%rdx
call   10a0 <snprintf@plt>
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
test   %eax,%eax
jns    1583 <main+0x353>
lea    0xb45(%rip),%rdi
call   1110 <error@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   10e0 <read@plt>
test   %eax,%eax
jns    15a3 <main+0x373>
lea    0xb3b(%rip),%rdi
call   1110 <error@plt>
lea    0xb45(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xb9e(%rip),%rbx
lea    0xbb7(%rip),%rbp
jmp    12a4 <main+0x74>
mov    $0x7c,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%r14
mov    $0x2,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%r15
mov    $0x2,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,0x8(%rsp)
mov    $0x200,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,0x18(%rsp)
lea    0xd01(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10b0 <clean_stdin@plt>
lea    0xa19(%rip),%rdi
mov    %rsp,%rsi
call   1100 <scanf@plt>
mov    (%rsp),%edx
lea    -0x1(%rdx),%eax
cmp    $0x77,%eax
ja     177a <main+0x54a>
mov    %r15,%rdi
lea    0x9f8(%rip),%rsi
call   1130 <sprintf@plt>
mov    %r14,%rdi
lea    0xa91(%rip),%rsi
mov    $0x25,%edx
call   1040 <strncpy@plt>
mov    %r15,%rdi
call   1080 <strlen@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   10c0 <strncat@plt>
mov    %r14,%rdi
lea    0xa8e(%rip),%rsi
call   1120 <strcat@plt>
lea    0xcb2(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   10b0 <clean_stdin@plt>
lea    0x9a1(%rip),%rdi
mov    %rsp,%rsi
call   1100 <scanf@plt>
mov    (%rsp),%edx
lea    -0x1(%rdx),%eax
cmp    $0x7,%eax
ja     177a <main+0x54a>
mov    %r15,0x20(%rsp)
mov    0x8(%rsp),%r15
mov    %r15,%rdi
lea    0x976(%rip),%rsi
call   1130 <sprintf@plt>
mov    %r14,%rdi
lea    0x982(%rip),%rsi
mov    $0x69,%edx
call   10c0 <strncat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   10c0 <strncat@plt>
lea    0xa17(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <write@plt>
test   %eax,%eax
jns    173f <main+0x50f>
lea    0x989(%rip),%rdi
call   1110 <error@plt>
mov    %r12d,%edi
mov    0x18(%rsp),%r15
mov    %r15,%rsi
mov    $0x200,%edx
call   10e0 <read@plt>
test   %eax,%eax
jns    1764 <main+0x534>
lea    0x97a(%rip),%rdi
call   1110 <error@plt>
lea    0x984(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0x9c0(%rip),%r14
lea    0x854(%rip),%r15
jmp    12a4 <main+0x74>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12d,%edi
call   10d0 <close@plt>
mov    $0x1,%edi
call   1140 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.addrinfo = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [3 x i8] c"80\00"
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@.str.3 = [5 x i8] c"\0A##\0A\00"
@.str.4 = [33 x i8] c"## Welcome to the HTCPCP Client\0A\00"
@.str.5 = [74 x i8] c"## This project was created for the C programming lesson of ESGI school.\0A\00"
@.str.6 = [60 x i8] c"## The project is released under the GNU GPL v2.0 License.\0A\00"
@.str.7 = [26 x i8] c"## Author: Dylan Dubief.\0A\00"
@.str.8 = [26 x i8] c"## Last update: 23/02/15\0A\00"
@.str.9 = [78 x i8] c"############################################################################\0A\00"
@.str.10 = [4 x i8] c"\0A\0A\0A\00"
@.str.11 = [17 x i8] c"1) Brew request\0A\00"
@.str.12 = [16 x i8] c"2) Get request\0A\00"
@.str.13 = [21 x i8] c"3) Propfind request\0A\00"
@.str.14 = [19 x i8] c"9) Quitter le C&C\0A\00"
@.str.15 = [11 x i8] c"\0A\0AChoix : \00"
@.str.16 = [4 x i8] c" %d\00"
@.str.17 = [21 x i8] c"\0AMauvaise commande.\0A\00"
@.str.18 = [33 x i8] c"\0A\0ADo you want your coffee now ?\0A\00"
@.str.19 = [29 x i8] c"1) Yeah, i need coffeeeeeee\0A\00"
@.str.20 = [28 x i8] c"2) No, I'll tell you when.\0A\00"
@.str.21 = [30 x i8] c"\0AHow many mugs do you want ?\0A\00"
@.str.22 = [3 x i8] c"%d\00"
@.str.23 = [106 x i8] c"BREW /pot-1 HTCPCP/1.1\0D\0AContent-Type: message/coffeepot\0D\0AAccept-additions: no-additions\0D\0AContent-Length: \00"
@.str.24 = [12 x i8] c"Request:\0A%s\00"
@.str.25 = [22 x i8] c"Error writing socket\0A\00"
@.str.26 = [22 x i8] c"Error reading socket\0A\00"
@.str.27 = [15 x i8] c"\0AResponse: %s\0A\00"
@.str.28 = [42 x i8] c"\0AWhen do you want your coffee ? (Minute)\0A\00"
@.str.29 = [38 x i8] c"WHEN /pot-1 HTCPCP/1.1\0D\0AWhen-I-Want: \00"
@.str.30 = [3 x i8] c"\0D\0A\00"
@.str.31 = [82 x i8] c"Content-Type: message/coffeepot\0D\0AAccept-additions: no-additions\0D\0AContent-Length: \00"
@.str.32 = [13 x i8] c"\0ARequest:\0A%s\00"
@.str.33 = [22 x i8] c"GET /pot-1 HTCPCP/1.1\00"
@.str.34 = [27 x i8] c"PROPFIND /pot-1 HTCPCP/1.1\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca %struct.sockaddr_in
%19 = alloca %struct.addrinfo*
%20 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = call i32 @tcp_connect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %2
br label %27
27: ; preds = %271, %26
%28 = load i32, i32* %10
%29 = icmp ne i32 %28, 9
br i1 %29, label %30, label %273
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.9, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i32* %10)
%45 = load i32, i32* %10
%46 = icmp slt i32 %45, 1
br i1 %46, label %47, label %50
47: ; preds = %30
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %56, label %50
50: ; preds = %47, %30
%51 = load i32, i32* %10
%52 = icmp sgt i32 %51, 3
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = load i32, i32* %10
%55 = icmp ne i32 %54, 9
br i1 %55, label %56, label %58
56: ; preds = %53, %47
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %10
br label %271
58: ; preds = %53, %50
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, 1
br i1 %60, label %61, label %196
61: ; preds = %58
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.18, i64 0, i64 0))
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0))
%65 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i32* %11)
%66 = load i32, i32* %11
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %116
68: ; preds = %61
%69 = call i8* @calloc(i32 124, i32 1)
store i8* %69, i8** %16
%70 = call i8* @calloc(i32 512, i32 1)
store i8* %70, i8** %17
%71 = call i8* @calloc(i32 2, i32 1)
store i8* %71, i8** %13
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0))
%73 = call i32 (...) @clean_stdin()
%74 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32* %12)
%75 = load i32, i32* %12
%76 = icmp sgt i32 %75, 0
br i1 %76, label %77, label %111
77: ; preds = %68
%78 = load i32, i32* %12
%79 = icmp sle i32 %78, 8
br i1 %79, label %80, label %111
80: ; preds = %77
%81 = load i8*, i8** %13
%82 = load i32, i32* %12
%83 = call i32 @sprintf(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32 %82)
%84 = load i8*, i8** %16
%85 = call i32 @strncpy(i8* %84, i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.23, i64 0, i64 0), i32 105)
%86 = load i8*, i8** %16
%87 = load i8*, i8** %13
%88 = call i32 @strncat(i8* %86, i8* %87, i32 2)
%89 = load i8*, i8** %16
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.24, i64 0, i64 0), i8* %89)
%91 = load i32, i32* %6
%92 = load i8*, i8** %16
%93 = load i8*, i8** %16
%94 = call i32 @strlen(i8* %93)
%95 = call i32 @write(i32 %91, i8* %92, i32 %94)
store i32 %95, i32* %8
%96 = load i32, i32* %8
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %80
%99 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %100
100: ; preds = %98, %80
%101 = load i32, i32* %6
%102 = load i8*, i8** %17
%103 = call i32 @read(i32 %101, i8* %102, i32 512)
store i32 %103, i32* %8
%104 = load i32, i32* %8
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %100
%107 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %108
108: ; preds = %106, %100
%109 = load i8*, i8** %17
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %109)
br label %111
111: ; preds = %108, %77, %68
%112 = load i8*, i8** %13
%113 = call i32 @free(i8* %112)
%114 = load i8*, i8** %16
%115 = call i32 @free(i8* %114)
br label %195
116: ; preds = %61
%117 = load i32, i32* %11
%118 = icmp eq i32 %117, 2
br i1 %118, label %119, label %194
119: ; preds = %116
%120 = call i8* @calloc(i32 124, i32 1)
store i8* %120, i8** %16
%121 = call i8* @calloc(i32 2, i32 1)
store i8* %121, i8** %14
%122 = call i8* @calloc(i32 2, i32 1)
store i8* %122, i8** %13
%123 = call i8* @calloc(i32 512, i32 1)
store i8* %123, i8** %17
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.28, i64 0, i64 0))
%125 = call i32 (...) @clean_stdin()
%126 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32* %12)
%127 = load i32, i32* %12
%128 = icmp sgt i32 %127, 0
br i1 %128, label %129, label %185
129: ; preds = %119
%130 = load i32, i32* %12
%131 = icmp slt i32 %130, 121
br i1 %131, label %132, label %185
132: ; preds = %129
%133 = load i8*, i8** %14
%134 = load i32, i32* %12
%135 = call i32 @sprintf(i8* %133, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32 %134)
%136 = load i8*, i8** %16
%137 = call i32 @strncpy(i8* %136, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.29, i64 0, i64 0), i32 37)
%138 = load i8*, i8** %16
%139 = load i8*, i8** %14
%140 = load i8*, i8** %14
%141 = call i32 @strlen(i8* %140)
%142 = call i32 @strncat(i8* %138, i8* %139, i32 %141)
%143 = load i8*, i8** %16
%144 = call i32 @strcat(i8* %143, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.30, i64 0, i64 0))
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.21, i64 0, i64 0))
%146 = call i32 (...) @clean_stdin()
%147 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32* %12)
%148 = load i32, i32* %12
%149 = icmp sgt i32 %148, 0
br i1 %149, label %150, label %184
150: ; preds = %132
%151 = load i32, i32* %12
%152 = icmp sle i32 %151, 8
br i1 %152, label %153, label %184
153: ; preds = %150
%154 = load i8*, i8** %13
%155 = load i32, i32* %12
%156 = call i32 @sprintf(i8* %154, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32 %155)
%157 = load i8*, i8** %16
%158 = call i32 @strncat(i8* %157, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.31, i64 0, i64 0), i32 105)
%159 = load i8*, i8** %16
%160 = load i8*, i8** %13
%161 = call i32 @strncat(i8* %159, i8* %160, i32 2)
%162 = load i8*, i8** %16
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.32, i64 0, i64 0), i8* %162)
%164 = load i32, i32* %6
%165 = load i8*, i8** %16
%166 = load i8*, i8** %16
%167 = call i32 @strlen(i8* %166)
%168 = call i32 @write(i32 %164, i8* %165, i32 %167)
store i32 %168, i32* %8
%169 = load i32, i32* %8
%170 = icmp slt i32 %169, 0
br i1 %170, label %171, label %173
171: ; preds = %153
%172 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %173
173: ; preds = %171, %153
%174 = load i32, i32* %6
%175 = load i8*, i8** %17
%176 = call i32 @read(i32 %174, i8* %175, i32 512)
store i32 %176, i32* %8
%177 = load i32, i32* %8
%178 = icmp slt i32 %177, 0
br i1 %178, label %179, label %181
179: ; preds = %173
%180 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %181
181: ; preds = %179, %173
%182 = load i8*, i8** %17
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %182)
br label %184
184: ; preds = %181, %150, %132
br label %185
185: ; preds = %184, %129, %119
%186 = load i8*, i8** %17
%187 = call i32 @free(i8* %186)
%188 = load i8*, i8** %13
%189 = call i32 @free(i8* %188)
%190 = load i8*, i8** %16
%191 = call i32 @free(i8* %190)
%192 = load i8*, i8** %14
%193 = call i32 @free(i8* %192)
br label %194
194: ; preds = %185, %116
br label %195
195: ; preds = %194, %111
br label %270
196: ; preds = %58
%197 = load i32, i32* %10
%198 = icmp eq i32 %197, 2
br i1 %198, label %199, label %228
199: ; preds = %196
%200 = call i8* @calloc(i32 22, i32 1)
store i8* %200, i8** %16
%201 = call i8* @calloc(i32 512, i32 1)
store i8* %201, i8** %17
%202 = load i8*, i8** %16
%203 = call i32 @snprintf(i8* %202, i32 22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.33, i64 0, i64 0))
%204 = load i32, i32* %6
%205 = load i8*, i8** %16
%206 = load i8*, i8** %16
%207 = call i32 @strlen(i8* %206)
%208 = call i32 @write(i32 %204, i8* %205, i32 %207)
store i32 %208, i32* %8
%209 = load i32, i32* %8
%210 = icmp slt i32 %209, 0
br i1 %210, label %211, label %213
211: ; preds = %199
%212 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %213
213: ; preds = %211, %199
%214 = load i32, i32* %6
%215 = load i8*, i8** %17
%216 = call i32 @read(i32 %214, i8* %215, i32 512)
store i32 %216, i32* %8
%217 = load i32, i32* %8
%218 = icmp slt i32 %217, 0
br i1 %218, label %219, label %221
219: ; preds = %213
%220 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %221
221: ; preds = %219, %213
%222 = load i8*, i8** %17
%223 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %222)
%224 = load i8*, i8** %17
%225 = call i32 @free(i8* %224)
%226 = load i8*, i8** %16
%227 = call i32 @free(i8* %226)
br label %269
228: ; preds = %196
%229 = load i32, i32* %10
%230 = icmp eq i32 %229, 3
br i1 %230, label %231, label %260
231: ; preds = %228
%232 = call i8* @calloc(i32 27, i32 1)
store i8* %232, i8** %16
%233 = call i8* @calloc(i32 512, i32 1)
store i8* %233, i8** %17
%234 = load i8*, i8** %16
%235 = call i32 @snprintf(i8* %234, i32 27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.34, i64 0, i64 0))
%236 = load i32, i32* %6
%237 = load i8*, i8** %16
%238 = load i8*, i8** %16
%239 = call i32 @strlen(i8* %238)
%240 = call i32 @write(i32 %236, i8* %237, i32 %239)
store i32 %240, i32* %8
%241 = load i32, i32* %8
%242 = icmp slt i32 %241, 0
br i1 %242, label %243, label %245
243: ; preds = %231
%244 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %245
245: ; preds = %243, %231
%246 = load i32, i32* %6
%247 = load i8*, i8** %17
%248 = call i32 @read(i32 %246, i8* %247, i32 512)
store i32 %248, i32* %8
%249 = load i32, i32* %8
%250 = icmp slt i32 %249, 0
br i1 %250, label %251, label %253
251: ; preds = %245
%252 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %253
253: ; preds = %251, %245
%254 = load i8*, i8** %17
%255 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %254)
%256 = load i8*, i8** %17
%257 = call i32 @free(i8* %256)
%258 = load i8*, i8** %16
%259 = call i32 @free(i8* %258)
br label %268
260: ; preds = %228
%261 = load i32, i32* %10
%262 = icmp eq i32 %261, 9
br i1 %262, label %263, label %267
263: ; preds = %260
%264 = load i32, i32* %6
%265 = call i32 @close(i32 %264)
%266 = call i32 @exit(i32 1)
unreachable
267: ; preds = %260
br label %268
268: ; preds = %267, %253
br label %269
269: ; preds = %268, %221
br label %270
270: ; preds = %269, %195
br label %271
271: ; preds = %270, %56
%272 = call i32 @sleep(i32 2)
br label %27
273: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
%struct.addrinfo = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [3 x i8] c"80\00"
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@.str.15 = [11 x i8] c"\0A\0AChoix : \00"
@.str.16 = [4 x i8] c" %d\00"
@.str.22 = [3 x i8] c"%d\00"
@.str.23 = [106 x i8] c"BREW /pot-1 HTCPCP/1.1\0D\0AContent-Type: message/coffeepot\0D\0AAccept-additions: no-additions\0D\0AContent-Length: \00"
@.str.24 = [12 x i8] c"Request:\0A%s\00"
@.str.25 = [22 x i8] c"Error writing socket\0A\00"
@.str.26 = [22 x i8] c"Error reading socket\0A\00"
@.str.27 = [15 x i8] c"\0AResponse: %s\0A\00"
@.str.29 = [38 x i8] c"WHEN /pot-1 HTCPCP/1.1\0D\0AWhen-I-Want: \00"
@.str.30 = [3 x i8] c"\0D\0A\00"
@.str.31 = [82 x i8] c"Content-Type: message/coffeepot\0D\0AAccept-additions: no-additions\0D\0AContent-Length: \00"
@.str.32 = [13 x i8] c"\0ARequest:\0A%s\00"
@.str.33 = [22 x i8] c"GET /pot-1 HTCPCP/1.1\00"
@.str.34 = [27 x i8] c"PROPFIND /pot-1 HTCPCP/1.1\00"
@str = [4 x i8] c"\0A##\00"
@str.35 = [32 x i8] c"## Welcome to the HTCPCP Client\00"
@str.36 = [73 x i8] c"## This project was created for the C programming lesson of ESGI school.\00"
@str.37 = [59 x i8] c"## The project is released under the GNU GPL v2.0 License.\00"
@str.38 = [25 x i8] c"## Author: Dylan Dubief.\00"
@str.39 = [25 x i8] c"## Last update: 23/02/15\00"
@str.40 = [77 x i8] c"############################################################################\00"
@str.41 = [3 x i8] c"\0A\0A\00"
@str.42 = [16 x i8] c"1) Brew request\00"
@str.43 = [15 x i8] c"2) Get request\00"
@str.44 = [20 x i8] c"3) Propfind request\00"
@str.45 = [18 x i8] c"9) Quitter le C&C\00"
@str.46 = [32 x i8] c"\0A\0ADo you want your coffee now ?\00"
@str.47 = [28 x i8] c"1) Yeah, i need coffeeeeeee\00"
@str.48 = [27 x i8] c"2) No, I'll tell you when.\00"
@str.49 = [41 x i8] c"\0AWhen do you want your coffee ? (Minute)\00"
@str.51 = [29 x i8] c"\0AHow many mugs do you want ?\00"
@str.52 = [20 x i8] c"\0AMauvaise commande.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 @tcp_connect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %2, %11
br label %14
14: ; preds = %13, %154
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.35, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.36, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.37, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.38, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.39, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.40, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.41, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.42, i64 0, i64 0))
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.43, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.44, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.45, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %14
switch i32 %29, label %32 [
i32 1, label %34
i32 2, label %115
i32 3, label %133
i32 9, label %151
i32 0, label %154
]
32: ; preds = %31, %14
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.52, i64 0, i64 0))
store i32 0, i32* %3
br label %154
34: ; preds = %31
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.46, i64 0, i64 0))
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.47, i64 0, i64 0))
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.48, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i32* %4)
%39 = load i32, i32* %4
switch i32 %39, label %154 [
i32 1, label %40
i32 2, label %70
]
40: ; preds = %34
%41 = call dereferenceable_or_null(124) i8* @calloc(i32 124, i32 1)
%42 = call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%43 = call dereferenceable_or_null(2) i8* @calloc(i32 2, i32 1)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.51, i64 0, i64 0))
%45 = call i32 (...) @clean_stdin()
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32* %5)
%47 = load i32, i32* %5
%48 = add i32 %47, -1
%49 = icmp ult i32 %48, 8
br i1 %49, label %50, label %67
50: ; preds = %40
%51 = call i32 @sprintf(i8* dereferenceable(1) %43, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32 %47)
%52 = call i32 @strncpy(i8* %41, i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.23, i64 0, i64 0), i32 105)
%53 = call i32 @strncat(i8* %41, i8* %43, i32 2)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.24, i64 0, i64 0), i8* %41)
%55 = call i32 @strlen(i8* %41)
%56 = call i32 @write(i32 %9, i8* %41, i32 %55)
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %50
%59 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %60
60: ; preds = %58, %50
%61 = call i32 @read(i32 %9, i8* %42, i32 512)
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %65
65: ; preds = %63, %60
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %42)
br label %67
67: ; preds = %65, %40
%68 = call i32 @free(i8* %43)
%69 = call i32 @free(i8* %41)
br label %154
70: ; preds = %34
%71 = call dereferenceable_or_null(124) i8* @calloc(i32 124, i32 1)
%72 = call dereferenceable_or_null(2) i8* @calloc(i32 2, i32 1)
%73 = call dereferenceable_or_null(2) i8* @calloc(i32 2, i32 1)
%74 = call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.49, i64 0, i64 0))
%76 = call i32 (...) @clean_stdin()
%77 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32* %5)
%78 = load i32, i32* %5
%79 = add i32 %78, -1
%80 = icmp ult i32 %79, 120
br i1 %80, label %81, label %110
81: ; preds = %70
%82 = call i32 @sprintf(i8* dereferenceable(1) %72, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32 %78)
%83 = call i32 @strncpy(i8* %71, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.29, i64 0, i64 0), i32 37)
%84 = call i32 @strlen(i8* %72)
%85 = call i32 @strncat(i8* %71, i8* %72, i32 %84)
%86 = call i32 @strcat(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.30, i64 0, i64 0))
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.51, i64 0, i64 0))
%88 = call i32 (...) @clean_stdin()
%89 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32* %5)
%90 = load i32, i32* %5
%91 = add i32 %90, -1
%92 = icmp ult i32 %91, 8
br i1 %92, label %93, label %110
93: ; preds = %81
%94 = call i32 @sprintf(i8* dereferenceable(1) %73, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i32 %90)
%95 = call i32 @strncat(i8* %71, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.31, i64 0, i64 0), i32 105)
%96 = call i32 @strncat(i8* %71, i8* %73, i32 2)
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.32, i64 0, i64 0), i8* %71)
%98 = call i32 @strlen(i8* %71)
%99 = call i32 @write(i32 %9, i8* %71, i32 %98)
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %93
%102 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %103
103: ; preds = %101, %93
%104 = call i32 @read(i32 %9, i8* %74, i32 512)
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %103
%107 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %108
108: ; preds = %106, %103
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %74)
br label %110
110: ; preds = %81, %108, %70
%111 = call i32 @free(i8* %74)
%112 = call i32 @free(i8* %73)
%113 = call i32 @free(i8* %71)
%114 = call i32 @free(i8* %72)
br label %154
115: ; preds = %31
%116 = call dereferenceable_or_null(22) i8* @calloc(i32 22, i32 1)
%117 = call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%118 = call i32 @snprintf(i8* %116, i32 22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.33, i64 0, i64 0))
%119 = call i32 @strlen(i8* %116)
%120 = call i32 @write(i32 %9, i8* %116, i32 %119)
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %115
%123 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %124
124: ; preds = %122, %115
%125 = call i32 @read(i32 %9, i8* %117, i32 512)
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %129
127: ; preds = %124
%128 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %129
129: ; preds = %127, %124
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %117)
%131 = call i32 @free(i8* %117)
%132 = call i32 @free(i8* %116)
br label %154
133: ; preds = %31
%134 = call dereferenceable_or_null(27) i8* @calloc(i32 27, i32 1)
%135 = call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%136 = call i32 @snprintf(i8* %134, i32 27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.34, i64 0, i64 0))
%137 = call i32 @strlen(i8* %134)
%138 = call i32 @write(i32 %9, i8* %134, i32 %137)
%139 = icmp slt i32 %138, 0
br i1 %139, label %140, label %142
140: ; preds = %133
%141 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.25, i64 0, i64 0))
br label %142
142: ; preds = %140, %133
%143 = call i32 @read(i32 %9, i8* %135, i32 512)
%144 = icmp slt i32 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %142
%146 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.26, i64 0, i64 0))
br label %147
147: ; preds = %145, %142
%148 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.27, i64 0, i64 0), i8* %135)
%149 = call i32 @free(i8* %135)
%150 = call i32 @free(i8* %134)
br label %154
151: ; preds = %31
%152 = call i32 @close(i32 %9)
%153 = call i32 @exit(i32 1)
unreachable
154: ; preds = %31, %34, %110, %67, %147, %129, %32
%155 = call i32 @sleep(i32 2)
%156 = load i32, i32* %3
%157 = icmp eq i32 %156, 9
br i1 %157, label %158, label %14
158: ; preds = %154
ret i32 0
}