#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 scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ generateChunks(char *, char *, scalar_t__, scalar_t__,
                                  char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char const *argv[]) {
  uint32_t fileSize;
  char path[150];
  char ptrPath[150];
  printf("Please enter the full path of the directory for storage.\nENSURE "
         "THAT THIS IS EXT4 AND JOURNALLING IS DISABLED.\n");
  scanf("%s", path);
  printf("Would you like to store your state file off disk? y/n\n");
  char ptrChoice = ' ';
  while (!(ptrChoice == 'y' | ptrChoice == 'n')) {
    scanf(" %c", &ptrChoice);
  }
  if (ptrChoice == 'y') {
    printf("Please enter the path where you want to save your state.\n");
    scanf("%s", ptrPath);
  } else {
    strcpy(ptrPath, path);
  }
  printf("Would you like to do simultaneous writing to two disks? y/n\n");
  char choice = ' ';
  while (!(choice == 'y' | choice == 'n')) {
    scanf(" %c", &choice);
  }
  char secondaryPath[150];
  char secondaryPtrPath[150];
  if (choice == 'y') {
    printf("Please enter the path of the secondary directory.\n");
    scanf("%s", secondaryPath);
    if (ptrChoice == 'y') {
      printf("Please enter the path where you want to save your secondary "
             "state.\n");
      scanf("%s", secondaryPtrPath);
    } else {
      strcpy(secondaryPtrPath, secondaryPath);
    }
  } else {
    secondaryPath[0] = '\0';
  }
  uint32_t chunksNo = 0;
  printf("Please enter how many ~100mb chunks of data you desire\n");
  scanf("%u", &chunksNo);
  if (chunksNo == 0) {
    printf("0 is not enough data. Please request more data.\n");
    return -1;
  }
  fileSize = 100003840;
  generateChunks(path, ptrPath, chunksNo, fileSize, secondaryPath,
                 secondaryPath);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
lea    -0xb0(%rbp),%rsi
lea    0xefd(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xef2(%rip),%rdi
call   1040 <printf@plt>
movb   $0x20,-0x151(%rbp)
movsbl -0x151(%rbp),%eax
cmp    $0x79,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
movsbl -0x151(%rbp),%ecx
cmp    $0x6e,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c9 <main+0x89>
jmp    11e3 <main+0xa3>
lea    0xeda(%rip),%rdi
lea    -0x151(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    118d <main+0x4d>
movsbl -0x151(%rbp),%eax
cmp    $0x79,%eax
jne    1219 <main+0xd9>
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    -0x150(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    122c <main+0xec>
lea    -0x150(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
movb   $0x20,-0x152(%rbp)
movsbl -0x152(%rbp),%eax
cmp    $0x79,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
movsbl -0x152(%rbp),%ecx
cmp    $0x6e,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
or     %ecx,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    127b <main+0x13b>
jmp    1295 <main+0x155>
lea    0xe28(%rip),%rdi
lea    -0x152(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    123f <main+0xff>
movsbl -0x152(%rbp),%eax
cmp    $0x79,%eax
jne    1314 <main+0x1d4>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1f0(%rbp),%rsi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x151(%rbp),%eax
cmp    $0x79,%eax
jne    12fc <main+0x1bc>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x290(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    130f <main+0x1cf>
lea    -0x290(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    131b <main+0x1db>
movb   $0x0,-0x1f0(%rbp)
movq   $0x0,-0x298(%rbp)
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0x298(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpq   $0x0,-0x298(%rbp)
jne    136d <main+0x22d>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a8 <main+0x268>
movq   $0x5f5f000,-0x18(%rbp)
05
lea    -0xb0(%rbp),%rdi
lea    -0x150(%rbp),%rsi
mov    -0x298(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    -0x1f0(%rbp),%r8
lea    -0x1f0(%rbp),%r9
call   1060 <generateChunks@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x288,%rsp
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xea3(%rip),%rdi
lea    0x150(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf06(%rip),%rdi
call   1040 <puts@plt>
movb   $0x20,0x6(%rsp)
mov    $0x20,%al
lea    0xe7d(%rip),%r14
lea    0x6(%rsp),%rbx
cmp    $0x6e,%al
je     11aa <main+0x6a>
nop
cmp    $0x79,%al
je     11c1 <main+0x81>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0x6(%rsp),%eax
cmp    $0x6e,%al
jne    1190 <main+0x50>
lea    0xb0(%rsp),%rdi
lea    0x150(%rsp),%rsi
call   1030 <strcpy@plt>
jmp    11e3 <main+0xa3>
lea    0xfff(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2c(%rip),%rdi
lea    0xb0(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
movb   $0x20,0x7(%rsp)
mov    $0x20,%al
lea    0xe06(%rip),%r14
lea    0x7(%rsp),%rbx
cmp    $0x6e,%al
je     122a <main+0xea>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x79,%al
je     122a <main+0xea>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0x6e,%al
jne    1210 <main+0xd0>
cmp    $0x79,%al
jne    1278 <main+0x138>
lea    0xf1d(%rip),%rdi
call   1040 <puts@plt>
lea    0xdbf(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x79,0x6(%rsp)
jne    127f <main+0x13f>
lea    0xf29(%rip),%rdi
call   1040 <puts@plt>
lea    0xd99(%rip),%rdi
lea    0x1f0(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
jmp    1291 <main+0x151>
movb   $0x0,0x10(%rsp)
jmp    1291 <main+0x151>
lea    0x1f0(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <strcpy@plt>
movq   $0x0,0x8(%rsp)
lea    0xe4a(%rip),%rdi
call   1040 <puts@plt>
lea    0xd5a(%rip),%rdi
xor    %ebx,%ebx
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     12e9 <main+0x1a9>
lea    0x150(%rsp),%rdi
lea    0xb0(%rsp),%rsi
lea    0x10(%rsp),%r8
mov    $0x5f5f000,%ecx
mov    %r8,%r9
call   1060 <generateChunks@plt>
jmp    12fa <main+0x1ba>
lea    0xe32(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x288,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [112 x i8] c"Please enter the full path of the directory for storage.\0AENSURE THAT THIS IS EXT4 AND JOURNALLING IS DISABLED.\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [55 x i8] c"Would you like to store your state file off disk? y/n\0A\00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [58 x i8] c"Please enter the path where you want to save your state.\0A\00"
@.str.5 = [61 x i8] c"Would you like to do simultaneous writing to two disks? y/n\0A\00"
@.str.6 = [51 x i8] c"Please enter the path of the secondary directory.\0A\00"
@.str.7 = [68 x i8] c"Please enter the path where you want to save your secondary state.\0A\00"
@.str.8 = [56 x i8] c"Please enter how many ~100mb chunks of data you desire\0A\00"
@.str.9 = [3 x i8] c"%u\00"
@.str.10 = [49 x i8] c"0 is not enough data. Please request more data.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [150 x i8]
%8 = alloca [150 x i8]
%9 = alloca i8
%10 = alloca i8
%11 = alloca [150 x i8]
%12 = alloca [150 x i8]
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 @printf(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [150 x i8], [150 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
store i8 32, i8* %9
br label %18
18: ; preds = %30, %2
%19 = load i8, i8* %9
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 121
%22 = zext i1 %21 to i32
%23 = load i8, i8* %9
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 110
%26 = zext i1 %25 to i32
%27 = or i32 %22, %26
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %32
30: ; preds = %18
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %18
32: ; preds = %18
%33 = load i8, i8* %9
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 121
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
%38 = getelementptr inbounds [150 x i8], [150 x i8]* %8, i64 0, i64 0
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
br label %44
40: ; preds = %32
%41 = getelementptr inbounds [150 x i8], [150 x i8]* %8, i64 0, i64 0
%42 = getelementptr inbounds [150 x i8], [150 x i8]* %7, i64 0, i64 0
%43 = call i32 @strcpy(i8* %41, i8* %42)
br label %44
44: ; preds = %40, %36
%45 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
store i8 32, i8* %10
br label %46
46: ; preds = %58, %44
%47 = load i8, i8* %10
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 121
%50 = zext i1 %49 to i32
%51 = load i8, i8* %10
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 110
%54 = zext i1 %53 to i32
%55 = or i32 %50, %54
%56 = icmp ne i32 %55, 0
%57 = xor i1 %56, true
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %46
60: ; preds = %46
%61 = load i8, i8* %10
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 121
br i1 %63, label %64, label %80
64: ; preds = %60
%65 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%66 = getelementptr inbounds [150 x i8], [150 x i8]* %11, i64 0, i64 0
%67 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %66)
%68 = load i8, i8* %9
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 121
br i1 %70, label %71, label %75
71: ; preds = %64
%72 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0))
%73 = getelementptr inbounds [150 x i8], [150 x i8]* %12, i64 0, i64 0
%74 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %73)
br label %79
75: ; preds = %64
%76 = getelementptr inbounds [150 x i8], [150 x i8]* %12, i64 0, i64 0
%77 = getelementptr inbounds [150 x i8], [150 x i8]* %11, i64 0, i64 0
%78 = call i32 @strcpy(i8* %76, i8* %77)
br label %79
79: ; preds = %75, %71
br label %82
80: ; preds = %60
%81 = getelementptr inbounds [150 x i8], [150 x i8]* %11, i64 0, i64 0
store i8 0, i8* %81
br label %82
82: ; preds = %80, %79
store i64 0, i64* %13
%83 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0))
%84 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64* %13)
%85 = load i64, i64* %13
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %82
%88 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.10, i64 0, i64 0))
store i32 -1, i32* %3
br label %97
89: ; preds = %82
store i64 100003840, i64* %6
%90 = getelementptr inbounds [150 x i8], [150 x i8]* %7, i64 0, i64 0
%91 = getelementptr inbounds [150 x i8], [150 x i8]* %8, i64 0, i64 0
%92 = load i64, i64* %13
%93 = load i64, i64* %6
%94 = getelementptr inbounds [150 x i8], [150 x i8]* %11, i64 0, i64 0
%95 = getelementptr inbounds [150 x i8], [150 x i8]* %11, i64 0, i64 0
%96 = call i32 @generateChunks(i8* %90, i8* %91, i64 %92, i64 %93, i8* %94, i8* %95)
store i32 0, i32* %3
br label %97
97: ; preds = %89, %87
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [4 x i8] c" %c\00"
@.str.9 = [3 x i8] c"%u\00"
@str = [111 x i8] c"Please enter the full path of the directory for storage.\0AENSURE THAT THIS IS EXT4 AND JOURNALLING IS DISABLED.\00"
@str.11 = [54 x i8] c"Would you like to store your state file off disk? y/n\00"
@str.12 = [60 x i8] c"Would you like to do simultaneous writing to two disks? y/n\00"
@str.13 = [55 x i8] c"Please enter how many ~100mb chunks of data you desire\00"
@str.14 = [48 x i8] c"0 is not enough data. Please request more data.\00"
@str.15 = [50 x i8] c"Please enter the path of the secondary directory.\00"
@str.16 = [67 x i8] c"Please enter the path where you want to save your secondary state.\00"
@str.17 = [57 x i8] c"Please enter the path where you want to save your state.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [150 x i8]
%4 = alloca [150 x i8]
%5 = alloca i8
%6 = alloca i8
%7 = alloca [150 x i8]
%8 = alloca [150 x i8]
%9 = alloca i64
%10 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [150 x i8], [150 x i8]* %4, i64 0, i64 0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([111 x i8], [111 x i8]* @str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.11, i64 0, i64 0))
store i8 32, i8* %5
br label %15
15: ; preds = %17, %2
%16 = phi i8 [ %19, %17 ], [ 32, %2 ]
switch i8 %16, label %17 [
i8 121, label %20
i8 110, label %23
]
17: ; preds = %15
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%19 = load i8, i8* %5
br label %15
20: ; preds = %15
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.17, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %25
23: ; preds = %15
%24 = call i32 @strcpy(i8* %11, i8* %10)
br label %25
25: ; preds = %23, %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.12, i64 0, i64 0))
store i8 32, i8* %6
br label %27
27: ; preds = %29, %25
%28 = phi i8 [ %31, %29 ], [ 32, %25 ]
switch i8 %28, label %29 [
i8 121, label %32
i8 110, label %32
]
29: ; preds = %27
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%31 = load i8, i8* %6
br label %27
32: ; preds = %27, %27
%33 = getelementptr inbounds [150 x i8], [150 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [150 x i8], [150 x i8]* %8, i64 0, i64 0
%35 = icmp eq i8 %28, 121
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.15, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%39 = load i8, i8* %5
%40 = icmp eq i8 %39, 121
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.16, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %34)
br label %47
44: ; preds = %36
%45 = call i32 @strcpy(i8* %34, i8* %33)
br label %47
46: ; preds = %32
store i8 0, i8* %33
br label %47
47: ; preds = %41, %44, %46
%48 = bitcast i64* %9 to i8*
store i64 0, i64* %9
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.13, i64 0, i64 0))
%50 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64* %9)
%51 = load i64, i64* %9
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.14, i64 0, i64 0))
br label %57
55: ; preds = %47
%56 = call i32 @generateChunks(i8* %10, i8* %11, i64 %51, i64 100003840, i8* %33, i8* %33)
br label %57
57: ; preds = %55, %53
%58 = phi i32 [ -1, %53 ], [ 0, %55 ]
ret i32 %58
}