#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ pthread_mutex_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_MUTEX_INITIALIZER;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
struct tm *gmtime(int /*<<< orphan*/ *);
int intlen(int);
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ pthread_mutex_unlock(int /*<<< orphan*/ *);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void *connection(void *arg) {
  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  int read_file_size;
  int read_file_size_length;
  time_t current_time;
  struct tm *current_gmtime;
  FILE *stats_file;
  int stats_string_length;
  char file_name[100];
  FILE *read_file;
  char receive_buffer[1024];
  char *send_buffer;
  int receive_buffer_size = 1024;
  int send_buffer_size;
  char time_buffer[30];
  char *page_buffer;
  char *stats_buffer;
  int stats_buffer_size;
  int receive_return;
  int send_return;
  int sent_so_far;
  int *connfd_value = (int *)arg;
  recv(*connfd_value, receive_buffer, receive_buffer_size, 0);
  if (receive_return < 0) {
    printf("Error encountered in receive.\n");
    exit(0);
  }
  time(&current_time);
  current_gmtime = gmtime(&current_time);
  strftime(time_buffer, 30, "%a, %d %b %Y %X %Z", current_gmtime);
  if (!(strncmp(receive_buffer, "GET ", 4) == 0)) {
    printf("Unknown command encountered.\n");
    send_buffer = (char *)malloc(32);
    strcpy(send_buffer, "Unknown command encountered.\n\n");
    send_buffer_size = strlen(send_buffer);
    strcpy(file_name, "N/A");
  } else {
    int i;
    int j = 0;
    for (i = 0; i < 100; i++) {
      if ((receive_buffer[j + 5] == ' ') || (receive_buffer[j + 5] == '\0') ||
          (receive_buffer[j + 5] == '\n')) {
        break;
      }
      if ((i == 0) && (receive_buffer[i + 4] == '/')) {
        j--;
      } else {
        file_name[j] = receive_buffer[i + 4];
      }
      if (i == 98) {
        printf(
            "Encountered a request for a file that had too long of a name.\n");
      }
      j++;
    }
    file_name[i] = '\0';
    read_file = fopen(file_name, "r");
    if (read_file != NULL) {
      fseek(read_file, 0, SEEK_END);
      read_file_size = ftell(read_file);
      fseek(read_file, 0, SEEK_SET);
      read_file_size_length = intlen(read_file_size);
      page_buffer = (char *)calloc(read_file_size + 1, sizeof(char));
      fread(page_buffer, 1, read_file_size, read_file);
      fclose(read_file);
      send_buffer =
          (char *)malloc(read_file_size + read_file_size_length + 120);
      strcpy(send_buffer, "HTTP/1.1 200 OK\nDate: ");
      strcat(send_buffer, time_buffer);
      sprintf(send_buffer,
              "%s\nContent-Length: %d\nConnection: close\nContent-Type: "
              "text/html\n\n",
              send_buffer, read_file_size);
      strcat(send_buffer, page_buffer);
      strcat(send_buffer, "\n");
      send_buffer_size = strlen(send_buffer);
      free(page_buffer);
    } else {
      send_buffer = (char *)malloc(64);
      strcpy(send_buffer, "HTTP/1.1 404 File Not Found\n\n");
      send_buffer_size = strlen(send_buffer);
    }
  }
  sent_so_far = 0;
  while (sent_so_far < send_buffer_size) {
    send_return = send(*connfd_value, send_buffer + sent_so_far,
                       send_buffer_size - sent_so_far, 0);
    if (send_return < 0) {
      printf("Encountered an error while sending the file.\n");
      exit(0);
    }
    sent_so_far += send_return;
  }
  close(*connfd_value);
  free(send_buffer);
  pthread_mutex_lock(&mutex);
  stats_buffer_size = strlen(file_name);
  stats_buffer_size += strlen(time_buffer);
  stats_buffer_size += 32;
  stats_buffer = malloc(stats_buffer_size);
  sprintf(stats_buffer, "%s - File Requested: %s\n", time_buffer, file_name);
  stats_string_length = strlen(stats_buffer);
  stats_file = fopen("stats.txt", "a");
  if (stats_file != NULL) {
    fwrite(stats_buffer, stats_string_length, 1, stats_file);
    fclose(stats_file);
  } else {
    printf("Encountered an error opening/creating stats file for appending.\n");
  }
  free(stats_buffer);
  pthread_mutex_unlock(&mutex);
  return NULL;
}


