#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*/ FILE;

/* Variables and functions */
char EOF;
char *calloc(int /*<<< orphan*/, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
char *getFilename(char *, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, size_t);
char *strstr(char *, char *);
void mergeFiles(char *mergeTask) {
  printf("task: [%s]\n", mergeTask);
  printf("size: %lu\n", strlen(mergeTask));
  int offset = 0;
  char *temp;
  offset = 0;
  temp = (char *)malloc(sizeof(char));
  temp = strstr(mergeTask, " ");
  if (temp != NULL) {
    offset = temp - mergeTask;
  }
  char *input1 = (char *)calloc(0, sizeof(char));
  strncpy(input1, mergeTask, offset);
  input1[strlen(input1)] = '\0';
  printf("input1 --> [%s]\n", input1);
  temp = (char *)malloc(sizeof(char));
  strncpy(temp, mergeTask + offset + 1, strlen(mergeTask));
  temp[strlen(temp)] = '\0';
  mergeTask = temp;
  offset = 0;
  temp = (char *)malloc(sizeof(char));
  temp = strstr(mergeTask, " ");
  if (temp != NULL) {
    offset = temp - mergeTask;
  }
  char *input2 = (char *)calloc(0, sizeof(char));
  strncpy(input2, mergeTask, offset);
  input2[strlen(input2)] = '\0';
  printf("input2 --> [%s]\n", input2);
  temp = (char *)malloc(sizeof(char));
  strncpy(temp, mergeTask + offset + 1, strlen(mergeTask));
  temp[strlen(temp)] = '\0';
  mergeTask = temp;
  offset = 0;
  temp = (char *)malloc(sizeof(char));
  temp = strstr(mergeTask, " ");
  if (temp != NULL) {
    offset = temp - mergeTask;
  }
  char *output = (char *)calloc(0, sizeof(char));
  strncpy(output, mergeTask, offset);
  output[strlen(output)] = '\0';
  printf("output --> [%s]\n", output);
  temp = (char *)malloc(sizeof(char));
  strncpy(temp, mergeTask + offset + 1, strlen(mergeTask));
  temp[strlen(temp)] = '\0';
  mergeTask = temp;
  char *fNameIn1;
  char *fNameIn2;
  char *fNameOut;
  bool isMerged;
  isMerged = false;
  offset = 0;
  temp = (char *)malloc(sizeof(char));
  temp = strstr(input1, "C");
  if (temp != NULL) {
    isMerged = true;
    offset = temp - input1;
  }
  temp = (char *)malloc(sizeof(char));
  strncpy(temp, input1 + 1, strlen(input1));
  temp[strlen(input1)] = '\0';
  input1 = temp;
  if (isMerged) {
    fNameIn1 = getFilename("reduced_", input1);
  } else {
    fNameIn1 = getFilename("sorted_output_split_", input1);
  }
  isMerged = false;
  offset = 0;
  temp = (char *)malloc(sizeof(char));
  temp = strstr(input2, "C");
  if (temp != NULL) {
    isMerged = true;
    offset = temp - input2;
  }
  temp = (char *)malloc(sizeof(char));
  strncpy(temp, input2 + 1, strlen(input2));
  temp[strlen(input2)] = '\0';
  input2 = temp;
  if (isMerged) {
    fNameIn2 = getFilename("reduced_", input2);
  } else {
    fNameIn2 = getFilename("sorted_output_split_", input2);
  }
  temp = (char *)malloc(sizeof(char));
  strncpy(temp, output + 1, strlen(output));
  temp[strlen(output)] = '\0';
  output = temp;
  fNameOut = getFilename("reduced_", output);
  FILE *fpOut = fopen(fNameOut, "w+");
  FILE *fpIn1 = fopen(fNameIn1, "r");
  FILE *fpIn2 = fopen(fNameIn2, "r");
  char tmp;
  char *string = malloc(sizeof(char));
  int charCount = 0;
  int wordCount = 0;
  while ((tmp = fgetc(fpIn1)) != EOF) {
    if (tmp == '\n') {
      if (charCount > 0) {
        string[strlen(string)] = '\0';
        fprintf(fpOut, "%s\n", string);
        wordCount++;
        charCount = 0;
        free(string);
        string = calloc(0, sizeof(char));
      }
    } else {
      if (charCount == 0) {
        free(string);
        string = calloc(0, sizeof(char));
      }
      string[charCount] = tmp;
      charCount++;
    }
  }
  fclose(fpIn1);
  while ((tmp = fgetc(fpIn2)) != EOF) {
    if (tmp == '\n') {
      if (charCount > 0) {
        string[strlen(string)] = '\0';
        fprintf(fpOut, "%s\n", string);
        wordCount++;
        charCount = 0;
        free(string);
        string = calloc(0, sizeof(char));
      }
    } else {
      if (charCount == 0) {
        free(string);
        string = calloc(0, sizeof(char));
      }
      string[charCount] = tmp;
      charCount++;
    }
  }
  fclose(fpIn2);
  free(string);
  printf("total words merged: %d\n", wordCount);
  fclose(fpOut);
  free(input1);
  free(input2);
  free(output);
}


x86 assembly (clang, -O0):
<mergeFiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1244 <mergeFiles+0x84>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rdx
call   1040 <strncpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xce6(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1353 <mergeFiles+0x193>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rdx
call   1040 <strncpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rsi
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0xb0(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xbd7(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1462 <mergeFiles+0x2a2>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rdx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xe0(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rsi
lea    0xb8b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0xd0(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xc8(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xaf6(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     157f <mergeFiles+0x3bf>
movl   $0x1,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xf0(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0xe8(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1613 <mergeFiles+0x453>
mov    -0x20(%rbp),%rsi
lea    0xa49(%rip),%rdi
call   10e0 <getFilename@plt>
mov    %rax,-0x38(%rbp)
jmp    1627 <mergeFiles+0x467>
mov    -0x20(%rbp),%rsi
lea    0xa39(%rip),%rdi
call   10e0 <getFilename@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
lea    0x9fe(%rip),%rsi
call   10d0 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1677 <mergeFiles+0x4b7>
movl   $0x1,-0x4c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x108(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x110(%rbp),%rdi
mov    -0x108(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x100(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     170b <mergeFiles+0x54b>
mov    -0x28(%rbp),%rsi
lea    0x951(%rip),%rdi
call   10e0 <getFilename@plt>
mov    %rax,-0x40(%rbp)
jmp    171f <mergeFiles+0x55f>
mov    -0x28(%rbp),%rsi
lea    0x941(%rip),%rdi
call   10e0 <getFilename@plt>
mov    %rax,-0x40(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x128(%rbp),%rdi
mov    -0x120(%rbp),%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x118(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0x8b3(%rip),%rdi
call   10e0 <getFilename@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0x8bd(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rdi
lea    0x8ac(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%rdi
lea    0x898(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x68(%rbp)
mov    $0x1,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
mov    -0x60(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x69(%rbp)
movsbl %al,%eax
mov    0x27d6(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     18d7 <mergeFiles+0x717>
movsbl -0x69(%rbp),%eax
cmp    $0xa,%eax
jne    1898 <mergeFiles+0x6d8>
cmpl   $0x0,-0x7c(%rbp)
jle    1893 <mergeFiles+0x6d3>
mov    -0x78(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%rdi
mov    -0x78(%rbp),%rdx
lea    0x80c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x78(%rbp)
jmp    18d2 <mergeFiles+0x712>
cmpl   $0x0,-0x7c(%rbp)
jne    18bb <mergeFiles+0x6fb>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x69(%rbp),%dl
mov    -0x78(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    17fc <mergeFiles+0x63c>
mov    -0x60(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x68(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x69(%rbp)
movsbl %al,%eax
mov    0x26f2(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     19bb <mergeFiles+0x7fb>
movsbl -0x69(%rbp),%eax
cmp    $0xa,%eax
jne    197c <mergeFiles+0x7bc>
cmpl   $0x0,-0x7c(%rbp)
jle    1977 <mergeFiles+0x7b7>
mov    -0x78(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x78(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x138(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%rdi
mov    -0x78(%rbp),%rdx
lea    0x728(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x78(%rbp)
jmp    19b6 <mergeFiles+0x7f6>
cmpl   $0x0,-0x7c(%rbp)
jne    199f <mergeFiles+0x7df>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x69(%rbp),%dl
mov    -0x78(%rbp),%rax
movslq -0x7c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    18e0 <mergeFiles+0x720>
mov    -0x68(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
mov    -0x80(%rbp),%esi
lea    0x69e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergeFiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r15
lea    0xe28(%rip),%rdi
xor    %r13d,%r13d
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0xe18(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %rax,%rbp
mov    %ebp,%ebx
sub    %r15d,%ebx
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
test   %rbp,%rbp
movslq %ebx,%rbx
cmove  %rbp,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%r14,%rax,1)
lea    0xdc9(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
add    %r15,%rbx
add    $0x1,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
movb   $0x0,0x0(%rbp,%rax,1)
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %eax,%ecx
sub    %ebp,%ecx
test   %rax,%rax
movslq %ecx,%r15
cmove  %rax,%r15
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%rbx
mov    %rax,(%rsp)
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%rbx,%rax,1)
lea    0xd4a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
add    %rbp,%r15
add    $0x1,%r15
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <strchr@plt>
mov    %eax,%ecx
sub    %ebx,%ecx
test   %rax,%rax
movslq %ecx,%r15
cmove  %rax,%r15
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%rbp
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <strncpy@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
movb   $0x0,0x0(%rbp,%rax,1)
lea    0xcca(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
add    %rbx,%r15
add    $0x1,%r15
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
movb   $0x0,0x0(%rbp,%rax,1)
mov    %r14,%rdi
mov    $0x43,%esi
call   1070 <strchr@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%r15
lea    0x1(%r14),%rbp
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
test   %rbx,%rbx
movb   $0x0,(%r15,%rax,1)
lea    0xc55(%rip),%r12
lea    0xc45(%rip),%rdi
cmove  %r12,%rdi
mov    %r15,0x20(%rsp)
mov    %r15,%rsi
call   10e0 <getFilename@plt>
mov    %rax,0x18(%rsp)
mov    (%rsp),%r15
mov    %r15,%rdi
mov    $0x43,%esi
call   1070 <strchr@plt>
mov    %rax,0x10(%rsp)
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
lea    0x1(%r15),%r14
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
cmpq   $0x0,0x10(%rsp)
movb   $0x0,0x0(%rbp,%rax,1)
lea    0xbd8(%rip),%rax
cmovne %rax,%r12
mov    %r12,%rdi
mov    %rbp,0x10(%rsp)
mov    %rbp,%rsi
call   10e0 <getFilename@plt>
mov    %rax,%r14
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%r15
lea    0x1(%r15),%rbp
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <strncpy@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%rbx,%rax,1)
lea    0xb82(%rip),%rdi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rsi
call   10e0 <getFilename@plt>
lea    0xb8c(%rip),%rsi
mov    %rax,%rdi
call   10d0 <fopen@plt>
mov    %rax,(%rsp)
lea    0xb7c(%rip),%rbp
mov    0x18(%rsp),%rdi
mov    %rbp,%rsi
call   10d0 <fopen@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rbp,%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbp
mov    $0x1,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1090 <fgetc@plt>
mov    %eax,%r12d
mov    0x2abc(%rip),%rax
cmp    (%rax),%r12b
jne    15ad <mergeFiles+0x3ed>
xor    %ebx,%ebx
mov    %ebx,%r12d
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %rbp,%rdi
call   1090 <fgetc@plt>
mov    %eax,%ebx
mov    0x2a99(%rip),%rax
cmp    (%rax),%bl
jne    1651 <mergeFiles+0x491>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xb03(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rsp),%rdi
call   1050 <fclose@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    15eb <mergeFiles+0x42b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r13d,%r13d
je     1635 <mergeFiles+0x475>
movslq %r13d,%rax
mov    %r12b,(%r14,%rax,1)
add    $0x1,%r13d
mov    %r15,%rdi
call   1090 <fgetc@plt>
mov    %eax,%r12d
mov    0x2a06(%rip),%rax
cmp    (%rax),%r12b
je     1533 <mergeFiles+0x373>
cmp    $0xa,%r12b
jne    15c0 <mergeFiles+0x400>
test   %r13d,%r13d
jle    15d0 <mergeFiles+0x410>
mov    %r14,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%r14,%rax,1)
mov    (%rsp),%rdi
lea    0xa5f(%rip),%rsi
mov    %r14,%rdx
call   10b0 <fprintf@plt>
add    $0x1,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r13d,%r13d
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
jmp    15d0 <mergeFiles+0x410>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
jmp    15c5 <mergeFiles+0x405>
lea    0xa15(%rip),%r15
jmp    1689 <mergeFiles+0x4c9>
nopw   0x0(%rax,%rax,1)
test   %r13d,%r13d
je     16cf <mergeFiles+0x50f>
movslq %r13d,%rax
mov    %bl,(%r14,%rax,1)
add    $0x1,%r13d
mov    %rbp,%rdi
call   1090 <fgetc@plt>
mov    %eax,%ebx
mov    0x2967(%rip),%rax
cmp    (%rax),%bl
je     1557 <mergeFiles+0x397>
cmp    $0xa,%bl
jne    1660 <mergeFiles+0x4a0>
test   %r13d,%r13d
jle    1670 <mergeFiles+0x4b0>
mov    %r14,%rdi
call   1060 <strlen@plt>
movb   $0x0,(%r14,%rax,1)
mov    (%rsp),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   10b0 <fprintf@plt>
add    $0x1,%r12d
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r13d,%r13d
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
jmp    1670 <mergeFiles+0x4b0>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
jmp    1665 <mergeFiles+0x4a5>

LLVM IR (-O0):
@.str = [12 x i8] c"task: [%s]\0A\00"
@.str.1 = [11 x i8] c"size: %lu\0A\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [17 x i8] c"input1 --> [%s]\0A\00"
@.str.4 = [17 x i8] c"input2 --> [%s]\0A\00"
@.str.5 = [17 x i8] c"output --> [%s]\0A\00"
@.str.6 = [2 x i8] c"C\00"
@.str.7 = [9 x i8] c"reduced_\00"
@.str.8 = [21 x i8] c"sorted_output_split_\00"
@.str.9 = [3 x i8] c"w+\00"
@.str.10 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.11 = [4 x i8] c"%s\0A\00"
@.str.12 = [24 x i8] c"total words merged: %d\0A\00"
define void @mergeFiles(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i8
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %2
%19 = load i8*, i8** %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %2
%22 = call i64 @strlen(i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %22)
store i32 0, i32* %3
store i32 0, i32* %3
%24 = call i8* @malloc(i32 1)
store i8* %24, i8** %4
%25 = load i8*, i8** %2
%26 = call i8* @strstr(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %36
29: ; preds = %1
%30 = load i8*, i8** %4
%31 = load i8*, i8** %2
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
store i32 %35, i32* %3
br label %36
36: ; preds = %29, %1
%37 = call i8* @calloc(i32 0, i32 1)
store i8* %37, i8** %5
%38 = load i8*, i8** %5
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = call i32 @strncpy(i8* %38, i8* %39, i64 %41)
%43 = load i8*, i8** %5
%44 = load i8*, i8** %5
%45 = call i64 @strlen(i8* %44)
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 0, i8* %46
%47 = load i8*, i8** %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = call i8* @malloc(i32 1)
store i8* %49, i8** %4
%50 = load i8*, i8** %4
%51 = load i8*, i8** %2
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = getelementptr inbounds i8, i8* %54, i64 1
%56 = load i8*, i8** %2
%57 = call i64 @strlen(i8* %56)
%58 = call i32 @strncpy(i8* %50, i8* %55, i64 %57)
%59 = load i8*, i8** %4
%60 = load i8*, i8** %4
%61 = call i64 @strlen(i8* %60)
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 0, i8* %62
%63 = load i8*, i8** %4
store i8* %63, i8** %2
store i32 0, i32* %3
%64 = call i8* @malloc(i32 1)
store i8* %64, i8** %4
%65 = load i8*, i8** %2
%66 = call i8* @strstr(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %66, i8** %4
%67 = load i8*, i8** %4
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %76
69: ; preds = %36
%70 = load i8*, i8** %4
%71 = load i8*, i8** %2
%72 = ptrtoint i8* %70 to i64
%73 = ptrtoint i8* %71 to i64
%74 = sub i64 %72, %73
%75 = trunc i64 %74 to i32
store i32 %75, i32* %3
br label %76
76: ; preds = %69, %36
%77 = call i8* @calloc(i32 0, i32 1)
store i8* %77, i8** %6
%78 = load i8*, i8** %6
%79 = load i8*, i8** %2
%80 = load i32, i32* %3
%81 = sext i32 %80 to i64
%82 = call i32 @strncpy(i8* %78, i8* %79, i64 %81)
%83 = load i8*, i8** %6
%84 = load i8*, i8** %6
%85 = call i64 @strlen(i8* %84)
%86 = getelementptr inbounds i8, i8* %83, i64 %85
store i8 0, i8* %86
%87 = load i8*, i8** %6
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %87)
%89 = call i8* @malloc(i32 1)
store i8* %89, i8** %4
%90 = load i8*, i8** %4
%91 = load i8*, i8** %2
%92 = load i32, i32* %3
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %91, i64 %93
%95 = getelementptr inbounds i8, i8* %94, i64 1
%96 = load i8*, i8** %2
%97 = call i64 @strlen(i8* %96)
%98 = call i32 @strncpy(i8* %90, i8* %95, i64 %97)
%99 = load i8*, i8** %4
%100 = load i8*, i8** %4
%101 = call i64 @strlen(i8* %100)
%102 = getelementptr inbounds i8, i8* %99, i64 %101
store i8 0, i8* %102
%103 = load i8*, i8** %4
store i8* %103, i8** %2
store i32 0, i32* %3
%104 = call i8* @malloc(i32 1)
store i8* %104, i8** %4
%105 = load i8*, i8** %2
%106 = call i8* @strstr(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %106, i8** %4
%107 = load i8*, i8** %4
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %116
109: ; preds = %76
%110 = load i8*, i8** %4
%111 = load i8*, i8** %2
%112 = ptrtoint i8* %110 to i64
%113 = ptrtoint i8* %111 to i64
%114 = sub i64 %112, %113
%115 = trunc i64 %114 to i32
store i32 %115, i32* %3
br label %116
116: ; preds = %109, %76
%117 = call i8* @calloc(i32 0, i32 1)
store i8* %117, i8** %7
%118 = load i8*, i8** %7
%119 = load i8*, i8** %2
%120 = load i32, i32* %3
%121 = sext i32 %120 to i64
%122 = call i32 @strncpy(i8* %118, i8* %119, i64 %121)
%123 = load i8*, i8** %7
%124 = load i8*, i8** %7
%125 = call i64 @strlen(i8* %124)
%126 = getelementptr inbounds i8, i8* %123, i64 %125
store i8 0, i8* %126
%127 = load i8*, i8** %7
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %127)
%129 = call i8* @malloc(i32 1)
store i8* %129, i8** %4
%130 = load i8*, i8** %4
%131 = load i8*, i8** %2
%132 = load i32, i32* %3
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i8, i8* %131, i64 %133
%135 = getelementptr inbounds i8, i8* %134, i64 1
%136 = load i8*, i8** %2
%137 = call i64 @strlen(i8* %136)
%138 = call i32 @strncpy(i8* %130, i8* %135, i64 %137)
%139 = load i8*, i8** %4
%140 = load i8*, i8** %4
%141 = call i64 @strlen(i8* %140)
%142 = getelementptr inbounds i8, i8* %139, i64 %141
store i8 0, i8* %142
%143 = load i8*, i8** %4
store i8* %143, i8** %2
store i32 0, i32* %11
store i32 0, i32* %3
%144 = call i8* @malloc(i32 1)
store i8* %144, i8** %4
%145 = load i8*, i8** %5
%146 = call i8* @strstr(i8* %145, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %146, i8** %4
%147 = load i8*, i8** %4
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %156
149: ; preds = %116
store i32 1, i32* %11
%150 = load i8*, i8** %4
%151 = load i8*, i8** %5
%152 = ptrtoint i8* %150 to i64
%153 = ptrtoint i8* %151 to i64
%154 = sub i64 %152, %153
%155 = trunc i64 %154 to i32
store i32 %155, i32* %3
br label %156
156: ; preds = %149, %116
%157 = call i8* @malloc(i32 1)
store i8* %157, i8** %4
%158 = load i8*, i8** %4
%159 = load i8*, i8** %5
%160 = getelementptr inbounds i8, i8* %159, i64 1
%161 = load i8*, i8** %5
%162 = call i64 @strlen(i8* %161)
%163 = call i32 @strncpy(i8* %158, i8* %160, i64 %162)
%164 = load i8*, i8** %4
%165 = load i8*, i8** %5
%166 = call i64 @strlen(i8* %165)
%167 = getelementptr inbounds i8, i8* %164, i64 %166
store i8 0, i8* %167
%168 = load i8*, i8** %4
store i8* %168, i8** %5
%169 = load i32, i32* %11
%170 = icmp ne i32 %169, 0
br i1 %170, label %171, label %174
171: ; preds = %156
%172 = load i8*, i8** %5
%173 = call i8* @getFilename(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %172)
store i8* %173, i8** %8
br label %177
174: ; preds = %156
%175 = load i8*, i8** %5
%176 = call i8* @getFilename(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %175)
store i8* %176, i8** %8
br label %177
177: ; preds = %174, %171
store i32 0, i32* %11
store i32 0, i32* %3
%178 = call i8* @malloc(i32 1)
store i8* %178, i8** %4
%179 = load i8*, i8** %6
%180 = call i8* @strstr(i8* %179, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i8* %180, i8** %4
%181 = load i8*, i8** %4
%182 = icmp ne i8* %181, null
br i1 %182, label %183, label %190
183: ; preds = %177
store i32 1, i32* %11
%184 = load i8*, i8** %4
%185 = load i8*, i8** %6
%186 = ptrtoint i8* %184 to i64
%187 = ptrtoint i8* %185 to i64
%188 = sub i64 %186, %187
%189 = trunc i64 %188 to i32
store i32 %189, i32* %3
br label %190
190: ; preds = %183, %177
%191 = call i8* @malloc(i32 1)
store i8* %191, i8** %4
%192 = load i8*, i8** %4
%193 = load i8*, i8** %6
%194 = getelementptr inbounds i8, i8* %193, i64 1
%195 = load i8*, i8** %6
%196 = call i64 @strlen(i8* %195)
%197 = call i32 @strncpy(i8* %192, i8* %194, i64 %196)
%198 = load i8*, i8** %4
%199 = load i8*, i8** %6
%200 = call i64 @strlen(i8* %199)
%201 = getelementptr inbounds i8, i8* %198, i64 %200
store i8 0, i8* %201
%202 = load i8*, i8** %4
store i8* %202, i8** %6
%203 = load i32, i32* %11
%204 = icmp ne i32 %203, 0
br i1 %204, label %205, label %208
205: ; preds = %190
%206 = load i8*, i8** %6
%207 = call i8* @getFilename(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %206)
store i8* %207, i8** %9
br label %211
208: ; preds = %190
%209 = load i8*, i8** %6
%210 = call i8* @getFilename(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %209)
store i8* %210, i8** %9
br label %211
211: ; preds = %208, %205
%212 = call i8* @malloc(i32 1)
store i8* %212, i8** %4
%213 = load i8*, i8** %4
%214 = load i8*, i8** %7
%215 = getelementptr inbounds i8, i8* %214, i64 1
%216 = load i8*, i8** %7
%217 = call i64 @strlen(i8* %216)
%218 = call i32 @strncpy(i8* %213, i8* %215, i64 %217)
%219 = load i8*, i8** %4
%220 = load i8*, i8** %7
%221 = call i64 @strlen(i8* %220)
%222 = getelementptr inbounds i8, i8* %219, i64 %221
store i8 0, i8* %222
%223 = load i8*, i8** %4
store i8* %223, i8** %7
%224 = load i8*, i8** %7
%225 = call i8* @getFilename(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %224)
store i8* %225, i8** %10
%226 = load i8*, i8** %10
%227 = call i32* @fopen(i8* %226, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
store i32* %227, i32** %12
%228 = load i8*, i8** %8
%229 = call i32* @fopen(i8* %228, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %229, i32** %13
%230 = load i8*, i8** %9
%231 = call i32* @fopen(i8* %230, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32* %231, i32** %14
%232 = call i8* @malloc(i32 1)
store i8* %232, i8** %16
store i32 0, i32* %17
store i32 0, i32* %18
br label %233
233: ; preds = %276, %211
%234 = load i32*, i32** %13
%235 = call signext i8 @fgetc(i32* %234)
store i8 %235, i8* %15
%236 = sext i8 %235 to i32
%237 = load i8, i8* @EOF
%238 = sext i8 %237 to i32
%239 = icmp ne i32 %236, %238
br i1 %239, label %240, label %277
240: ; preds = %233
%241 = load i8, i8* %15
%242 = sext i8 %241 to i32
%243 = icmp eq i32 %242, 10
br i1 %243, label %244, label %261
244: ; preds = %240
%245 = load i32, i32* %17
%246 = icmp sgt i32 %245, 0
br i1 %246, label %247, label %260
247: ; preds = %244
%248 = load i8*, i8** %16
%249 = load i8*, i8** %16
%250 = call i64 @strlen(i8* %249)
%251 = getelementptr inbounds i8, i8* %248, i64 %250
store i8 0, i8* %251
%252 = load i32*, i32** %12
%253 = load i8*, i8** %16
%254 = call i32 @fprintf(i32* %252, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %253)
%255 = load i32, i32* %18
%256 = add nsw i32 %255, 1
store i32 %256, i32* %18
store i32 0, i32* %17
%257 = load i8*, i8** %16
%258 = call i32 @free(i8* %257)
%259 = call i8* @calloc(i32 0, i32 1)
store i8* %259, i8** %16
br label %260
260: ; preds = %247, %244
br label %276
261: ; preds = %240
%262 = load i32, i32* %17
%263 = icmp eq i32 %262, 0
br i1 %263, label %264, label %268
264: ; preds = %261
%265 = load i8*, i8** %16
%266 = call i32 @free(i8* %265)
%267 = call i8* @calloc(i32 0, i32 1)
store i8* %267, i8** %16
br label %268
268: ; preds = %264, %261
%269 = load i8, i8* %15
%270 = load i8*, i8** %16
%271 = load i32, i32* %17
%272 = sext i32 %271 to i64
%273 = getelementptr inbounds i8, i8* %270, i64 %272
store i8 %269, i8* %273
%274 = load i32, i32* %17
%275 = add nsw i32 %274, 1
store i32 %275, i32* %17
br label %276
276: ; preds = %268, %260
br label %233
277: ; preds = %233
%278 = load i32*, i32** %13
%279 = call i32 @fclose(i32* %278)
br label %280
280: ; preds = %323, %277
%281 = load i32*, i32** %14
%282 = call signext i8 @fgetc(i32* %281)
store i8 %282, i8* %15
%283 = sext i8 %282 to i32
%284 = load i8, i8* @EOF
%285 = sext i8 %284 to i32
%286 = icmp ne i32 %283, %285
br i1 %286, label %287, label %324
287: ; preds = %280
%288 = load i8, i8* %15
%289 = sext i8 %288 to i32
%290 = icmp eq i32 %289, 10
br i1 %290, label %291, label %308
291: ; preds = %287
%292 = load i32, i32* %17
%293 = icmp sgt i32 %292, 0
br i1 %293, label %294, label %307
294: ; preds = %291
%295 = load i8*, i8** %16
%296 = load i8*, i8** %16
%297 = call i64 @strlen(i8* %296)
%298 = getelementptr inbounds i8, i8* %295, i64 %297
store i8 0, i8* %298
%299 = load i32*, i32** %12
%300 = load i8*, i8** %16
%301 = call i32 @fprintf(i32* %299, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %300)
%302 = load i32, i32* %18
%303 = add nsw i32 %302, 1
store i32 %303, i32* %18
store i32 0, i32* %17
%304 = load i8*, i8** %16
%305 = call i32 @free(i8* %304)
%306 = call i8* @calloc(i32 0, i32 1)
store i8* %306, i8** %16
br label %307
307: ; preds = %294, %291
br label %323
308: ; preds = %287
%309 = load i32, i32* %17
%310 = icmp eq i32 %309, 0
br i1 %310, label %311, label %315
311: ; preds = %308
%312 = load i8*, i8** %16
%313 = call i32 @free(i8* %312)
%314 = call i8* @calloc(i32 0, i32 1)
store i8* %314, i8** %16
br label %315
315: ; preds = %311, %308
%316 = load i8, i8* %15
%317 = load i8*, i8** %16
%318 = load i32, i32* %17
%319 = sext i32 %318 to i64
%320 = getelementptr inbounds i8, i8* %317, i64 %319
store i8 %316, i8* %320
%321 = load i32, i32* %17
%322 = add nsw i32 %321, 1
store i32 %322, i32* %17
br label %323
323: ; preds = %315, %307
br label %280
324: ; preds = %280
%325 = load i32*, i32** %14
%326 = call i32 @fclose(i32* %325)
%327 = load i8*, i8** %16
%328 = call i32 @free(i8* %327)
%329 = load i32, i32* %18
%330 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i32 %329)
%331 = load i32*, i32** %12
%332 = call i32 @fclose(i32* %331)
%333 = load i8*, i8** %5
%334 = call i32 @free(i8* %333)
%335 = load i8*, i8** %6
%336 = call i32 @free(i8* %335)
%337 = load i8*, i8** %7
%338 = call i32 @free(i8* %337)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"task: [%s]\0A\00"
@.str.1 = [11 x i8] c"size: %lu\0A\00"
@.str.3 = [17 x i8] c"input1 --> [%s]\0A\00"
@.str.4 = [17 x i8] c"input2 --> [%s]\0A\00"
@.str.5 = [17 x i8] c"output --> [%s]\0A\00"
@.str.7 = [9 x i8] c"reduced_\00"
@.str.8 = [21 x i8] c"sorted_output_split_\00"
@.str.9 = [3 x i8] c"w+\00"
@.str.10 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.11 = [4 x i8] c"%s\0A\00"
@.str.12 = [24 x i8] c"total words merged: %d\0A\00"
define void @mergeFiles(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 32)
%6 = icmp eq i8* %5, null
%7 = ptrtoint i8* %5 to i64
%8 = ptrtoint i8* %0 to i64
%9 = sub i64 %7, %8
%10 = tail call i8* @calloc(i32 0, i32 1)
%11 = shl i64 %9, 32
%12 = ashr exact i64 %11, 32
%13 = select i1 %6, i64 0, i64 %12
%14 = tail call i32 @strncpy(i8* %10, i8* %0, i64 %13)
%15 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%16 = getelementptr inbounds i8, i8* %10, i64 %15
store i8 0, i8* %16
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%18 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%19 = getelementptr inbounds i8, i8* %0, i64 %13
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%22 = tail call i32 @strncpy(i8* %18, i8* %20, i64 %21)
%23 = tail call i64 @strlen(i8* dereferenceable(1) %18)
%24 = getelementptr inbounds i8, i8* %18, i64 %23
store i8 0, i8* %24
%25 = tail call i8* @strchr(i8* dereferenceable(1) %18, i32 32)
%26 = icmp eq i8* %25, null
%27 = ptrtoint i8* %25 to i64
%28 = ptrtoint i8* %18 to i64
%29 = sub i64 %27, %28
%30 = shl i64 %29, 32
%31 = ashr exact i64 %30, 32
%32 = select i1 %26, i64 0, i64 %31
%33 = tail call i8* @calloc(i32 0, i32 1)
%34 = tail call i32 @strncpy(i8* %33, i8* %18, i64 %32)
%35 = tail call i64 @strlen(i8* dereferenceable(1) %33)
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 0, i8* %36
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%38 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%39 = getelementptr inbounds i8, i8* %18, i64 %32
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = tail call i64 @strlen(i8* dereferenceable(1) %18)
%42 = tail call i32 @strncpy(i8* %38, i8* %40, i64 %41)
%43 = tail call i64 @strlen(i8* dereferenceable(1) %38)
%44 = getelementptr inbounds i8, i8* %38, i64 %43
store i8 0, i8* %44
%45 = tail call i8* @strchr(i8* dereferenceable(1) %38, i32 32)
%46 = icmp eq i8* %45, null
%47 = ptrtoint i8* %45 to i64
%48 = ptrtoint i8* %38 to i64
%49 = sub i64 %47, %48
%50 = shl i64 %49, 32
%51 = ashr exact i64 %50, 32
%52 = select i1 %46, i64 0, i64 %51
%53 = tail call i8* @calloc(i32 0, i32 1)
%54 = tail call i32 @strncpy(i8* %53, i8* %38, i64 %52)
%55 = tail call i64 @strlen(i8* dereferenceable(1) %53)
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 0, i8* %56
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %53)
%58 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%59 = getelementptr inbounds i8, i8* %38, i64 %52
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = tail call i64 @strlen(i8* dereferenceable(1) %38)
%62 = tail call i32 @strncpy(i8* %58, i8* %60, i64 %61)
%63 = tail call i64 @strlen(i8* dereferenceable(1) %58)
%64 = getelementptr inbounds i8, i8* %58, i64 %63
store i8 0, i8* %64
%65 = tail call i8* @strchr(i8* dereferenceable(1) %10, i32 67)
%66 = icmp eq i8* %65, null
%67 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%68 = getelementptr inbounds i8, i8* %10, i64 1
%69 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%70 = tail call i32 @strncpy(i8* %67, i8* %68, i64 %69)
%71 = tail call i64 @strlen(i8* dereferenceable(1) %10)
%72 = getelementptr inbounds i8, i8* %67, i64 %71
store i8 0, i8* %72
%73 = select i1 %66, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0)
%74 = tail call i8* @getFilename(i8* %73, i8* %67)
%75 = tail call i8* @strchr(i8* dereferenceable(1) %33, i32 67)
%76 = icmp eq i8* %75, null
%77 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%78 = getelementptr inbounds i8, i8* %33, i64 1
%79 = tail call i64 @strlen(i8* dereferenceable(1) %33)
%80 = tail call i32 @strncpy(i8* %77, i8* %78, i64 %79)
%81 = tail call i64 @strlen(i8* dereferenceable(1) %33)
%82 = getelementptr inbounds i8, i8* %77, i64 %81
store i8 0, i8* %82
%83 = select i1 %76, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0)
%84 = tail call i8* @getFilename(i8* %83, i8* %77)
%85 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%86 = getelementptr inbounds i8, i8* %53, i64 1
%87 = tail call i64 @strlen(i8* dereferenceable(1) %53)
%88 = tail call i32 @strncpy(i8* %85, i8* %86, i64 %87)
%89 = tail call i64 @strlen(i8* dereferenceable(1) %53)
%90 = getelementptr inbounds i8, i8* %85, i64 %89
store i8 0, i8* %90
%91 = tail call i8* @getFilename(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* %85)
%92 = tail call i32* @fopen(i8* %91, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%93 = tail call i32* @fopen(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%94 = tail call i32* @fopen(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%95 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%96 = tail call signext i8 @fgetc(i32* %93)
%97 = load i8, i8* @EOF
%98 = icmp eq i8 %96, %97
br i1 %98, label %131, label %99
99: ; preds = %1, %124
%100 = phi i8 [ %128, %124 ], [ %96, %1 ]
%101 = phi i32 [ %127, %124 ], [ 0, %1 ]
%102 = phi i32 [ %126, %124 ], [ 0, %1 ]
%103 = phi i8* [ %125, %124 ], [ %95, %1 ]
%104 = icmp eq i8 %100, 10
br i1 %104, label %105, label %114
105: ; preds = %99
%106 = icmp sgt i32 %102, 0
br i1 %106, label %107, label %124
107: ; preds = %105
%108 = tail call i64 @strlen(i8* dereferenceable(1) %103)
%109 = getelementptr inbounds i8, i8* %103, i64 %108
store i8 0, i8* %109
%110 = tail call i32 @fprintf(i32* %92, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %103)
%111 = add nsw i32 %101, 1
%112 = tail call i32 @free(i8* %103)
%113 = tail call i8* @calloc(i32 0, i32 1)
br label %124
114: ; preds = %99
%115 = icmp eq i32 %102, 0
br i1 %115, label %116, label %119
116: ; preds = %114
%117 = tail call i32 @free(i8* %103)
%118 = tail call i8* @calloc(i32 0, i32 1)
br label %119
119: ; preds = %116, %114
%120 = phi i8* [ %118, %116 ], [ %103, %114 ]
%121 = sext i32 %102 to i64
%122 = getelementptr inbounds i8, i8* %120, i64 %121
store i8 %100, i8* %122
%123 = add nsw i32 %102, 1
br label %124
124: ; preds = %105, %107, %119
%125 = phi i8* [ %113, %107 ], [ %103, %105 ], [ %120, %119 ]
%126 = phi i32 [ 0, %107 ], [ %102, %105 ], [ %123, %119 ]
%127 = phi i32 [ %111, %107 ], [ %101, %105 ], [ %101, %119 ]
%128 = tail call signext i8 @fgetc(i32* %93)
%129 = load i8, i8* @EOF
%130 = icmp eq i8 %128, %129
br i1 %130, label %131, label %99
131: ; preds = %124, %1
%132 = phi i8* [ %95, %1 ], [ %125, %124 ]
%133 = phi i32 [ 0, %1 ], [ %126, %124 ]
%134 = phi i32 [ 0, %1 ], [ %127, %124 ]
%135 = tail call i32 @fclose(i32* %93)
%136 = tail call signext i8 @fgetc(i32* %94)
%137 = load i8, i8* @EOF
%138 = icmp eq i8 %136, %137
br i1 %138, label %171, label %139
139: ; preds = %131, %164
%140 = phi i8 [ %168, %164 ], [ %136, %131 ]
%141 = phi i32 [ %167, %164 ], [ %134, %131 ]
%142 = phi i32 [ %166, %164 ], [ %133, %131 ]
%143 = phi i8* [ %165, %164 ], [ %132, %131 ]
%144 = icmp eq i8 %140, 10
br i1 %144, label %145, label %154
145: ; preds = %139
%146 = icmp sgt i32 %142, 0
br i1 %146, label %147, label %164
147: ; preds = %145
%148 = tail call i64 @strlen(i8* dereferenceable(1) %143)
%149 = getelementptr inbounds i8, i8* %143, i64 %148
store i8 0, i8* %149
%150 = tail call i32 @fprintf(i32* %92, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %143)
%151 = add nsw i32 %141, 1
%152 = tail call i32 @free(i8* %143)
%153 = tail call i8* @calloc(i32 0, i32 1)
br label %164
154: ; preds = %139
%155 = icmp eq i32 %142, 0
br i1 %155, label %156, label %159
156: ; preds = %154
%157 = tail call i32 @free(i8* %143)
%158 = tail call i8* @calloc(i32 0, i32 1)
br label %159
159: ; preds = %156, %154
%160 = phi i8* [ %158, %156 ], [ %143, %154 ]
%161 = sext i32 %142 to i64
%162 = getelementptr inbounds i8, i8* %160, i64 %161
store i8 %140, i8* %162
%163 = add nsw i32 %142, 1
br label %164
164: ; preds = %145, %147, %159
%165 = phi i8* [ %153, %147 ], [ %143, %145 ], [ %160, %159 ]
%166 = phi i32 [ 0, %147 ], [ %142, %145 ], [ %163, %159 ]
%167 = phi i32 [ %151, %147 ], [ %141, %145 ], [ %141, %159 ]
%168 = tail call signext i8 @fgetc(i32* %94)
%169 = load i8, i8* @EOF
%170 = icmp eq i8 %168, %169
br i1 %170, label %171, label %139
171: ; preds = %164, %131
%172 = phi i8* [ %132, %131 ], [ %165, %164 ]
%173 = phi i32 [ %134, %131 ], [ %167, %164 ]
%174 = tail call i32 @fclose(i32* %94)
%175 = tail call i32 @free(i8* %172)
%176 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i32 %173)
%177 = tail call i32 @fclose(i32* %92)
%178 = tail call i32 @free(i8* %67)
%179 = tail call i32 @free(i8* %77)
%180 = tail call i32 @free(i8* %85)
ret void
}