#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *input_file, *len_output_file, *concat_output_file, *sorted_output_file;
  int N = 512, i, j, str_len;
  char tmp_str[65], concat_str[129], sort_str[N][65], output_file_name[128];
  if (argc != 2) {
    printf("Please provide input file\n");
    exit(-1);
  }
  if ((input_file = fopen(argv[1], "r")) == NULL) {
    printf("Cannot open output file with file path %s", argv[1]);
    perror("open input_file");
    exit(-1);
  }
  strcpy(output_file_name, argv[1]);
  strcat(output_file_name, "_len_out");
  if ((len_output_file = fopen(output_file_name, "w")) == NULL) {
    printf("Cannot open output file with file path %s\n", output_file_name);
    perror("open len_out");
    exit(-1);
  }
  strcpy(output_file_name, argv[1]);
  strcat(output_file_name, "_concat_out");
  if ((concat_output_file = fopen(output_file_name, "w")) == NULL) {
    printf("Cannot open output file with file path %s\n", output_file_name);
    perror("open concat_out");
    exit(-1);
  }
  strcpy(output_file_name, argv[1]);
  strcat(output_file_name, "_sorted_out");
  if ((sorted_output_file = fopen(output_file_name, "w")) == NULL) {
    printf("Cannot open output file with file path %s\n", output_file_name);
    perror("open sorted_out");
    exit(-1);
  }
  for (i = 0; i < N; i++) {
    fscanf(input_file, "%s", tmp_str);
    strcpy(sort_str[i], tmp_str);
    str_len = strlen(tmp_str);
    fprintf(len_output_file, "%d\n", str_len);
    if (i % 2 == 0)
      strcpy(concat_str, tmp_str);
    else {
      strcat(concat_str, tmp_str);
      fprintf(concat_output_file, "%s\n", concat_str);
    }
  }
  for (i = 0; i < N; i++) {
    for (j = N - 1; j > i; j--)
      if (strcmp(sort_str[j], sort_str[j - 1]) < 0) {
        strcpy(tmp_str, sort_str[j - 1]);
        strcpy(sort_str[j - 1], sort_str[j]);
        strcpy(sort_str[j], tmp_str);
      }
    fprintf(sorted_output_file, "%s\n", sort_str[i]);
  }
  fclose(input_file);
  fclose(len_output_file);
  fclose(concat_output_file);
  fclose(sorted_output_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x200,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x128(%rbp)
mov    %rax,%rcx
shl    $0x6,%rcx
lea    0xf(%rax,%rcx,1),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1b8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x130(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1226 <main+0x76>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde6(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1274 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xde2(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x1b0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xdb7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12e7 <main+0x137>
lea    -0x1b0(%rbp),%rsi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdb5(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x1b0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xd91(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xd44(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    135a <main+0x1aa>
lea    -0x1b0(%rbp),%rsi
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd5b(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x1b0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xcd1(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    13cd <main+0x21d>
lea    -0x1b0(%rbp),%rsi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd04(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    14a4 <main+0x2f4>
mov    -0x18(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xc52(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x1b8(%rbp),%rdi
movslq -0x38(%rbp),%rax
imul   $0x41,%rax,%rax
add    %rax,%rdi
lea    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xca0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x38(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1465 <main+0x2b5>
lea    -0x120(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1491 <main+0x2e1>
lea    -0x120(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   10c0 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xbff(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1496 <main+0x2e6>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    13d4 <main+0x224>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    15ad <main+0x3fd>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jle    157b <main+0x3cb>
mov    -0x1b8(%rbp),%rsi
movslq -0x3c(%rbp),%rax
imul   $0x41,%rax,%rax
mov    %rsi,%rdi
add    %rax,%rdi
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x41,%rax,%rax
add    %rax,%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jge    1568 <main+0x3b8>
mov    -0x1b8(%rbp),%rsi
lea    -0x90(%rbp),%rdi
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x41,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x1b8(%rbp),%rsi
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x41,%rax,%rax
mov    %rsi,%rdi
add    %rax,%rdi
movslq -0x3c(%rbp),%rax
imul   $0x41,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x1b8(%rbp),%rdi
movslq -0x3c(%rbp),%rax
imul   $0x41,%rax,%rax
add    %rax,%rdi
lea    -0x90(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    156d <main+0x3bd>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    14c0 <main+0x310>
mov    -0x1b8(%rbp),%rdx
mov    -0x30(%rbp),%rdi
movslq -0x38(%rbp),%rax
imul   $0x41,%rax,%rax
add    %rax,%rdx
lea    0xaf1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    14ab <main+0x2fb>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8388,%rsp
cmp    $0x2,%edi
jne    1441 <main+0x281>
mov    %rsi,%rbx
mov    %rsp,%r14
mov    0x8(%rsi),%rdi
lea    0xe15(%rip),%rsi
call   10b0 <fopen@plt>
mov    0x8(%rbx),%rsi
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1457 <main+0x297>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xe26(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcat@plt>
lea    0xe20(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     146e <main+0x2ae>
mov    0x8(%rbx),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
lea    0xe2c(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcat@plt>
lea    0xde3(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <fopen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     148a <main+0x2ca>
mov    %r14,0x18(%rsp)
mov    0x8(%rbx),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe07(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xda2(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14a6 <main+0x2e6>
mov    %rax,%r13
lea    0x180(%rsp),%rbx
lea    0xa0(%rsp),%r15
lea    0xde9(%rip),%r14
lea    0xf0(%rsp),%r12
xor    %ebp,%ebp
jmp    130b <main+0x14b>
nopw   0x0(%rax,%rax,1)
call   10d0 <strcat@plt>
mov    (%rsp),%rdi
lea    0xd7e(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%rbp
add    $0x41,%rbx
cmp    $0x200,%rbp
je     1356 <main+0x196>
mov    0x10(%rsp),%rdi
lea    0xd12(%rip),%rsi
mov    %r15,%rdx
call   1080 <fscanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
test   $0x1,%bpl
jne    12e0 <main+0x120>
call   1030 <strcpy@plt>
jmp    12fa <main+0x13a>
lea    0xa0(%rsp),%r15
xor    %r12d,%r12d
jmp    13a3 <main+0x1e3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rax
shl    $0x6,%rax
add    %r12,%rax
lea    (%rsp,%rax,1),%rdx
add    $0x180,%rdx
mov    %r13,%rdi
lea    0xcdf(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%r12
cmp    $0x200,%r12
je     1403 <main+0x243>
cmp    $0x1fe,%r12
ja     1370 <main+0x1b0>
mov    $0x1ff,%r14d
lea    0x833f(%rsp),%rbp
jmp    13c8 <main+0x208>
nopl   0x0(%rax)
mov    %rbx,%rbp
cmp    %r12,%r14
jbe    1370 <main+0x1b0>
add    $0xffffffffffffffff,%r14
lea    -0x41(%rbp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
jns    13c0 <main+0x200>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    13c0 <main+0x200>
mov    0x10(%rsp),%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1050 <fclose@plt>
mov    (%rsp),%rdi
call   1050 <fclose@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    0x18(%rsp),%rsp
xor    %eax,%eax
add    $0x8388,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc73(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
lea    0xba4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbc0(%rip),%rdi
jmp    14c0 <main+0x300>
lea    0xbd2(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbea(%rip),%rdi
jmp    14c0 <main+0x300>
lea    0xbb6(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbe7(%rip),%rdi
jmp    14c0 <main+0x300>
lea    0xb9a(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbe7(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Please provide input file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [42 x i8] c"Cannot open output file with file path %s\00"
@.str.3 = [16 x i8] c"open input_file\00"
@.str.4 = [9 x i8] c"_len_out\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [43 x i8] c"Cannot open output file with file path %s\0A\00"
@.str.7 = [13 x i8] c"open len_out\00"
@.str.8 = [12 x i8] c"_concat_out\00"
@.str.9 = [16 x i8] c"open concat_out\00"
@.str.10 = [12 x i8] c"_sorted_out\00"
@.str.11 = [16 x i8] c"open sorted_out\00"
@.str.12 = [3 x i8] c"%s\00"
@.str.13 = [4 x i8] c"%d\0A\00"
@.str.14 = [4 x i8] c"%s\0A\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 i32
%14 = alloca [65 x i8]
%15 = alloca [129 x i8]
%16 = alloca i8*
%17 = alloca i64
%18 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 512, i32* %10
%19 = load i32, i32* %10
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %16
%22 = alloca [65 x i8], i64 %20
store i64 %20, i64* %17
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %6
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @exit(i32 -1)
unreachable
41: ; preds = %28
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @strcpy(i8* %42, i8* %45)
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%48 = call i32 @strcat(i8* %47, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %50, i32** %7
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %57
52: ; preds = %41
%53 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %53)
%55 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%56 = call i32 @exit(i32 -1)
unreachable
57: ; preds = %41
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32 @strcpy(i8* %58, i8* %61)
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%65 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%66 = call i32* @fopen(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %66, i32** %8
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %73
68: ; preds = %57
%69 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %69)
%71 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%72 = call i32 @exit(i32 -1)
unreachable
73: ; preds = %57
%74 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i32 @strcpy(i8* %74, i8* %77)
%79 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%80 = call i32 @strcat(i8* %79, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%82 = call i32* @fopen(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %82, i32** %9
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %89
84: ; preds = %73
%85 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %85)
%87 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%88 = call i32 @exit(i32 -1)
unreachable
89: ; preds = %73
store i32 0, i32* %11
br label %90
90: ; preds = %124, %89
%91 = load i32, i32* %11
%92 = load i32, i32* %10
%93 = icmp slt i32 %91, %92
br i1 %93, label %94, label %127
94: ; preds = %90
%95 = load i32*, i32** %6
%96 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%97 = call i32 @fscanf(i32* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %96)
%98 = load i32, i32* %11
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %99
%101 = getelementptr inbounds [65 x i8], [65 x i8]* %100, i64 0, i64 0
%102 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%103 = call i32 @strcpy(i8* %101, i8* %102)
%104 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%105 = call i32 @strlen(i8* %104)
store i32 %105, i32* %13
%106 = load i32*, i32** %7
%107 = load i32, i32* %13
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %106, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %107)
%109 = load i32, i32* %11
%110 = srem i32 %109, 2
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %116
112: ; preds = %94
%113 = getelementptr inbounds [129 x i8], [129 x i8]* %15, i64 0, i64 0
%114 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%115 = call i32 @strcpy(i8* %113, i8* %114)
br label %123
116: ; preds = %94
%117 = getelementptr inbounds [129 x i8], [129 x i8]* %15, i64 0, i64 0
%118 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%119 = call i32 @strcat(i8* %117, i8* %118)
%120 = load i32*, i32** %8
%121 = getelementptr inbounds [129 x i8], [129 x i8]* %15, i64 0, i64 0
%122 = call i32 (i32*, i8*, ...) @fprintf(i32* %120, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %121)
br label %123
123: ; preds = %116, %112
br label %124
124: ; preds = %123
%125 = load i32, i32* %11
%126 = add nsw i32 %125, 1
store i32 %126, i32* %11
br label %90
127: ; preds = %90
store i32 0, i32* %11
br label %128
128: ; preds = %186, %127
%129 = load i32, i32* %11
%130 = load i32, i32* %10
%131 = icmp slt i32 %129, %130
br i1 %131, label %132, label %189
132: ; preds = %128
%133 = load i32, i32* %10
%134 = sub nsw i32 %133, 1
store i32 %134, i32* %12
br label %135
135: ; preds = %176, %132
%136 = load i32, i32* %12
%137 = load i32, i32* %11
%138 = icmp sgt i32 %136, %137
br i1 %138, label %139, label %179
139: ; preds = %135
%140 = load i32, i32* %12
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %141
%143 = getelementptr inbounds [65 x i8], [65 x i8]* %142, i64 0, i64 0
%144 = load i32, i32* %12
%145 = sub nsw i32 %144, 1
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %146
%148 = getelementptr inbounds [65 x i8], [65 x i8]* %147, i64 0, i64 0
%149 = call i64 @strcmp(i8* %143, i8* %148)
%150 = icmp slt i64 %149, 0
br i1 %150, label %151, label %175
151: ; preds = %139
%152 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%153 = load i32, i32* %12
%154 = sub nsw i32 %153, 1
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %155
%157 = getelementptr inbounds [65 x i8], [65 x i8]* %156, i64 0, i64 0
%158 = call i32 @strcpy(i8* %152, i8* %157)
%159 = load i32, i32* %12
%160 = sub nsw i32 %159, 1
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %161
%163 = getelementptr inbounds [65 x i8], [65 x i8]* %162, i64 0, i64 0
%164 = load i32, i32* %12
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %165
%167 = getelementptr inbounds [65 x i8], [65 x i8]* %166, i64 0, i64 0
%168 = call i32 @strcpy(i8* %163, i8* %167)
%169 = load i32, i32* %12
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %170
%172 = getelementptr inbounds [65 x i8], [65 x i8]* %171, i64 0, i64 0
%173 = getelementptr inbounds [65 x i8], [65 x i8]* %14, i64 0, i64 0
%174 = call i32 @strcpy(i8* %172, i8* %173)
br label %175
175: ; preds = %151, %139
br label %176
176: ; preds = %175
%177 = load i32, i32* %12
%178 = add nsw i32 %177, -1
store i32 %178, i32* %12
br label %135
179: ; preds = %135
%180 = load i32*, i32** %9
%181 = load i32, i32* %11
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds [65 x i8], [65 x i8]* %22, i64 %182
%184 = getelementptr inbounds [65 x i8], [65 x i8]* %183, i64 0, i64 0
%185 = call i32 (i32*, i8*, ...) @fprintf(i32* %180, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %184)
br label %186
186: ; preds = %179
%187 = load i32, i32* %11
%188 = add nsw i32 %187, 1
store i32 %188, i32* %11
br label %128
189: ; preds = %128
%190 = load i32*, i32** %6
%191 = call i32 @fclose(i32* %190)
%192 = load i32*, i32** %7
%193 = call i32 @fclose(i32* %192)
%194 = load i32*, i32** %8
%195 = call i32 @fclose(i32* %194)
%196 = load i32*, i32** %9
%197 = call i32 @fclose(i32* %196)
store i32 0, i32* %3
%198 = load i8*, i8** %16
%199 = load i32, i32* %3
ret i32 %199
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [42 x i8] c"Cannot open output file with file path %s\00"
@.str.3 = [16 x i8] c"open input_file\00"
@.str.4 = [9 x i8] c"_len_out\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [43 x i8] c"Cannot open output file with file path %s\0A\00"
@.str.7 = [13 x i8] c"open len_out\00"
@.str.8 = [12 x i8] c"_concat_out\00"
@.str.9 = [16 x i8] c"open concat_out\00"
@.str.10 = [12 x i8] c"_sorted_out\00"
@.str.11 = [16 x i8] c"open sorted_out\00"
@.str.12 = [3 x i8] c"%s\00"
@.str.13 = [4 x i8] c"%d\0A\00"
@.str.14 = [4 x i8] c"%s\0A\00"
@str = [26 x i8] c"Please provide input file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65 x i8]
%4 = alloca [129 x i8]
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [129 x i8], [129 x i8]* %4, i64 0, i64 0
%8 = tail call i8* @llvm.stacksave()
%9 = alloca [512 x [65 x i8]]
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%11 = icmp eq i32 %0, 2
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
%20 = load i8*, i8** %16
br i1 %19, label %21, label %25
21: ; preds = %15
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%23 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @exit(i32 -1)
unreachable
25: ; preds = %15
%26 = call i32 @strcpy(i8* %10, i8* %20)
%27 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%28 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%32 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @exit(i32 -1)
unreachable
34: ; preds = %25
%35 = load i8*, i8** %16
%36 = call i32 @strcpy(i8* %10, i8* %35)
%37 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %44
40: ; preds = %34
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%42 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%43 = call i32 @exit(i32 -1)
unreachable
44: ; preds = %34
%45 = load i8*, i8** %16
%46 = call i32 @strcpy(i8* %10, i8* %45)
%47 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%48 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %54
50: ; preds = %44
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* %10)
%52 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0))
%53 = call i32 @exit(i32 -1)
unreachable
54: ; preds = %44, %68
%55 = phi i64 [ %69, %68 ], [ 0, %44 ]
%56 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %6)
%57 = getelementptr inbounds [512 x [65 x i8]], [512 x [65 x i8]]* %9, i64 0, i64 %55, i64 0
%58 = call i32 @strcpy(i8* %57, i8* %6)
%59 = call i32 @strlen(i8* %6)
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 %59)
%61 = and i64 %55, 1
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %54
%64 = call i32 @strcpy(i8* %7, i8* %6)
br label %68
65: ; preds = %54
%66 = call i32 @strcat(i8* %7, i8* %6)
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %7)
br label %68
68: ; preds = %63, %65
%69 = add nuw nsw i64 %55, 1
%70 = icmp eq i64 %69, 512
br i1 %70, label %71, label %54
71: ; preds = %68, %87
%72 = phi i64 [ %90, %87 ], [ 0, %68 ]
%73 = icmp ult i64 %72, 511
br i1 %73, label %74, label %87
74: ; preds = %71, %85
%75 = phi i64 [ %77, %85 ], [ 511, %71 ]
%76 = getelementptr inbounds [512 x [65 x i8]], [512 x [65 x i8]]* %9, i64 0, i64 %75, i64 0
%77 = add nsw i64 %75, -1
%78 = getelementptr inbounds [512 x [65 x i8]], [512 x [65 x i8]]* %9, i64 0, i64 %77, i64 0
%79 = call i64 @strcmp(i8* %76, i8* %78)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %74
%82 = call i32 @strcpy(i8* %6, i8* %78)
%83 = call i32 @strcpy(i8* %78, i8* %76)
%84 = call i32 @strcpy(i8* %76, i8* %6)
br label %85
85: ; preds = %74, %81
%86 = icmp ugt i64 %77, %72
br i1 %86, label %74, label %87
87: ; preds = %85, %71
%88 = getelementptr inbounds [512 x [65 x i8]], [512 x [65 x i8]]* %9, i64 0, i64 %72, i64 0
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i8* %88)
%90 = add nuw nsw i64 %72, 1
%91 = icmp eq i64 %90, 512
br i1 %91, label %92, label %71
92: ; preds = %87
%93 = call i32 @fclose(i32* %18)
%94 = call i32 @fclose(i32* %28)
%95 = call i32 @fclose(i32* %38)
%96 = call i32 @fclose(i32* %48)
ret i32 0
}