x86 assembly (clang, -O0):
<connection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x500,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2d32(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
movl   $0x400,-0x4ac(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x4f8(%rbp)
mov    -0x4f8(%rbp),%rax
mov    (%rax),%edi
lea    -0x4a0(%rbp),%rsi
mov    -0x4ac(%rbp),%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmpl   $0x0,-0x4e8(%rbp)
jge    12fd <connection+0x6d>
lea    0xd0f(%rip),%rdi
call   10c0 <printf@plt>
xor    %edi,%edi
call   1190 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1100 <time@plt>
lea    -0x18(%rbp),%rdi
call   1160 <gmtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x4d0(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1e,%esi
lea    0xcf5(%rip),%rdx
call   1140 <strftime@plt>
lea    -0x4a0(%rbp),%rdi
lea    0xcf5(%rip),%rsi
mov    $0x4,%edx
call   1060 <strncmp@plt>
cmp    $0x0,%rax
je     13ab <connection+0x11b>
lea    0xcdf(%rip),%rdi
call   10c0 <printf@plt>
mov    $0x20,%edi
call   1120 <malloc@plt>
mov    %rax,-0x4a8(%rbp)
mov    -0x4a8(%rbp),%rdi
lea    0xcd9(%rip),%rsi
call   1070 <strcpy@plt>
mov    -0x4a8(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x4b0(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xcd3(%rip),%rsi
call   1070 <strcpy@plt>
jmp    1659 <connection+0x3c9>
movl   $0x0,-0x500(%rbp)
movl   $0x0,-0x4fc(%rbp)
cmpl   $0x64,-0x4fc(%rbp)
jge    14be <connection+0x22e>
mov    -0x500(%rbp),%eax
add    $0x5,%eax
cltq
movsbl -0x4a0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     1420 <connection+0x190>
mov    -0x500(%rbp),%eax
add    $0x5,%eax
cltq
movsbl -0x4a0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1420 <connection+0x190>
mov    -0x500(%rbp),%eax
add    $0x5,%eax
cltq
movsbl -0x4a0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1425 <connection+0x195>
jmp    14be <connection+0x22e>
cmpl   $0x0,-0x4fc(%rbp)
jne    1462 <connection+0x1d2>
mov    -0x4fc(%rbp),%eax
add    $0x4,%eax
cltq
movsbl -0x4a0(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    1462 <connection+0x1d2>
mov    -0x500(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x500(%rbp)
jmp    1482 <connection+0x1f2>
mov    -0x4fc(%rbp),%eax
add    $0x4,%eax
cltq
mov    -0x4a0(%rbp,%rax,1),%cl
movslq -0x500(%rbp),%rax
mov    %cl,-0x90(%rbp,%rax,1)
cmpl   $0x62,-0x4fc(%rbp)
jne    149b <connection+0x20b>
lea    0xbe2(%rip),%rdi
call   10c0 <printf@plt>
mov    -0x500(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x500(%rbp)
mov    -0x4fc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4fc(%rbp)
jmp    13bf <connection+0x12f>
movslq -0x4fc(%rbp),%rax
movb   $0x0,-0x90(%rbp,%rax,1)
lea    -0x90(%rbp),%rdi
lea    0xbdc(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     161e <connection+0x38e>
mov    -0x98(%rbp),%rdi
mov    0x2ae5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1130 <fseek@plt>
mov    -0x98(%rbp),%rdi
call   10f0 <ftell@plt>
mov    %eax,-0x10(%rbp)
mov    -0x98(%rbp),%rdi
mov    0x2aa7(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1130 <fseek@plt>
mov    -0x10(%rbp),%edi
call   1050 <intlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,-0x4d8(%rbp)
mov    -0x4d8(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x98(%rbp),%rcx
mov    $0x1,%esi
call   1080 <fread@plt>
mov    -0x98(%rbp),%rdi
call   1090 <fclose@plt>
mov    -0x10(%rbp),%edi
add    -0x14(%rbp),%edi
add    $0x78,%edi
call   1120 <malloc@plt>
mov    %rax,-0x4a8(%rbp)
mov    -0x4a8(%rbp),%rdi
lea    0xb1b(%rip),%rsi
call   1070 <strcpy@plt>
mov    -0x4a8(%rbp),%rdi
lea    -0x4d0(%rbp),%rsi
call   1170 <strcat@plt>
mov    -0x4a8(%rbp),%rdi
mov    -0x4a8(%rbp),%rdx
mov    -0x10(%rbp),%ecx
lea    0xb02(%rip),%rsi
mov    $0x0,%al
call   1180 <sprintf@plt>
mov    -0x4a8(%rbp),%rdi
mov    -0x4d8(%rbp),%rsi
call   1170 <strcat@plt>
mov    -0x4a8(%rbp),%rdi
lea    0xa7c(%rip),%rsi
call   1170 <strcat@plt>
mov    -0x4a8(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x4b0(%rbp)
mov    -0x4d8(%rbp),%rdi
call   1030 <free@plt>
jmp    1654 <connection+0x3c4>
mov    $0x40,%edi
call   1120 <malloc@plt>
mov    %rax,-0x4a8(%rbp)
mov    -0x4a8(%rbp),%rdi
lea    0xad5(%rip),%rsi
call   1070 <strcpy@plt>
mov    -0x4a8(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x4b0(%rbp)
jmp    1659 <connection+0x3c9>
movl   $0x0,-0x4f0(%rbp)
mov    -0x4f0(%rbp),%eax
cmp    -0x4b0(%rbp),%eax
jge    16df <connection+0x44f>
mov    -0x4f8(%rbp),%rax
mov    (%rax),%edi
mov    -0x4a8(%rbp),%rsi
movslq -0x4f0(%rbp),%rax
add    %rax,%rsi
mov    -0x4b0(%rbp),%edx
sub    -0x4f0(%rbp),%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    %eax,-0x4ec(%rbp)
cmpl   $0x0,-0x4ec(%rbp)
jge    16c8 <connection+0x438>
lea    0xa74(%rip),%rdi
call   10c0 <printf@plt>
xor    %edi,%edi
call   1190 <exit@plt>
mov    -0x4ec(%rbp),%eax
add    -0x4f0(%rbp),%eax
mov    %eax,-0x4f0(%rbp)
jmp    1663 <connection+0x3d3>
mov    -0x4f8(%rbp),%rax
mov    (%rax),%edi
call   10d0 <close@plt>
mov    -0x4a8(%rbp),%rdi
call   1030 <free@plt>
lea    -0xc(%rbp),%rdi
call   11b0 <pthread_mutex_lock@plt>
lea    -0x90(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x4e4(%rbp)
lea    -0x4d0(%rbp),%rdi
call   10a0 <strlen@plt>
add    -0x4e4(%rbp),%eax
mov    %eax,-0x4e4(%rbp)
mov    -0x4e4(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x4e4(%rbp)
mov    -0x4e4(%rbp),%edi
call   1120 <malloc@plt>
mov    %rax,-0x4e0(%rbp)
mov    -0x4e0(%rbp),%rdi
lea    -0x4d0(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    0x9f5(%rip),%rsi
mov    $0x0,%al
call   1180 <sprintf@plt>
mov    -0x4e0(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    0x9f1(%rip),%rdi
lea    0x9f4(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     17c7 <connection+0x537>
mov    -0x4e0(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
call   11a0 <fwrite@plt>
mov    -0x28(%rbp),%rdi
call   1090 <fclose@plt>
jmp    17d3 <connection+0x543>
lea    0x9b5(%rip),%rdi
call   10c0 <printf@plt>
mov    -0x4e0(%rbp),%rdi
call   1030 <free@plt>
lea    -0xc(%rbp),%rdi
call   1110 <pthread_mutex_unlock@plt>
xor    %eax,%eax
add    $0x500,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connection>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4a8,%rsp
mov    %rdi,%r14
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    (%rdi),%edi
lea    0xa0(%rsp),%r15
xor    %ebx,%ebx
mov    %r15,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    0xc(%rsp),%rbp
mov    %rbp,%rdi
call   1100 <time@plt>
mov    %rbp,%rdi
call   1160 <gmtime@plt>
lea    0xd18(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x1e,%esi
mov    %rax,%rcx
call   1140 <strftime@plt>
lea    0xd12(%rip),%rsi
mov    %r15,%rdi
mov    $0x4,%edx
call   1060 <strncmp@plt>
test   %rax,%rax
je     1363 <connection+0xd3>
lea    0xdbf(%rip),%rdi
call   1080 <puts@plt>
mov    $0x20,%edi
call   1120 <malloc@plt>
mov    %rax,%r13
lea    0xce5(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcpy@plt>
mov    %r13,%rdi
call   10b0 <strlen@plt>
mov    %eax,%ebp
lea    0xceb(%rip),%rsi
lea    0x30(%rsp),%rdi
call   1070 <strcpy@plt>
test   %ebp,%ebp
jg     14ff <connection+0x26f>
jmp    1533 <connection+0x2a3>
lea    0xdf9(%rip),%r12
movabs $0x100000401,%r13
xor    %ebp,%ebp
jmp    1390 <connection+0x100>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
add    $0x1,%ebx
add    $0x1,%rbp
cmp    $0x64,%rbp
je     13d0 <connection+0x140>
movslq %ebx,%rax
movzbl 0x5(%rax,%r15,1),%ecx
cmp    $0x20,%rcx
ja     13a5 <connection+0x115>
bt     %rcx,%r13
jb     13d5 <connection+0x145>
test   %rbp,%rbp
jne    13b4 <connection+0x124>
cmpb   $0x2f,0xa4(%rsp)
2f
je     1380 <connection+0xf0>
movzbl 0xa4(%rsp,%rbp,1),%ecx
mov    %cl,0x30(%rsp,%rax,1)
cmp    $0x62,%rbp
jne    1383 <connection+0xf3>
mov    %r12,%rdi
call   1080 <puts@plt>
jmp    1383 <connection+0xf3>
mov    $0x64,%ebp
mov    %ebp,%eax
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xc58(%rip),%rsi
lea    0x30(%rsp),%rdi
call   1150 <fopen@plt>
test   %rax,%rax
je     14d5 <connection+0x245>
mov    %rax,%rbx
mov    0x2be8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1130 <fseek@plt>
mov    %rbx,%rdi
call   10f0 <ftell@plt>
mov    %eax,%r12d
mov    0x2bb2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1130 <fseek@plt>
mov    %r12d,%edi
call   1050 <intlen@plt>
mov    %eax,%ebp
lea    0x1(%r12),%edi
mov    $0x1,%esi
call   10e0 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rbx,%rcx
call   1090 <fread@plt>
mov    %rbx,%rdi
call   10a0 <fclose@plt>
lea    (%r12,%rbp,1),%edi
add    $0x78,%edi
call   1120 <malloc@plt>
mov    %rax,%r13
lea    0xbc6(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcpy@plt>
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   1170 <strcat@plt>
lea    0xbc1(%rip),%rsi
mov    %r13,%rdi
mov    %r13,%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1180 <sprintf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1170 <strcat@plt>
lea    0xb80(%rip),%rsi
mov    %r13,%rdi
call   1170 <strcat@plt>
mov    %r13,%rdi
call   10b0 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
jg     14ff <connection+0x26f>
jmp    1533 <connection+0x2a3>
mov    $0x40,%edi
call   1120 <malloc@plt>
mov    %rax,%r13
lea    0xbad(%rip),%rsi
mov    %rax,%rdi
call   1070 <strcpy@plt>
mov    %r13,%rdi
call   10b0 <strlen@plt>
mov    %eax,%ebp
test   %ebp,%ebp
jle    1533 <connection+0x2a3>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
movslq %ebx,%rax
lea    (%rax,%r13,1),%rsi
mov    %ebp,%edx
sub    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send@plt>
test   %eax,%eax
js     1603 <connection+0x373>
add    %eax,%ebx
cmp    %ebx,%ebp
jg     1510 <connection+0x280>
mov    (%r14),%edi
call   10d0 <close@plt>
mov    %r13,%rdi
call   1030 <free@plt>
lea    0x8(%rsp),%rdi
call   11b0 <pthread_mutex_lock@plt>
lea    0x30(%rsp),%r14
mov    %r14,%rdi
call   10b0 <strlen@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   10b0 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x20,%edi
call   1120 <malloc@plt>
mov    %rax,%rbx
lea    0xb36(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1180 <sprintf@plt>
mov    %rbx,%rdi
call   10b0 <strlen@plt>
mov    %eax,%r14d
lea    0xb2d(%rip),%rdi
lea    0xb30(%rip),%rsi
call   1150 <fopen@plt>
test   %rax,%rax
je     15d1 <connection+0x341>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   11a0 <fwrite@plt>
mov    %rbp,%rdi
call   10a0 <fclose@plt>
jmp    15dd <connection+0x34d>
lea    0xb1e(%rip),%rdi
call   1080 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0x8(%rsp),%rdi
call   1110 <pthread_mutex_unlock@plt>
xor    %eax,%eax
add    $0x4a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb2c(%rip),%rdi
call   1080 <puts@plt>
xor    %edi,%edi
call   1190 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@PTHREAD_MUTEX_INITIALIZER = global i32 0
@.str = [31 x i8] c"Error encountered in receive.\0A\00"
@.str.1 = [19 x i8] c"%a, %d %b %Y %X %Z\00"
@.str.2 = [5 x i8] c"GET \00"
@.str.3 = [30 x i8] c"Unknown command encountered.\0A\00"
@.str.4 = [31 x i8] c"Unknown command encountered.\0A\0A\00"
@.str.5 = [4 x i8] c"N/A\00"
@.str.6 = [63 x i8] c"Encountered a request for a file that had too long of a name.\0A\00"
@.str.7 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [23 x i8] c"HTTP/1.1 200 OK\0ADate: \00"
@.str.9 = [66 x i8] c"%s\0AContent-Length: %d\0AConnection: close\0AContent-Type: text/html\0A\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [30 x i8] c"HTTP/1.1 404 File Not Found\0A\0A\00"
@.str.12 = [46 x i8] c"Encountered an error while sending the file.\0A\00"
@.str.13 = [25 x i8] c"%s - File Requested: %s\0A\00"
@.str.14 = [10 x i8] c"stats.txt\00"
@.str.15 = [2 x i8] c"a\00"
@.str.16 = [65 x i8] c"Encountered an error opening/creating stats file for appending.\0A\00"
define i8* @connection(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.tm*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [100 x i8]
%11 = alloca i32*
%12 = alloca [1024 x i8]
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca [30 x i8]
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32*
%24 = alloca i32
%25 = alloca i32
store i8* %0, i8** %2
%26 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %26, i32* %3
store i32 1024, i32* %14
%27 = load i8*, i8** %2
%28 = bitcast i8* %27 to i32*
store i32* %28, i32** %23
%29 = load i32*, i32** %23
%30 = load i32, i32* %29
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%32 = load i32, i32* %14
%33 = call i32 @recv(i32 %30, i8* %31, i32 %32, i32 0)
%34 = load i32, i32* %20
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %1
%37 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @exit(i32 0)
unreachable
39: ; preds = %1
%40 = call i32 @time(i32* %6)
%41 = call %struct.tm* @gmtime(i32* %6)
store %struct.tm* %41, %struct.tm** %7
%42 = getelementptr inbounds [30 x i8], [30 x i8]* %16, i64 0, i64 0
%43 = load %struct.tm*, %struct.tm** %7
%44 = call i32 @strftime(i8* %42, i32 30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %43)
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%46 = call i64 @strncmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%47 = icmp eq i64 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %39
%49 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%50 = call i8* @malloc(i32 32)
store i8* %50, i8** %13
%51 = load i8*, i8** %13
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%53 = load i8*, i8** %13
%54 = call i32 @strlen(i8* %53)
store i32 %54, i32* %15
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%56 = call i32 @strcpy(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %179
57: ; preds = %39
store i32 0, i32* %25
store i32 0, i32* %24
br label %58
58: ; preds = %117, %57
%59 = load i32, i32* %24
%60 = icmp slt i32 %59, 100
br i1 %60, label %61, label %120
61: ; preds = %58
%62 = load i32, i32* %25
%63 = add nsw i32 %62, 5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 32
br i1 %68, label %85, label %69
69: ; preds = %61
%70 = load i32, i32* %25
%71 = add nsw i32 %70, 5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 0
br i1 %76, label %85, label %77
77: ; preds = %69
%78 = load i32, i32* %25
%79 = add nsw i32 %78, 5
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %80
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 10
br i1 %84, label %85, label %86
85: ; preds = %77, %69, %61
br label %120
86: ; preds = %77
%87 = load i32, i32* %24
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %100
89: ; preds = %86
%90 = load i32, i32* %24
%91 = add nsw i32 %90, 4
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 47
br i1 %96, label %97, label %100
97: ; preds = %89
%98 = load i32, i32* %25
%99 = add nsw i32 %98, -1
store i32 %99, i32* %25
br label %109
100: ; preds = %89, %86
%101 = load i32, i32* %24
%102 = add nsw i32 %101, 4
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %103
%105 = load i8, i8* %104
%106 = load i32, i32* %25
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 %107
store i8 %105, i8* %108
br label %109
109: ; preds = %100, %97
%110 = load i32, i32* %24
%111 = icmp eq i32 %110, 98
br i1 %111, label %112, label %114
112: ; preds = %109
%113 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0))
br label %114
114: ; preds = %112, %109
%115 = load i32, i32* %25
%116 = add nsw i32 %115, 1
store i32 %116, i32* %25
br label %117
117: ; preds = %114
%118 = load i32, i32* %24
%119 = add nsw i32 %118, 1
store i32 %119, i32* %24
br label %58
120: ; preds = %85, %58
%121 = load i32, i32* %24
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 %122
store i8 0, i8* %123
%124 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%125 = call i32* @fopen(i8* %124, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %125, i32** %11
%126 = load i32*, i32** %11
%127 = icmp ne i32* %126, null
br i1 %127, label %128, label %172
128: ; preds = %120
%129 = load i32*, i32** %11
%130 = load i32, i32* @SEEK_END
%131 = call i32 @fseek(i32* %129, i32 0, i32 %130)
%132 = load i32*, i32** %11
%133 = call i32 @ftell(i32* %132)
store i32 %133, i32* %4
%134 = load i32*, i32** %11
%135 = load i32, i32* @SEEK_SET
%136 = call i32 @fseek(i32* %134, i32 0, i32 %135)
%137 = load i32, i32* %4
%138 = call i32 @intlen(i32 %137)
store i32 %138, i32* %5
%139 = load i32, i32* %4
%140 = add nsw i32 %139, 1
%141 = call i64 @calloc(i32 %140, i32 1)
%142 = inttoptr i64 %141 to i8*
store i8* %142, i8** %17
%143 = load i8*, i8** %17
%144 = load i32, i32* %4
%145 = load i32*, i32** %11
%146 = call i32 @fread(i8* %143, i32 1, i32 %144, i32* %145)
%147 = load i32*, i32** %11
%148 = call i32 @fclose(i32* %147)
%149 = load i32, i32* %4
%150 = load i32, i32* %5
%151 = add nsw i32 %149, %150
%152 = add nsw i32 %151, 120
%153 = call i8* @malloc(i32 %152)
store i8* %153, i8** %13
%154 = load i8*, i8** %13
%155 = call i32 @strcpy(i8* %154, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%156 = load i8*, i8** %13
%157 = getelementptr inbounds [30 x i8], [30 x i8]* %16, i64 0, i64 0
%158 = call i32 @strcat(i8* %156, i8* %157)
%159 = load i8*, i8** %13
%160 = load i8*, i8** %13
%161 = load i32, i32* %4
%162 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %159, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.9, i64 0, i64 0), i8* %160, i32 %161)
%163 = load i8*, i8** %13
%164 = load i8*, i8** %17
%165 = call i32 @strcat(i8* %163, i8* %164)
%166 = load i8*, i8** %13
%167 = call i32 @strcat(i8* %166, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%168 = load i8*, i8** %13
%169 = call i32 @strlen(i8* %168)
store i32 %169, i32* %15
%170 = load i8*, i8** %17
%171 = call i32 @free(i8* %170)
br label %178
172: ; preds = %120
%173 = call i8* @malloc(i32 64)
store i8* %173, i8** %13
%174 = load i8*, i8** %13
%175 = call i32 @strcpy(i8* %174, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%176 = load i8*, i8** %13
%177 = call i32 @strlen(i8* %176)
store i32 %177, i32* %15
br label %178
178: ; preds = %172, %128
br label %179
179: ; preds = %178, %48
store i32 0, i32* %22
br label %180
180: ; preds = %200, %179
%181 = load i32, i32* %22
%182 = load i32, i32* %15
%183 = icmp slt i32 %181, %182
br i1 %183, label %184, label %204
184: ; preds = %180
%185 = load i32*, i32** %23
%186 = load i32, i32* %185
%187 = load i8*, i8** %13
%188 = load i32, i32* %22
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds i8, i8* %187, i64 %189
%191 = load i32, i32* %15
%192 = load i32, i32* %22
%193 = sub nsw i32 %191, %192
%194 = call i32 @send(i32 %186, i8* %190, i32 %193, i32 0)
store i32 %194, i32* %21
%195 = load i32, i32* %21
%196 = icmp slt i32 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %184
%198 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0))
%199 = call i32 @exit(i32 0)
unreachable
200: ; preds = %184
%201 = load i32, i32* %21
%202 = load i32, i32* %22
%203 = add nsw i32 %202, %201
store i32 %203, i32* %22
br label %180
204: ; preds = %180
%205 = load i32*, i32** %23
%206 = load i32, i32* %205
%207 = call i32 @close(i32 %206)
%208 = load i8*, i8** %13
%209 = call i32 @free(i8* %208)
%210 = call i32 @pthread_mutex_lock(i32* %3)
%211 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%212 = call i32 @strlen(i8* %211)
store i32 %212, i32* %19
%213 = getelementptr inbounds [30 x i8], [30 x i8]* %16, i64 0, i64 0
%214 = call i32 @strlen(i8* %213)
%215 = load i32, i32* %19
%216 = add nsw i32 %215, %214
store i32 %216, i32* %19
%217 = load i32, i32* %19
%218 = add nsw i32 %217, 32
store i32 %218, i32* %19
%219 = load i32, i32* %19
%220 = call i8* @malloc(i32 %219)
store i8* %220, i8** %18
%221 = load i8*, i8** %18
%222 = getelementptr inbounds [30 x i8], [30 x i8]* %16, i64 0, i64 0
%223 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%224 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %221, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i8* %222, i8* %223)
%225 = load i8*, i8** %18
%226 = call i32 @strlen(i8* %225)
store i32 %226, i32* %9
%227 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32* %227, i32** %8
%228 = load i32*, i32** %8
%229 = icmp ne i32* %228, null
br i1 %229, label %230, label %237
230: ; preds = %204
%231 = load i8*, i8** %18
%232 = load i32, i32* %9
%233 = load i32*, i32** %8
%234 = call i32 @fwrite(i8* %231, i32 %232, i32 1, i32* %233)
%235 = load i32*, i32** %8
%236 = call i32 @fclose(i32* %235)
br label %239
237: ; preds = %204
%238 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.16, i64 0, i64 0))
br label %239
239: ; preds = %237, %230
%240 = load i8*, i8** %18
%241 = call i32 @free(i8* %240)
%242 = call i32 @pthread_mutex_unlock(i32* %3)
ret i8* null
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@PTHREAD_MUTEX_INITIALIZER = global i32 0
@.str.1 = [19 x i8] c"%a, %d %b %Y %X %Z\00"
@.str.2 = [5 x i8] c"GET \00"
@.str.4 = [31 x i8] c"Unknown command encountered.\0A\0A\00"
@.str.5 = [4 x i8] c"N/A\00"
@.str.7 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [23 x i8] c"HTTP/1.1 200 OK\0ADate: \00"
@.str.9 = [66 x i8] c"%s\0AContent-Length: %d\0AConnection: close\0AContent-Type: text/html\0A\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [30 x i8] c"HTTP/1.1 404 File Not Found\0A\0A\00"
@.str.13 = [25 x i8] c"%s - File Requested: %s\0A\00"
@.str.14 = [10 x i8] c"stats.txt\00"
@.str.15 = [2 x i8] c"a\00"
@str = [29 x i8] c"Unknown command encountered.\00"
@str.17 = [64 x i8] c"Encountered an error opening/creating stats file for appending.\00"
@str.18 = [45 x i8] c"Encountered an error while sending the file.\00"
@str.19 = [62 x i8] c"Encountered a request for a file that had too long of a name.\00"
define noalias i8* @connection(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [30 x i8]
%7 = bitcast i32* %2 to i8*
%8 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %8, i32* %2
%9 = bitcast i32* %3 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [30 x i8], [30 x i8]* %6, i64 0, i64 0
%13 = bitcast i8* %0 to i32*
%14 = load i32, i32* %13
%15 = call i32 @recv(i32 %14, i8* %11, i32 1024, i32 0)
%16 = call i32 @time(i32* %3)
%17 = call %struct.tm* @gmtime(i32* %3)
%18 = call i32 @strftime(i8* %12, i32 30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %17)
%19 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %1
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 4
br label %29
23: ; preds = %1
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%25 = call dereferenceable_or_null(32) i8* @malloc(i32 32)
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @strlen(i8* %25)
%28 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %89
29: ; preds = %21, %52
%30 = phi i64 [ 0, %21 ], [ %55, %52 ]
%31 = phi i32 [ 0, %21 ], [ %54, %52 ]
%32 = add nsw i32 %31, 5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %33
%35 = load i8, i8* %34
switch i8 %35, label %36 [
i8 32, label %57
i8 0, label %57
i8 10, label %57
]
36: ; preds = %29
%37 = icmp eq i64 %30, 0
%38 = load i8, i8* %22
%39 = icmp eq i8 %38, 47
%40 = select i1 %37, i1 %39, i1 false
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = add nsw i32 %31, -1
br label %52
43: ; preds = %36
%44 = add nuw nsw i64 %30, 4
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i32 %31 to i64
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %47
store i8 %46, i8* %48
%49 = icmp eq i64 %30, 98
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str.19, i64 0, i64 0))
br label %52
52: ; preds = %41, %50, %43
%53 = phi i32 [ %42, %41 ], [ %31, %50 ], [ %31, %43 ]
%54 = add nsw i32 %53, 1
%55 = add nuw nsw i64 %30, 1
%56 = icmp eq i64 %55, 100
br i1 %56, label %57, label %29
57: ; preds = %29, %29, %29, %52
%58 = phi i64 [ %30, %29 ], [ %30, %29 ], [ %30, %29 ], [ 100, %52 ]
%59 = and i64 %58, 4294967295
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %59
store i8 0, i8* %60
%61 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%62 = icmp eq i32* %61, null
br i1 %62, label %85, label %63
63: ; preds = %57
%64 = load i32, i32* @SEEK_END
%65 = call i32 @fseek(i32* %61, i32 0, i32 %64)
%66 = call i32 @ftell(i32* %61)
%67 = load i32, i32* @SEEK_SET
%68 = call i32 @fseek(i32* %61, i32 0, i32 %67)
%69 = call i32 @intlen(i32 %66)
%70 = add nsw i32 %66, 1
%71 = call i64 @calloc(i32 %70, i32 1)
%72 = inttoptr i64 %71 to i8*
%73 = call i32 @fread(i8* %72, i32 1, i32 %66, i32* %61)
%74 = call i32 @fclose(i32* %61)
%75 = add i32 %66, 120
%76 = add i32 %75, %69
%77 = call i8* @malloc(i32 %76)
%78 = call i32 @strcpy(i8* %77, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%79 = call i32 @strcat(i8* %77, i8* %12)
%80 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %77, i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.9, i64 0, i64 0), i8* %77, i32 %66)
%81 = call i32 @strcat(i8* %77, i8* %72)
%82 = call i32 @strcat(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%83 = call i32 @strlen(i8* %77)
%84 = call i32 @free(i8* %72)
br label %89
85: ; preds = %57
%86 = call dereferenceable_or_null(64) i8* @malloc(i32 64)
%87 = call i32 @strcpy(i8* %86, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
%88 = call i32 @strlen(i8* %86)
br label %89
89: ; preds = %63, %85, %23
%90 = phi i32 [ %27, %23 ], [ %83, %63 ], [ %88, %85 ]
%91 = phi i8* [ %25, %23 ], [ %77, %63 ], [ %86, %85 ]
%92 = icmp sgt i32 %90, 0
br i1 %92, label %95, label %107
93: ; preds = %95
%94 = icmp sgt i32 %90, %103
br i1 %94, label %95, label %107
95: ; preds = %89, %93
%96 = phi i32 [ %103, %93 ], [ 0, %89 ]
%97 = load i32, i32* %13
%98 = sext i32 %96 to i64
%99 = getelementptr inbounds i8, i8* %91, i64 %98
%100 = sub nsw i32 %90, %96
%101 = call i32 @send(i32 %97, i8* %99, i32 %100, i32 0)
%102 = icmp slt i32 %101, 0
%103 = add nsw i32 %101, %96
br i1 %102, label %104, label %93
104: ; preds = %95
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.18, i64 0, i64 0))
%106 = call i32 @exit(i32 0)
unreachable
107: ; preds = %93, %89
%108 = load i32, i32* %13
%109 = call i32 @close(i32 %108)
%110 = call i32 @free(i8* %91)
%111 = call i32 @pthread_mutex_lock(i32* %2)
%112 = call i32 @strlen(i8* %10)
%113 = call i32 @strlen(i8* %12)
%114 = add i32 %112, 32
%115 = add i32 %114, %113
%116 = call i8* @malloc(i32 %115)
%117 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %116, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i8* %12, i8* %10)
%118 = call i32 @strlen(i8* %116)
%119 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%120 = icmp eq i32* %119, null
br i1 %120, label %124, label %121
121: ; preds = %107
%122 = call i32 @fwrite(i8* %116, i32 %118, i32 1, i32* %119)
%123 = call i32 @fclose(i32* %119)
br label %126
124: ; preds = %107
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.17, i64 0, i64 0))
br label %126
126: ; preds = %124, %121
%127 = call i32 @free(i8* %116)
%128 = call i32 @pthread_mutex_unlock(i32* %2)
ret i8* null
}