#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*/ assert(int);
int /*<<< orphan*/ perms(int *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  printf("%s", "Enter the number n: ");
  int n = 0;
  scanf("%d", &n);
  assert(n > 0);
  int array[n];
  for (int i = 0; i < n; ++i) {
    array[i] = i;
  }
  perms(array, n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
lea    0xea8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
test   %eax,%eax
setg   %al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11df <main+0x9f>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%edx
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b7 <main+0x77>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <perms@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf3e(%rip),%rdi
lea    0xf3a(%rip),%rsi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
lea    0xf3c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
xor    %edi,%edi
cmpl   $0x0,-0x14(%rbp)
setg   %dil
call   1040 <assert@plt>
mov    %rsp,%r14
mov    -0x14(%rbp),%eax
mov    %rsp,%rdi
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdi
mov    %rdi,%rsp
mov    -0x14(%rbp),%esi
test   %esi,%esi
jle    131c <main+0x1dc>
cmp    $0x8,%esi
jae    11b6 <main+0x76>
xor    %eax,%eax
jmp    1310 <main+0x1d0>
mov    %esi,%eax
and    $0xfffffff8,%eax
lea    -0x8(%rax),%rbx
mov    %rbx,%rdx
shr    $0x3,%rdx
add    $0x1,%rdx
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0x18,%rbx
jae    11e4 <main+0xa4>
movdqa 0xe23(%rip),%xmm0
xor    %ebx,%ebx
jmp    12b8 <main+0x178>
and    $0xfffffffffffffffc,%rdx
movdqa 0xe10(%rip),%xmm0
xor    %ebx,%ebx
movdqa 0xe15(%rip),%xmm8
movdqa 0xe1c(%rip),%xmm9
movdqa 0xe23(%rip),%xmm10
movdqa 0xe2b(%rip),%xmm4
movdqa 0xe33(%rip),%xmm5
movdqa 0xe3b(%rip),%xmm6
movdqa 0xe43(%rip),%xmm7
movdqa 0xe4b(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqa %xmm0,(%rdi,%rbx,4)
movdqa %xmm2,0x10(%rdi,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqa %xmm2,0x20(%rdi,%rbx,4)
movdqa %xmm3,0x30(%rdi,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqa %xmm2,0x40(%rdi,%rbx,4)
movdqa %xmm3,0x50(%rdi,%rbx,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqa %xmm2,0x60(%rdi,%rbx,4)
movdqa %xmm3,0x70(%rdi,%rbx,4)
add    $0x20,%rbx
paddd  %xmm1,%xmm0
add    $0xfffffffffffffffc,%rdx
jne    1240 <main+0x100>
test   %rcx,%rcx
je     1300 <main+0x1c0>
lea    (%rdi,%rbx,4),%rdx
add    $0x10,%rdx
shl    $0x5,%rcx
xor    %ebx,%ebx
movdqa 0xd3d(%rip),%xmm1
movdqa 0xd45(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm3
paddd  %xmm1,%xmm3
movdqa %xmm0,-0x10(%rdx,%rbx,1)
movdqa %xmm3,(%rdx,%rbx,1)
paddd  %xmm2,%xmm0
add    $0x20,%rbx
cmp    %rbx,%rcx
jne    12e0 <main+0x1a0>
cmp    %rsi,%rax
je     131c <main+0x1dc>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,(%rdi,%rax,4)
add    $0x1,%rax
cmp    %rax,%rsi
jne    1310 <main+0x1d0>
call   1060 <perms@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [21 x i8] c"Enter the number n: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %1
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
%12 = alloca i32, i64 %10
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %82
15: ; preds = %0
%16 = zext i32 %13 to i64
%17 = icmp ult i32 %13, 8
br i1 %17, label %80, label %18
18: ; preds = %15
%19 = and i64 %16, 4294967288
%20 = add nsw i64 %19, -8
%21 = lshr exact i64 %20, 3
%22 = add nuw nsw i64 %21, 1
%23 = and i64 %22, 3
%24 = icmp ult i64 %20, 24
br i1 %24, label %61, label %25
25: ; preds = %18
%26 = and i64 %22, 4611686018427387900
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ 0, %25 ], [ %57, %27 ]
%29 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %25 ], [ %58, %27 ]
%30 = phi i64 [ 0, %25 ], [ %59, %27 ]
%31 = add <4 x i32> %29, <i32 4, i32 4, i32 4, i32 4>
%32 = getelementptr inbounds i32, i32* %12, i64 %28
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %33
%34 = getelementptr inbounds i32, i32* %32, i64 4
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %35
%36 = or i64 %28, 8
%37 = add <4 x i32> %29, <i32 8, i32 8, i32 8, i32 8>
%38 = add <4 x i32> %29, <i32 12, i32 12, i32 12, i32 12>
%39 = getelementptr inbounds i32, i32* %12, i64 %36
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> %37, <4 x i32>* %40
%41 = getelementptr inbounds i32, i32* %39, i64 4
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> %38, <4 x i32>* %42
%43 = or i64 %28, 16
%44 = add <4 x i32> %29, <i32 16, i32 16, i32 16, i32 16>
%45 = add <4 x i32> %29, <i32 20, i32 20, i32 20, i32 20>
%46 = getelementptr inbounds i32, i32* %12, i64 %43
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> %44, <4 x i32>* %47
%48 = getelementptr inbounds i32, i32* %46, i64 4
%49 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> %45, <4 x i32>* %49
%50 = or i64 %28, 24
%51 = add <4 x i32> %29, <i32 24, i32 24, i32 24, i32 24>
%52 = add <4 x i32> %29, <i32 28, i32 28, i32 28, i32 28>
%53 = getelementptr inbounds i32, i32* %12, i64 %50
%54 = bitcast i32* %53 to <4 x i32>*
store <4 x i32> %51, <4 x i32>* %54
%55 = getelementptr inbounds i32, i32* %53, i64 4
%56 = bitcast i32* %55 to <4 x i32>*
store <4 x i32> %52, <4 x i32>* %56
%57 = add nuw i64 %28, 32
%58 = add <4 x i32> %29, <i32 32, i32 32, i32 32, i32 32>
%59 = add i64 %30, 4
%60 = icmp eq i64 %59, %26
br i1 %60, label %61, label %27
61: ; preds = %27, %18
%62 = phi i64 [ 0, %18 ], [ %57, %27 ]
%63 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %18 ], [ %58, %27 ]
%64 = icmp eq i64 %23, 0
br i1 %64, label %78, label %65
65: ; preds = %61, %65
%66 = phi i64 [ %74, %65 ], [ %62, %61 ]
%67 = phi <4 x i32> [ %75, %65 ], [ %63, %61 ]
%68 = phi i64 [ %76, %65 ], [ 0, %61 ]
%69 = add <4 x i32> %67, <i32 4, i32 4, i32 4, i32 4>
%70 = getelementptr inbounds i32, i32* %12, i64 %66
%71 = bitcast i32* %70 to <4 x i32>*
store <4 x i32> %67, <4 x i32>* %71
%72 = getelementptr inbounds i32, i32* %70, i64 4
%73 = bitcast i32* %72 to <4 x i32>*
store <4 x i32> %69, <4 x i32>* %73
%74 = add nuw i64 %66, 8
%75 = add <4 x i32> %67, <i32 8, i32 8, i32 8, i32 8>
%76 = add i64 %68, 1
%77 = icmp eq i64 %76, %23
br i1 %77, label %78, label %65
78: ; preds = %65, %61
%79 = icmp eq i64 %19, %16
br i1 %79, label %82, label %80
80: ; preds = %15, %78
%81 = phi i64 [ 0, %15 ], [ %19, %78 ]
br label %84
82: ; preds = %84, %78, %0
%83 = call i32 @perms(i32* %12, i32 %13)
ret i32 0
84: ; preds = %80, %84
%85 = phi i64 [ %88, %84 ], [ %81, %80 ]
%86 = getelementptr inbounds i32, i32* %12, i64 %85
%87 = trunc i64 %85 to i32
store i32 %87, i32* %86
%88 = add nuw nsw i64 %85, 1
%89 = icmp eq i64 %88, %16
br i1 %89, label %82, label %84
}