#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 next_perm(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, i, j;
  int garbage;
  for (i = 0; i < 999999; i++) {
    garbage = next_perm(arr, 10);
    for (j = 0; i == 999998 && j < 10; j++) {
      printf("%d", arr[j]);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xf423f,-0x34(%rbp)
jge    11e3 <main+0xb3>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1040 <next_perm@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0xf423e,-0x34(%rbp)
mov    %al,-0x3d(%rbp)
jne    119c <main+0x6c>
cmpl   $0xa,-0x38(%rbp)
setl   %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    11ac <main+0x7c>
jmp    11d0 <main+0xa0>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1180 <main+0x50>
jmp    11d5 <main+0xa5>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <main+0x2b>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0xf423f,%ebp
mov    %rsp,%r14
lea    0xebe(%rip),%rbx
jmp    1179 <main+0x49>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     121b <main+0xeb>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <next_perm@plt>
cmp    $0x1,%ebp
jne    1170 <main+0x40>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.arr = [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
br label %14
14: ; preds = %0, %39
%15 = phi i32 [ 0, %0 ], [ %40, %39 ]
%16 = call i32 @next_perm(i32* %3, i32 10)
%17 = icmp eq i32 %15, 999998
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %7
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %8
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %9
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %10
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %11
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %12
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %13
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %18, %14
%40 = add nuw nsw i32 %15, 1
%41 = icmp eq i32 %40, 999999
br i1 %41, label %42, label %14
42: ; preds = %39
%43 = call i32 @putchar(i32 10)
ret i32 0
}