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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
int main(void) {
  int list[5] = {4, 3, 5, 1, 2};
  int listCount = (int)(sizeof(list) / sizeof(int));
  for (int i = 1; i < listCount; i++) {
    int j = i;
    while (j > 0 && list[j - 1] > list[j]) {
      int n = list[j - 1];
      list[j - 1] = list[j];
      list[j] = n;
      j = j - 1;
      printf("list: %i %i %i %i %i\n", list[0], list[1], list[2], list[3],
             list[4]);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x5,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1203 <main+0xf3>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x31(%rbp)
jle    1187 <main+0x77>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1197 <main+0x87>
jmp    11f0 <main+0xe0>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x30(%rbp)
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x30(%rbp),%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
jmp    115e <main+0x4e>
jmp    11f5 <main+0xe5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <main+0x3c>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
mov    $0x1,%r8d
mov    $0x2,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
mov    $0x1,%ecx
mov    $0x5,%r8d
mov    $0x2,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
mov    $0x5,%r8d
mov    $0x2,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
mov    $0x5,%r8d
mov    $0x2,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
mov    $0x2,%r8d
mov    $0x5,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x2,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.list = [5 x i32] [i32 4, i32 3, i32 5, i32 1, i32 2]
@.str = [22 x i8] c"list: %i %i %i %i %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [5 x i32]* %2 to i8*
store i32 5, i32* %3
store i32 1, i32* %4
br label %8
8: ; preds = %62, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %65
12: ; preds = %8
%13 = load i32, i32* %4
store i32 %13, i32* %5
br label %14
14: ; preds = %30, %12
%15 = load i32, i32* %5
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp sgt i32 %22, %26
br label %28
28: ; preds = %17, %14
%29 = phi i1 [ false, %14 ], [ %27, %17 ]
br i1 %29, label %30, label %61
30: ; preds = %28
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %6
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = load i32, i32* %5
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %42
store i32 %39, i32* %43
%44 = load i32, i32* %6
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %46
store i32 %44, i32* %47
%48 = load i32, i32* %5
%49 = sub nsw i32 %48, 1
store i32 %49, i32* %5
%50 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 1
%53 = load i32, i32* %52
%54 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 2
%55 = load i32, i32* %54
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%57 = load i32, i32* %56
%58 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 4
%59 = load i32, i32* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %51, i32 %53, i32 %55, i32 %57, i32 %59)
br label %14
61: ; preds = %28
br label %62
62: ; preds = %61
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
br label %8
65: ; preds = %8
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [22 x i8] c"list: %i %i %i %i %i\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 3, i32 4, i32 5, i32 1, i32 2)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 3, i32 4, i32 1, i32 5, i32 2)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 3, i32 1, i32 4, i32 5, i32 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 3, i32 4, i32 5, i32 2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 3, i32 4, i32 2, i32 5)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 3, i32 2, i32 4, i32 5)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 1, i32 2, i32 3, i32 4, i32 5)
ret i32 0
}