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

/* Variables and functions */
int /*<<< orphan*/ insertion_sort(int *, int);
int /*<<< orphan*/ print_sequence(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int test_insertion_sort(int *, int);
int main(int argc, char *argv[]) {
  int sequence[] = {3, 3242, 21, 55, 653, 19, 139, 459, 138, 45349, 19, 2, 1};
  int sequence_length = sizeof(sequence) / sizeof(sequence[0]);
  printf("Sorting %d values in sequence ", sequence_length);
  print_sequence(sequence, sequence_length);
  insertion_sort(sequence, sequence_length);
  printf("Done sorting. Result ");
  print_sequence(sequence, sequence_length);
  printf("Testing if result sort is valid....");
  int pass = test_insertion_sort(sequence, sequence_length);
  if (pass)
    printf("Yes!\n");
  else
    printf("No!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
movl   $0xd,-0x54(%rbp)
mov    -0x54(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1040 <print_sequence@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1070 <insertion_sort@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1040 <print_sequence@plt>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1060 <test_insertion_sort@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
je     11ff <main+0xaf>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xbd>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xed5(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeab(%rip),%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xd,%esi
call   1050 <print_sequence@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1070 <insertion_sort@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1050 <print_sequence@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   1060 <test_insertion_sort@plt>
test   %eax,%eax
lea    0xe9c(%rip),%rax
lea    0xe99(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.sequence = [13 x i32] [i32 3, i32 3242, i32 21, i32 55, i32 653, i32 19, i32 139, i32 459, i32 138, i32 45349, i32 19, i32 2, i32 1]
@.str = [31 x i8] c"Sorting %d values in sequence \00"
@.str.1 = [22 x i8] c"Done sorting. Result \00"
@.str.2 = [36 x i8] c"Testing if result sort is valid....\00"
@.str.3 = [6 x i8] c"Yes!\0A\00"
@.str.4 = [5 x i8] c"No!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [13 x i32]* %6 to i8*
store i32 13, i32* %7
%10 = load i32, i32* %7
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%13 = load i32, i32* %7
%14 = call i32 @print_sequence(i32* %12, i32 %13)
%15 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%16 = load i32, i32* %7
%17 = call i32 @insertion_sort(i32* %15, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%20 = load i32, i32* %7
%21 = call i32 @print_sequence(i32* %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%23 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%24 = load i32, i32* %7
%25 = call i32 @test_insertion_sort(i32* %23, i32 %24)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %32
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}

LLVM IR (-O2):
@__const.main.sequence = [13 x i32] [i32 3, i32 3242, i32 21, i32 55, i32 653, i32 19, i32 139, i32 459, i32 138, i32 45349, i32 19, i32 2, i32 1]
@.str = [31 x i8] c"Sorting %d values in sequence \00"
@.str.1 = [22 x i8] c"Done sorting. Result \00"
@.str.2 = [36 x i8] c"Testing if result sort is valid....\00"
@str = [4 x i8] c"No!\00"
@str.5 = [5 x i8] c"Yes!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i32]
%4 = bitcast [13 x i32]* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 13)
%6 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%7 = call i32 @print_sequence(i32* %6, i32 13)
%8 = call i32 @insertion_sort(i32* %6, i32 13)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @print_sequence(i32* %6, i32 13)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @test_insertion_sort(i32* %6, i32 13)
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0)
%15 = call i32 @puts(i8* dereferenceable(1) %14)
ret i32 0
}