#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 */
int /*<<< orphan*/ printarray(int, int *);
int /*<<< orphan*/ printf(char *);
int *rpermute(int);
int main(void) {
  int limit = 6;
  int *a;
  int k;
  for (k = 0; k < 7; k++) {
    a = rpermute(limit);
    printarray(limit, a);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    1189 <main+0x59>
mov    -0x8(%rbp),%edi
call   1040 <rpermute@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <printarray@plt>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x6,%edi
call   1040 <rpermute@plt>
mov    $0x6,%edi
mov    %rax,%rsi
call   1050 <printarray@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32 6, i32* %2
store i32 0, i32* %4
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 7
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = call i32* @rpermute(i32 %9)
store i32* %10, i32** %3
%11 = load i32, i32* %2
%12 = load i32*, i32** %3
%13 = call i32 @printarray(i32 %11, i32* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %8
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %5
18: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @rpermute(i32 6)
%2 = tail call i32 @printarray(i32 6, i32* %1)
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32* @rpermute(i32 6)
%5 = tail call i32 @printarray(i32 6, i32* %4)
%6 = tail call i32 @putchar(i32 10)
%7 = tail call i32* @rpermute(i32 6)
%8 = tail call i32 @printarray(i32 6, i32* %7)
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32* @rpermute(i32 6)
%11 = tail call i32 @printarray(i32 6, i32* %10)
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i32* @rpermute(i32 6)
%14 = tail call i32 @printarray(i32 6, i32* %13)
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32* @rpermute(i32 6)
%17 = tail call i32 @printarray(i32 6, i32* %16)
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32* @rpermute(i32 6)
%20 = tail call i32 @printarray(i32 6, i32* %19)
%21 = tail call i32 @putchar(i32 10)
ret i32 0
}