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

/* Variables and functions */
int /*<<< orphan*/ assemble(char ***, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ slice(char *, char *, int);
int main() {
  int parts = 5;
  char sourceFile[4096];
  char destFile[4096];
  printf("Please enter the path of the file you want to be splitted: ");
  scanf("%s", sourceFile);
  slice(sourceFile, destFile, parts);
  char *files[] = {"Part-1.jpg", "Part-2.jpg", "Part-3.jpg", "Part-4.jpg",
                   "Part-5.jpg"};
  assemble(&files, "merged.jpg");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x2010(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <slice@plt>
lea    -0x2040(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1060 <memset@plt>
lea    0xe87(%rip),%rax
mov    %rax,-0x2040(%rbp)
lea    0xe84(%rip),%rax
mov    %rax,-0x2038(%rbp)
lea    0xe81(%rip),%rax
mov    %rax,-0x2030(%rbp)
lea    0xe7e(%rip),%rax
mov    %rax,-0x2028(%rbp)
lea    0xe7b(%rip),%rax
mov    %rax,-0x2020(%rbp)
lea    -0x2040(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1050 <assemble@plt>
xor    %eax,%eax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2030,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
lea    0x1030(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <slice@plt>
lea    0xebb(%rip),%rax
mov    %rax,(%rsp)
lea    0xebb(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xeba(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xeb9(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xeb8(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xeb7(%rip),%rsi
mov    %rsp,%rdi
call   1050 <assemble@plt>
xor    %eax,%eax
add    $0x2030,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Please enter the path of the file you want to be splitted: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [11 x i8] c"Part-1.jpg\00"
@.str.3 = [11 x i8] c"Part-2.jpg\00"
@.str.4 = [11 x i8] c"Part-3.jpg\00"
@.str.5 = [11 x i8] c"Part-4.jpg\00"
@.str.6 = [11 x i8] c"Part-5.jpg\00"
@.str.7 = [11 x i8] c"merged.jpg\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4096 x i8]
%4 = alloca [4096 x i8]
%5 = alloca [5 x i8*]
store i32 0, i32* %1
store i32 5, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @slice(i8* %9, i8* %10, i32 %11)
%13 = bitcast [5 x i8*]* %5 to i8*
%14 = bitcast i8* %13 to [5 x i8*]*
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 4
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i8** %19
%20 = bitcast [5 x i8*]* %5 to i8***
%21 = call i32 @assemble(i8*** %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [60 x i8] c"Please enter the path of the file you want to be splitted: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [11 x i8] c"Part-1.jpg\00"
@.str.3 = [11 x i8] c"Part-2.jpg\00"
@.str.4 = [11 x i8] c"Part-3.jpg\00"
@.str.5 = [11 x i8] c"Part-4.jpg\00"
@.str.6 = [11 x i8] c"Part-5.jpg\00"
@.str.7 = [11 x i8] c"merged.jpg\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca [4096 x i8]
%3 = alloca [5 x i8*]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 @slice(i8* %4, i8* %5, i32 5)
%9 = bitcast [5 x i8*]* %3 to i8*
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 3
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 4
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %14
%15 = bitcast [5 x i8*]* %3 to i8***
%16 = call i32 @assemble(i8*** %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}