#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 scalar_t__ clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ permute(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i = 0, len = 0;
  clock_t start, stop;
  float diff = 0.0;
  printf("How many digits would you like to input?\n");
  scanf("%d", &len);
  int list[len];
  printf("Please enter the digits.\n");
  for (i = 0; i < len; i++)
    scanf("%d", &list[i]);
  printf("The permutations are as follows:\n");
  start = clock();
  permute(list, 0, len - 1);
  stop = clock();
  diff = ((float)stop - (float)start) / CLOCKS_PER_SEC;
  printf("Time taken to compute the permutations was %f seconds.\n", diff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f3 <main+0xb3>
mov    -0x40(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4a(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11be <main+0x7e>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <permute@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
cvtsi2ssq -0x20(%rbp),%xmm0
cvtsi2ssq -0x18(%rbp),%xmm1
subss  %xmm1,%xmm0
mov    0x2da9(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,-0x2c(%rbp)
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11dc <main+0x8c>
xor    %r13d,%r13d
lea    0xe48(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11c0 <main+0x70>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbx
mov    -0x2c(%rbp),%edx
add    $0xffffffff,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <permute@plt>
xor    %eax,%eax
call   1050 <clock@plt>
cvtsi2ss %rax,%xmm0
cvtsi2ss %rbx,%xmm1
subss  %xmm1,%xmm0
mov    0x2dca(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdd6(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"How many digits would you like to input?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Please enter the digits.\0A\00"
@.str.3 = [34 x i8] c"The permutations are as follows:\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.4 = [56 x i8] c"Time taken to compute the permutations was %f seconds.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca float
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store float 0.000000e+00, float* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i32, i64 %12
store i64 %12, i64* %8
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %16
16: ; preds = %25, %0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %14, i64 %22
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %16
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%30 = call i64 (...) @clock()
store i64 %30, i64* %4
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
%33 = call i32 @permute(i32* %14, i32 0, i32 %32)
%34 = call i64 (...) @clock()
store i64 %34, i64* %5
%35 = load i64, i64* %5
%36 = sitofp i64 %35 to float
%37 = load i64, i64* %4
%38 = sitofp i64 %37 to float
%39 = fsub float %36, %38
%40 = load float, float* @CLOCKS_PER_SEC
%41 = fdiv float %39, %40
store float %41, float* %6
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), double %43)
store i32 0, i32* %1
%45 = load i8*, i8** %7
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.4 = [56 x i8] c"Time taken to compute the permutations was %f seconds.\0A\00"
@str = [41 x i8] c"How many digits would you like to input?\00"
@str.5 = [25 x i8] c"Please enter the digits.\00"
@str.6 = [33 x i8] c"The permutations are as follows:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.5, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds i32, i32* %8, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.6, i64 0, i64 0))
%22 = call i64 (...) @clock()
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
%25 = call i32 @permute(i32* %8, i32 0, i32 %24)
%26 = call i64 (...) @clock()
%27 = sitofp i64 %26 to float
%28 = sitofp i64 %22 to float
%29 = fsub float %27, %28
%30 = load float, float* @CLOCKS_PER_SEC
%31 = fdiv float %29, %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), double %32)
ret i32 0
}