#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sklansky(int /*<<< orphan*/, int *, int *);
int main(int argc, char **argv) {
  uint32_t values[32];
  uint32_t result[32];
  for (int i = 0; i < 32; ++i) {
    values[i] = i;
  }
  sklansky(0, values, result);
  for (int i = 0; i < 32; ++i) {
    printf("%d ", result[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x114(%rbp)
cmpl   $0x20,-0x114(%rbp)
jge    1178 <main+0x58>
mov    -0x114(%rbp),%ecx
movslq -0x114(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1143 <main+0x23>
lea    -0x90(%rbp),%rsi
lea    -0x110(%rbp),%rdx
xor    %edi,%edi
call   1040 <sklansky@plt>
movl   $0x0,-0x118(%rbp)
cmpl   $0x20,-0x118(%rbp)
jge    11d2 <main+0xb2>
movslq -0x118(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    1197 <main+0x77>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x108,%rsp
movaps 0xecf(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
xor    %ebx,%ebx
mov    %rsp,%rsi
lea    0x80(%rsp),%rdx
xor    %edi,%edi
call   1040 <sklansky@plt>
lea    0xedc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x80(%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    11b0 <main+0x90>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i32]
%4 = alloca [32 x i32]
%5 = bitcast [32 x i32]* %3 to i8*
%6 = bitcast [32 x i32]* %4 to i8*
%7 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%8 = bitcast [32 x i32]* %3 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %8
%9 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %10
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 8
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %12
%13 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 12
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %14
%15 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 16
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %16
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 20
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %18
%19 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 24
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, <4 x i32>* %20
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 28
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, <4 x i32>* %22
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
%24 = call i32 @sklansky(i32 0, i32* %7, i32* %23)
br label %26
25: ; preds = %26
ret i32 0
26: ; preds = %2, %26
%27 = phi i64 [ 0, %2 ], [ %31, %26 ]
%28 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = add nuw nsw i64 %27, 1
%32 = icmp eq i64 %31, 32
br i1 %32, label %25, label %26
}