#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 size_t uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
void display_sort_state(uint8_t a[], uint8_t len, uint8_t pos) {
  uint8_t i;
  for (i = 0; i < len; i++)
    printf("%5s  ", i == pos ? "v" : " ");
  puts("");
  for (i = 0; i < len; i++) {
    printf(i == len - 1 ? "%5d" : "%5d, ", a[i]);
  }
  puts("");
  sleep(1);
}


x86 assembly (clang, -O0):
<display_sort_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1196 <display_sort_state+0x66>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
lea    0xe9b(%rip),%rsi
lea    0xe96(%rip),%rax
cmp    %rdx,%rcx
cmove  %rax,%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <display_sort_state+0x1c>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11fd <display_sort_state+0xcd>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
lea    0xe41(%rip),%rdi
lea    0xe36(%rip),%rax
cmp    %rdx,%rcx
cmove  %rax,%rdi
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11aa <display_sort_state+0x7a>
lea    0xe01(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_sort_state>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11e1 <display_sort_state+0xb1>
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,(%rsp)
lea    0xeb1(%rip),%r13
lea    0xea8(%rip),%rbp
lea    0xe9d(%rip),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
cmp    %r14,%r15
mov    %rbp,%rsi
cmove  %r13,%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    1170 <display_sort_state+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
mov    (%rsp),%r13
je     11eb <display_sort_state+0xbb>
lea    -0x1(%rbx),%r15
lea    0xe5d(%rip),%r12
lea    0xe5a(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %rbp,%r15
mov    %r14,%rdi
cmove  %r12,%rdi
mov    0x0(%r13,%rbp,8),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11c0 <display_sort_state+0x90>
jmp    11eb <display_sort_state+0xbb>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <sleep@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%5s \00"
@.str.1 = [2 x i8] c"v\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [4 x i8] c"%5d\00"
@.str.5 = [6 x i8] c"%5d, \00"
define void @display_sort_state(i64* %0, i64 %1, i64 %2) {
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i64* %0, i64** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %19, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %5
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i64, i64* %7
%14 = load i64, i64* %6
%15 = icmp eq i64 %13, %14
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %12
%20 = load i64, i64* %7
%21 = add i64 %20, 1
store i64 %21, i64* %7
br label %8
22: ; preds = %8
%23 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %7
br label %24
24: ; preds = %40, %22
%25 = load i64, i64* %7
%26 = load i64, i64* %5
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = load i64, i64* %7
%30 = load i64, i64* %5
%31 = sub i64 %30, 1
%32 = icmp eq i64 %29, %31
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%35 = load i64*, i64** %4
%36 = load i64, i64* %7
%37 = getelementptr inbounds i64, i64* %35, i64 %36
%38 = load i64, i64* %37
%39 = call i32 (i8*, ...) @printf(i8* %34, i64 %38)
br label %40
40: ; preds = %28
%41 = load i64, i64* %7
%42 = add i64 %41, 1
store i64 %42, i64* %7
br label %24
43: ; preds = %24
%44 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 @sleep(i32 1)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%5s \00"
@.str.1 = [2 x i8] c"v\00"
@.str.2 = [2 x i8] c" \00"
@.str.4 = [4 x i8] c"%5d\00"
@.str.5 = [6 x i8] c"%5d, \00"
define void @display_sort_state(i64* nocapture %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @putchar(i32 10)
br label %27
7: ; preds = %3, %7
%8 = phi i64 [ %12, %7 ], [ 0, %3 ]
%9 = icmp eq i64 %8, %2
%10 = select i1 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = add nuw i64 %8, 1
%13 = icmp eq i64 %12, %1
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = tail call i32 @putchar(i32 10)
br i1 %4, label %27, label %16
16: ; preds = %14
%17 = add i64 %1, -1
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %25, %18 ]
%20 = icmp eq i64 %19, %17
%21 = select i1 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%22 = getelementptr inbounds i64, i64* %0, i64 %19
%23 = load i64, i64* %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %21, i64 %23)
%25 = add nuw i64 %19, 1
%26 = icmp eq i64 %25, %1
br i1 %26, label %27, label %18
27: ; preds = %18, %5, %14
%28 = tail call i32 @putchar(i32 10)
%29 = tail call i32 @sleep(i32 1)
ret void
}