#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 get_correctness(int *, int);
int *malloc(int);
int /*<<< orphan*/ recurs_endsort(int *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ single_endsort(int *, int, int /*<<< orphan*/);
int main(void) {
  int *array = malloc(sizeof(int) * 23);
  int i, num_correct = 0, cycles = 0;
  for (i = 0; i < 23; i++) {
    scanf("%d", &array[i]);
  }
  get_correctness(array, 23);
  while (num_correct < 23 - 1 && cycles < 17) {
    single_endsort(array, 23, 0);
    recurs_endsort(array, 23, 0, cycles % 2);
    num_correct = get_correctness(array, 23);
    cycles++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x5c,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x17,-0x14(%rbp)
jge    11b5 <main+0x65>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5e(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <main+0x32>
mov    -0x10(%rbp),%rdi
mov    $0x17,%esi
call   1070 <get_correctness@plt>
xor    %eax,%eax
cmpl   $0x16,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
jge    11dc <main+0x8c>
cmpl   $0x11,-0x1c(%rbp)
setl   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11ec <main+0x9c>
jmp    1238 <main+0xe8>
mov    -0x10(%rbp),%rdi
mov    $0x17,%esi
xor    %edx,%edx
call   1040 <single_endsort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x17,%esi
xor    %edx,%edx
call   1050 <recurs_endsort@plt>
mov    -0x10(%rbp),%rdi
mov    $0x17,%esi
call   1070 <get_correctness@plt>
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c3 <main+0x73>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x5c,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
lea    0xe97(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <scanf@plt>
lea    0x4(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x8(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xc(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x10(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x14(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x18(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x1c(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x20(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x24(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x28(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x2c(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x30(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x34(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x38(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x3c(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x40(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x44(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x48(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x4c(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x50(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x54(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x58(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    %r15,%rdi
mov    $0x17,%esi
call   1070 <get_correctness@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x17,%esi
xor    %edx,%edx
call   1040 <single_endsort@plt>
mov    %ebx,%ecx
and    $0x1,%ecx
mov    %r15,%rdi
mov    $0x17,%esi
xor    %edx,%edx
call   1050 <recurs_endsort@plt>
mov    %r15,%rdi
mov    $0x17,%esi
call   1070 <get_correctness@plt>
cmp    $0x15,%eax
jg     12cf <main+0x17f>
lea    0x1(%rbx),%eax
cmp    $0x10,%ebx
mov    %eax,%ebx
jb     1290 <main+0x140>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @malloc(i32 92)
store i32* %6, i32** %2
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %3
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 23
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %7
19: ; preds = %7
%20 = load i32*, i32** %2
%21 = call i32 @get_correctness(i32* %20, i32 23)
br label %22
22: ; preds = %30, %19
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 22
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 17
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ false, %22 ], [ %27, %25 ]
br i1 %29, label %30, label %41
30: ; preds = %28
%31 = load i32*, i32** %2
%32 = call i32 @single_endsort(i32* %31, i32 23, i32 0)
%33 = load i32*, i32** %2
%34 = load i32, i32* %5
%35 = srem i32 %34, 2
%36 = call i32 @recurs_endsort(i32* %33, i32 23, i32 0, i32 %35)
%37 = load i32*, i32** %2
%38 = call i32 @get_correctness(i32* %37, i32 23)
store i32 %38, i32* %4
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %22
41: ; preds = %28
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 92)
%2 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%3 = getelementptr inbounds i32, i32* %1, i64 1
%4 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = getelementptr inbounds i32, i32* %1, i64 2
%6 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds i32, i32* %1, i64 3
%8 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds i32, i32* %1, i64 4
%10 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds i32, i32* %1, i64 5
%12 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds i32, i32* %1, i64 6
%14 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds i32, i32* %1, i64 7
%16 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds i32, i32* %1, i64 8
%18 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds i32, i32* %1, i64 9
%20 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds i32, i32* %1, i64 10
%22 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds i32, i32* %1, i64 11
%24 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds i32, i32* %1, i64 12
%26 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
%27 = getelementptr inbounds i32, i32* %1, i64 13
%28 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %27)
%29 = getelementptr inbounds i32, i32* %1, i64 14
%30 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %29)
%31 = getelementptr inbounds i32, i32* %1, i64 15
%32 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %31)
%33 = getelementptr inbounds i32, i32* %1, i64 16
%34 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %33)
%35 = getelementptr inbounds i32, i32* %1, i64 17
%36 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %35)
%37 = getelementptr inbounds i32, i32* %1, i64 18
%38 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %37)
%39 = getelementptr inbounds i32, i32* %1, i64 19
%40 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %39)
%41 = getelementptr inbounds i32, i32* %1, i64 20
%42 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %41)
%43 = getelementptr inbounds i32, i32* %1, i64 21
%44 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %43)
%45 = getelementptr inbounds i32, i32* %1, i64 22
%46 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %45)
%47 = tail call i32 @get_correctness(i32* %1, i32 23)
br label %48
48: ; preds = %0, %48
%49 = phi i32 [ 0, %0 ], [ %54, %48 ]
%50 = tail call i32 @single_endsort(i32* %1, i32 23, i32 0)
%51 = and i32 %49, 1
%52 = tail call i32 @recurs_endsort(i32* %1, i32 23, i32 0, i32 %51)
%53 = tail call i32 @get_correctness(i32* %1, i32 23)
%54 = add nuw nsw i32 %49, 1
%55 = icmp slt i32 %53, 22
%56 = icmp ult i32 %49, 16
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %48, label %58
58: ; preds = %48
ret i32 0
}