#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*/ in_set(int *, int, int);
int stub1(int *, int, char **);
void permute(int *set, int len, char **vals, int lev, int *currset,
             int (*func)(int *, int, char **)) {
  int i;
  if (lev == len) {
    (*func)(currset, len, vals);
    return;
  }
  for (i = 0; i < len; i++) {
    if (!in_set(currset, lev, i)) {
      currset[lev] = i;
      permute(set, len, vals, lev + 1, currset, func);
    }
  }
}


x86 assembly (clang, -O0):
<permute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1160 <permute+0x40>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   *%rax
jmp    11ca <permute+0xaa>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ca <permute+0xaa>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1040 <in_set@plt>
cmp    $0x0,%eax
jne    11b7 <permute+0x97>
mov    -0x34(%rbp),%edx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   1030 <permute@plt>
jmp    11bc <permute+0x9c>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1167 <permute+0x47>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permute>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %ecx,%r15d
mov    %rdx,%r14
cmp    %esi,%ecx
jne    1155 <permute+0x35>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    *%r9
mov    %esi,%ebp
mov    %rdi,0x8(%rsp)
mov    %r9,0x10(%rsp)
test   %esi,%esi
jle    11bf <permute+0x9f>
movslq %r15d,%rax
mov    %rax,(%rsp)
lea    0x1(%r15),%r13d
xor    %r12d,%r12d
jmp    1189 <permute+0x69>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12d
cmp    %r12d,%ebp
je     11bf <permute+0x9f>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r12d,%edx
call   1040 <in_set@plt>
test   %eax,%eax
jne    1180 <permute+0x60>
mov    (%rsp),%rax
mov    %r12d,(%rbx,%rax,4)
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %r13d,%ecx
mov    %rbx,%r8
mov    0x10(%rsp),%r9
call   1030 <permute@plt>
jmp    1180 <permute+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @permute(i32* %0, i32 %1, i8** %2, i32 %3, i32* %4, i32 (i32*, i32, i8**)* %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32 (i32*, i32, i8**)*
%13 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i8** %2, i8*** %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i32 (i32*, i32, i8**)* %5, i32 (i32*, i32, i8**)** %12
%14 = load i32, i32* %10
%15 = load i32, i32* %8
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %6
%18 = load i32 (i32*, i32, i8**)*, i32 (i32*, i32, i8**)** %12
%19 = load i32*, i32** %11
%20 = load i32, i32* %8
%21 = load i8**, i8*** %9
%22 = call i32 %18(i32* %19, i32 %20, i8** %21)
br label %51
23: ; preds = %6
store i32 0, i32* %13
br label %24
24: ; preds = %48, %23
%25 = load i32, i32* %13
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %51
28: ; preds = %24
%29 = load i32*, i32** %11
%30 = load i32, i32* %10
%31 = load i32, i32* %13
%32 = call i32 @in_set(i32* %29, i32 %30, i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %47, label %34
34: ; preds = %28
%35 = load i32, i32* %13
%36 = load i32*, i32** %11
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
store i32 %35, i32* %39
%40 = load i32*, i32** %7
%41 = load i32, i32* %8
%42 = load i8**, i8*** %9
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
%45 = load i32*, i32** %11
%46 = load i32 (i32*, i32, i8**)*, i32 (i32*, i32, i8**)** %12
br label %47
47: ; preds = %34, %28
br label %48
48: ; preds = %47
%49 = load i32, i32* %13
%50 = add nsw i32 %49, 1
store i32 %50, i32* %13
br label %24
51: ; preds = %17, %24
ret void
}

LLVM IR (-O2):
define void @permute(i32* nocapture readnone %0, i32 %1, i8** %2, i32 %3, i32* %4, i32 (i32*, i32, i8**)* nocapture %5) {
%7 = icmp eq i32 %3, %1
br i1 %7, label %14, label %8
8: ; preds = %6
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %24
10: ; preds = %8
%11 = sext i32 %3 to i64
%12 = getelementptr inbounds i32, i32* %4, i64 %11
%13 = add nsw i32 %3, 1
br label %16
14: ; preds = %6
%15 = tail call i32 %5(i32* %4, i32 %3, i8** %2)
br label %24
16: ; preds = %10, %21
%17 = phi i32 [ 0, %10 ], [ %22, %21 ]
%18 = tail call i32 @in_set(i32* %4, i32 %3, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 %17, i32* %12
tail call void @permute(i32* %0, i32 %1, i8** %2, i32 %13, i32* %4, i32 (i32*, i32, i8**)* %5)
br label %21
21: ; preds = %16, %20
%22 = add nuw nsw i32 %17, 1
%23 = icmp eq i32 %22, %1
br i1 %23, label %24, label %16
24: ; preds = %21, %8, %14
ret void
}