#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 */
scalar_t__ circle_sort_inner(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void circle_sort(int *a, int a_size) {
  do {
    int k;
    for (k = 0; k < a_size; k++)
      printf("%d ", a[k]);
    printf("\n");
  } while (circle_sort_inner(a, a + (a_size - 1)));
}


x86 assembly (clang, -O0):
<circle_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1169 <circle_sort+0x49>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <circle_sort+0x16>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <circle_sort_inner@plt>
cmp    $0x0,%rax
jne    112f <circle_sort+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circle_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
movslq %esi,%rax
lea    (%rdi,%rax,4),%r15
add    $0xfffffffffffffffc,%r15
mov    %eax,%r13d
lea    0xeaa(%rip),%r12
jmp    117a <circle_sort+0x4a>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <circle_sort_inner@plt>
test   %rax,%rax
je     11a8 <circle_sort+0x78>
test   %r14d,%r14d
jle    1160 <circle_sort+0x30>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1190 <circle_sort+0x60>
jmp    1160 <circle_sort+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @circle_sort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %23, %2
store i32 0, i32* %5
br label %7
7: ; preds = %18, %6
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %7
21: ; preds = %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21
%24 = load i32*, i32** %3
%25 = load i32*, i32** %3
%26 = load i32, i32* %4
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
%30 = call i64 @circle_sort_inner(i32* %24, i32* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %6, label %32
32: ; preds = %23
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @circle_sort(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
%4 = add nsw i32 %1, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %16, %2
br i1 %3, label %9, label %16
9: ; preds = %8, %9
%10 = phi i64 [ %14, %9 ], [ 0, %8 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %9
16: ; preds = %9, %8
%17 = tail call i32 @putchar(i32 10)
%18 = tail call i64 @circle_sort_inner(i32* %0, i32* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %16
ret void
}