#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*/ printf(char *);
int sscanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ test_random(int);
int /*<<< orphan*/ test_shuffle(int);
int main(int argc, char *argv[]) {
  int length = 25;
  int test = 0;
  if (argc > 1) {
    if (strcmp(argv[1], "--help") == 0) {
      printf("1st input parameter 0 to select random array in a range "
             "(Default)\n");
      printf("1st input parameter 1 to select shuffle This will continue in a "
             "loop till Ctrl+C(Default)\n");
      printf("2nd input parameter  to select number of elements in the array "
             "(Default 25) \n");
      return 0;
    }
    if (sscanf(argv[1], "%i", (int *)&test) != 1) {
      printf("input arg error - not an integer");
      return -1;
    }
  }
  if (argc > 2) {
    if (sscanf(argv[2], "%i", &length) != 1) {
      printf("input arg error - not an integer");
      return -1;
    }
  }
  switch (test) {
  case 0:
    test_random(length);
    break;
  case 1:
    test_shuffle(length);
    break;
  default:
    printf("Invalid test case \n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x19,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    120a <main+0xba>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe73(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11cc <main+0x7c>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xeea(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a3 <main+0x153>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf18(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
je     1205 <main+0xb5>
lea    0xf02(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a3 <main+0x153>
jmp    120a <main+0xba>
cmpl   $0x2,-0x8(%rbp)
jle    1252 <main+0x102>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xed0(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
je     124d <main+0xfd>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a3 <main+0x153>
jmp    1252 <main+0x102>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1276 <main+0x126>
jmp    1265 <main+0x115>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1283 <main+0x133>
jmp    1290 <main+0x140>
mov    -0x14(%rbp),%edi
call   1030 <test_random@plt>
jmp    129c <main+0x14c>
mov    -0x14(%rbp),%edi
call   1050 <test_shuffle@plt>
jmp    129c <main+0x14c>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
movl   $0x19,(%rsp)
movl   $0x0,0x4(%rsp)
mov    $0x19,%edi
cmp    $0x2,%ebp
jl     11dd <main+0x7d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe74(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f7 <main+0x97>
mov    0x8(%rbx),%rdi
lea    0xe66(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    11e4 <main+0x84>
cmp    $0x3,%ebp
jb     11cd <main+0x6d>
mov    0x10(%rbx),%rdi
lea    0xe47(%rip),%rsi
mov    %rsp,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    11e4 <main+0x84>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     1224 <main+0xc4>
test   %eax,%eax
jne    122e <main+0xce>
mov    (%rsp),%edi
call   1030 <test_random@plt>
jmp    121b <main+0xbb>
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%eax
jmp    121d <main+0xbd>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rsp),%edi
call   1060 <test_shuffle@plt>
jmp    121b <main+0xbb>
lea    0xdf6(%rip),%rdi
jmp    1216 <main+0xb6>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [67 x i8] c"1st input parameter 0 to select random array in a range (Default)\0A\00"
@.str.2 = [91 x i8] c"1st input parameter 1 to select shuffle This will continue in a loop till Ctrl+C(Default)\0A\00"
@.str.3 = [78 x i8] c"2nd input parameter to select number of elements in the array (Default 25) \0A\00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [33 x i8] c"input arg error - not an integer\00"
@.str.6 = [20 x i8] c"Invalid test case \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 25, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %29
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %52
20: ; preds = %10
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
28: ; preds = %20
br label %29
29: ; preds = %28, %2
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 2
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @sscanf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%37 = icmp ne i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %52
40: ; preds = %32
br label %41
41: ; preds = %40, %29
%42 = load i32, i32* %7
switch i32 %42, label %49 [
i32 0, label %43
i32 1, label %46
]
43: ; preds = %41
%44 = load i32, i32* %6
%45 = call i32 @test_random(i32 %44)
br label %51
46: ; preds = %41
%47 = load i32, i32* %6
%48 = call i32 @test_shuffle(i32 %47)
br label %51
49: ; preds = %41
%50 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %51
51: ; preds = %49, %46, %43
store i32 0, i32* %3
br label %52
52: ; preds = %51, %38, %26, %16
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [33 x i8] c"input arg error - not an integer\00"
@str = [19 x i8] c"Invalid test case \00"
@str.7 = [66 x i8] c"1st input parameter 0 to select random array in a range (Default)\00"
@str.8 = [90 x i8] c"1st input parameter 1 to select shuffle This will continue in a loop till Ctrl+C(Default)\00"
@str.9 = [77 x i8] c"2nd input parameter to select number of elements in the array (Default 25) \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 25, i32* %3
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %36
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.7, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @str.8, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str.9, i64 0, i64 0))
br label %44
17: ; preds = %8
%18 = load i8*, i8** %9
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%20 = icmp eq i32 %19, 1
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %44
23: ; preds = %17
%24 = icmp ugt i32 %0, 2
br i1 %24, label %25, label %32
25: ; preds = %23
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%29 = icmp eq i32 %28, 1
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %44
32: ; preds = %25, %23
%33 = load i32, i32* %4
switch i32 %33, label %42 [
i32 0, label %34
i32 1, label %39
]
34: ; preds = %32
%35 = load i32, i32* %3
br label %36
36: ; preds = %34, %2
%37 = phi i32 [ %35, %34 ], [ 25, %2 ]
%38 = call i32 @test_random(i32 %37)
br label %44
39: ; preds = %32
%40 = load i32, i32* %3
%41 = call i32 @test_shuffle(i32 %40)
br label %44
42: ; preds = %32
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %36, %39, %42, %30, %21, %13
%45 = phi i32 [ 0, %13 ], [ -1, %21 ], [ -1, %30 ], [ 0, %42 ], [ 0, %39 ], [ 0, %36 ]
ret i32 %45
}