#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 */
bool test_insertion_sort(int *sequence, int sequence_length) {
  for (int i = 1; i < sequence_length; i++) {
    if (sequence[i] < sequence[i - 1])
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<test_insertion_sort>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    115e <test_insertion_sort+0x5e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jge    114b <test_insertion_sort+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1165 <test_insertion_sort+0x65>
jmp    1150 <test_insertion_sort+0x50>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1112 <test_insertion_sort+0x12>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_insertion_sort>:
mov    $0x1,%eax
cmp    $0x2,%esi
jl     113d <test_insertion_sort+0x3d>
mov    0x4(%rdi),%edx
xor    %eax,%eax
cmp    (%rdi),%edx
jl     113d <test_insertion_sort+0x3d>
mov    %esi,%r8d
mov    $0x2,%eax
nopl   0x0(%rax,%rax,1)
mov    %rax,%rsi
cmp    %rax,%r8
je     1135 <test_insertion_sort+0x35>
mov    (%rdi,%rsi,4),%ecx
lea    0x1(%rsi),%rax
cmp    %edx,%ecx
mov    %ecx,%edx
jge    1120 <test_insertion_sort+0x20>
xor    %eax,%eax
cmp    %r8,%rsi
setae  %al
ret

LLVM IR (-O0):
define i32 @test_insertion_sort(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 1, i32* %6
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = load i32*, i32** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = load i32*, i32** %4
%18 = load i32, i32* %6
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32, i32* %21
%23 = icmp slt i32 %16, %22
br i1 %23, label %24, label %25
24: ; preds = %11
store i32 0, i32* %3
br label %30
25: ; preds = %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %7
29: ; preds = %7
store i32 1, i32* %3
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @test_insertion_sort(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = zext i32 %1 to i64
%7 = load i32, i32* %0
%8 = getelementptr inbounds i32, i32* %0, i64 1
%9 = load i32, i32* %8
%10 = icmp slt i32 %9, %7
br i1 %10, label %23, label %11
11: ; preds = %4, %15
%12 = phi i64 [ %19, %15 ], [ 2, %4 ]
%13 = phi i32 [ %17, %15 ], [ %9, %4 ]
%14 = icmp eq i64 %12, %6
br i1 %14, label %20, label %15
15: ; preds = %11
%16 = getelementptr inbounds i32, i32* %0, i64 %12
%17 = load i32, i32* %16
%18 = icmp slt i32 %17, %13
%19 = add nuw nsw i64 %12, 1
br i1 %18, label %20, label %11
20: ; preds = %11, %15
%21 = icmp uge i64 %12, %5
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %20, %4, %2
%24 = phi i32 [ 1, %2 ], [ 0, %4 ], [ %22, %20 ]
ret i32 %24
}