#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*/ list3;
typedef int /*<<< orphan*/ list2;
typedef int /*<<< orphan*/ list1;

/* Variables and functions */
int /*<<< orphan*/ perm(int *, int, int);
int /*<<< orphan*/ perm2(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ puts(char *);
int main(int argc, const char *argv[]) {
  int list1[] = {1};
  int size = ((int)sizeof(list1) / sizeof(int));
  puts("list1");
  perm(list1, 0, size - 1);
  perm2(list1, 0, size - 1);
  puts("list2");
  int list2[] = {1, 2};
  size = ((int)sizeof(list2) / sizeof(int));
  perm(list2, 0, size - 1);
  perm2(list2, 0, size - 1);
  puts("other test");
  perm(list2, 1, 1);
  perm(list2, 1, 0);
  puts("list3");
  int list3[] = {0, 1, 3, 5};
  size = ((int)sizeof(list3) / sizeof(int));
  perm(list3, 0, size - 1);
  perm2(list3, 0, size - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb4(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
lea    -0x14(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <perm@plt>
lea    -0x14(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <perm2@plt>
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
mov    0xe8d(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x2,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <perm@plt>
lea    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <perm2@plt>
lea    0xe45(%rip),%rdi
call   1040 <puts@plt>
lea    -0x20(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <perm@plt>
lea    -0x20(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <perm@plt>
lea    0xe24(%rip),%rdi
call   1040 <puts@plt>
mov    0xe2d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe2a(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x4,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <perm@plt>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <perm2@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x1,0x4(%rsp)
lea    0xebc(%rip),%rdi
call   1040 <puts@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <perm@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <perm2@plt>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
movabs $0x200000001,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <perm@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <perm2@plt>
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <perm@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <perm@plt>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
movaps 0xe3c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <perm@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <perm2@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.list1 = [1 x i32] [i32 1]
@.str = [6 x i8] c"list1\00"
@.str.1 = [6 x i8] c"list2\00"
@__const.main.list2 = [2 x i32] [i32 1, i32 2]
@.str.2 = [11 x i8] c"other test\00"
@.str.3 = [6 x i8] c"list3\00"
@__const.main.list3 = [4 x i32] [i32 0, i32 1, i32 3, i32 5]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1 x i32]
%7 = alloca i32
%8 = alloca [2 x i32]
%9 = alloca [4 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [1 x i32]* %6 to i8*
store i32 1, i32* %7
%11 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%13 = load i32, i32* %7
%14 = sub nsw i32 %13, 1
%15 = call i32 @perm(i32* %12, i32 0, i32 %14)
%16 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%17 = load i32, i32* %7
%18 = sub nsw i32 %17, 1
%19 = call i32 @perm2(i32* %16, i32 0, i32 %18)
%20 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%21 = bitcast [2 x i32]* %8 to i8*
store i32 2, i32* %7
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%23 = load i32, i32* %7
%24 = sub nsw i32 %23, 1
%25 = call i32 @perm(i32* %22, i32 0, i32 %24)
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 1
%29 = call i32 @perm2(i32* %26, i32 0, i32 %28)
%30 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%32 = call i32 @perm(i32* %31, i32 1, i32 1)
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%34 = call i32 @perm(i32* %33, i32 1, i32 0)
%35 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%36 = bitcast [4 x i32]* %9 to i8*
store i32 4, i32* %7
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%38 = load i32, i32* %7
%39 = sub nsw i32 %38, 1
%40 = call i32 @perm(i32* %37, i32 0, i32 %39)
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%42 = load i32, i32* %7
%43 = sub nsw i32 %42, 1
%44 = call i32 @perm2(i32* %41, i32 0, i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"list1\00"
@.str.1 = [6 x i8] c"list2\00"
@.str.2 = [11 x i8] c"other test\00"
@.str.3 = [6 x i8] c"list3\00"
@__const.main.list3 = [4 x i32] [i32 0, i32 1, i32 3, i32 5]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1 x i32]
%4 = alloca i64
%5 = alloca [4 x i32]
%6 = bitcast [1 x i32]* %3 to i8*
%7 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
store i32 1, i32* %7
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @perm(i32* %7, i32 0, i32 0)
%10 = call i32 @perm2(i32* %7, i32 0, i32 0)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = bitcast i64* %4 to i8*
store i64 8589934593, i64* %4
%13 = bitcast i64* %4 to i32*
%14 = call i32 @perm(i32* %13, i32 0, i32 1)
%15 = call i32 @perm2(i32* %13, i32 0, i32 1)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @perm(i32* %13, i32 1, i32 1)
%18 = call i32 @perm(i32* %13, i32 1, i32 0)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%20 = bitcast [4 x i32]* %5 to i8*
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%22 = call i32 @perm(i32* %21, i32 0, i32 3)
%23 = call i32 @perm2(i32* %21, i32 0, i32 3)
ret i32 0
}