#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 int /*<<< orphan*/ digits;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ permute_norepeat(char const *, char *, char *, int const,
                                    int /*<<< orphan*/, int *);
int main(void) {
  const char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
  const int len = sizeof(digits) / sizeof(digits[0]);
  char buf[sizeof(digits) + 1], taken[sizeof(digits)];
  memset(buf, 0, sizeof(digits) + 1);
  memset(taken, 0, sizeof(digits));
  int count = 0;
  permute_norepeat(digits, taken, buf, len, 0, &count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0x6(%rbp)
movl   $0xa,-0x14(%rbp)
lea    -0x1f(%rbp),%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1040 <memset@plt>
lea    -0x29(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,-0x30(%rbp)
lea    -0xe(%rbp),%rdi
lea    -0x29(%rbp),%rsi
lea    -0x1f(%rbp),%rdx
mov    $0xa,%ecx
xor    %r8d,%r8d
lea    -0x30(%rbp),%r9
call   1030 <permute_norepeat@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,0x8(%rsp)
movw   $0x3938,0x10(%rsp)
lea    0x1d(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xb,%edx
call   1040 <memset@plt>
lea    0x13(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,0x4(%rsp)
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%r9
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0xa,%ecx
xor    %r8d,%r8d
call   1030 <permute_norepeat@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.digits = [10 x i8] c"0123456789"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = alloca [10 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [10 x i8]* %2 to i8*
store i32 10, i32* %3
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 11)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 10)
store i32 0, i32* %6
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%15 = call i32 @permute_norepeat(i8* %12, i8* %13, i8* %14, i32 10, i32 0, i32* %6)
ret i32 0
}

LLVM IR (-O2):
@__const.main.digits = [10 x i8] c"0123456789"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [11 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = call i32 @memset(i8* %6, i32 0, i32 11)
%9 = call i32 @memset(i8* %7, i32 0, i32 10)
%10 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%11 = call i32 @permute_norepeat(i8* %5, i8* %7, i8* %6, i32 10, i32 0, i32* %4)
ret i32 0
}