#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 */
unsigned long long perm(unsigned char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(void) {
  unsigned char A[10];
  unsigned char i;
  unsigned long long x;
  for (i = 0; i < 10; ++i) {
    A[i] = i;
  }
  x = perm(A, 0);
  printf("SUM: %llu\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0xf(%rbp)
movzbl -0xf(%rbp),%eax
cmp    $0xa,%eax
jge    1158 <main+0x38>
mov    -0xf(%rbp),%cl
movzbl -0xf(%rbp),%eax
mov    %cl,-0xe(%rbp,%rax,1)
mov    -0xf(%rbp),%al
add    $0x1,%al
mov    %al,-0xf(%rbp)
jmp    1133 <main+0x13>
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
call   1040 <perm@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0x706050403020100,%rax
05 06 07
mov    %rax,0xe(%rsp)
movw   $0x908,0x16(%rsp)
lea    0xe(%rsp),%rdi
xor    %esi,%esi
call   1040 <perm@plt>
lea    0xeb3(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"SUM: %llu\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
store i8 1, i8* %3
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
store i8 2, i8* %4
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 3
store i8 3, i8* %5
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
store i8 4, i8* %6
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
store i8 5, i8* %7
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 6
store i8 6, i8* %8
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 7
store i8 7, i8* %9
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 8
store i8 8, i8* %10
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 9
store i8 9, i8* %11
%12 = call i64 @perm(i8* %2, i32 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %12)
ret i32 0
}