#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ product(int *, int *, int *, int);
int /*<<< orphan*/ range(int *, int);
void trace_schreier(int point, int *nu, int *w, int *perm, int n) {
  int i;
  int found = 0;
  int *newperm = (int *)malloc(n * sizeof(int));
  for (i = 0; i < n; i++) {
    if (*(w + point - 1) == 0) {
      range(perm, n);
      found = 1;
      break;
    }
  }
  if (!found) {
    trace_schreier(*(w + point - 1), nu, w, newperm, n);
    product(newperm, nu + (point - 1) * n, perm, n);
  }
  free(newperm);
}


x86 assembly (clang, -O0):
<trace_schreier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11d6 <trace_schreier+0x86>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
cmpl   $0x0,-0x4(%rax,%rcx,4)
jne    11c3 <trace_schreier+0x73>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <range@plt>
movl   $0x1,-0x2c(%rbp)
jmp    11d6 <trace_schreier+0x86>
jmp    11c8 <trace_schreier+0x78>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118c <trace_schreier+0x3c>
cmpl   $0x0,-0x2c(%rbp)
jne    1228 <trace_schreier+0xd8>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    -0x4(%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1040 <trace_schreier@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1060 <product@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trace_schreier>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%ebx
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%r12
mov    %edi,%ebp
lea    0x0(,%rbx,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
movslq %ebp,%rax
mov    -0x4(%r13,%rax,4),%edi
test   %ebx,%ebx
jle    1194 <trace_schreier+0x44>
test   %edi,%edi
jne    1194 <trace_schreier+0x44>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <range@plt>
jmp    11bf <trace_schreier+0x6f>
mov    %r12,%rsi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %ebx,%r8d
call   1040 <trace_schreier@plt>
add    $0xffffffff,%ebp
imul   %ebx,%ebp
movslq %ebp,%rax
lea    (%r12,%rax,4),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1060 <product@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @trace_schreier(i32 %0, i32* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i32 %0, i32* %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
store i32 0, i32* %12
%14 = load i32, i32* %10
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 4
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i32*
store i32* %19, i32** %13
store i32 0, i32* %11
br label %20
20: ; preds = %37, %5
%21 = load i32, i32* %11
%22 = load i32, i32* %10
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32*, i32** %8
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = getelementptr inbounds i32, i32* %28, i64 -1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %24
%33 = load i32*, i32** %9
%34 = load i32, i32* %10
%35 = call i32 @range(i32* %33, i32 %34)
store i32 1, i32* %12
br label %40
36: ; preds = %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %20
40: ; preds = %32, %20
%41 = load i32, i32* %12
%42 = icmp ne i32 %41, 0
br i1 %42, label %65, label %43
43: ; preds = %40
%44 = load i32*, i32** %8
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = getelementptr inbounds i32, i32* %47, i64 -1
%49 = load i32, i32* %48
%50 = load i32*, i32** %7
%51 = load i32*, i32** %8
%52 = load i32*, i32** %13
%53 = load i32, i32* %10
%54 = load i32*, i32** %13
%55 = load i32*, i32** %7
%56 = load i32, i32* %6
%57 = sub nsw i32 %56, 1
%58 = load i32, i32* %10
%59 = mul nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %55, i64 %60
%62 = load i32*, i32** %9
%63 = load i32, i32* %10
%64 = call i32 @product(i32* %54, i32* %61, i32* %62, i32 %63)
br label %65
65: ; preds = %43, %40
%66 = load i32*, i32** %13
%67 = call i32 @free(i32* %66)
ret void
}

LLVM IR (-O2):
define void @trace_schreier(i32 %0, i32* %1, i32* nocapture %2, i32* %3, i32 %4) {
%6 = shl i32 %4, 2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = icmp sgt i32 %4, 0
%10 = sext i32 %0 to i64
%11 = getelementptr inbounds i32, i32* %2, i64 %10
%12 = getelementptr inbounds i32, i32* %11, i64 -1
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
%15 = select i1 %9, i1 %14, i1 false
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = tail call i32 @range(i32* %3, i32 %4)
br label %24
18: ; preds = %5
tail call void @trace_schreier(i32 %13, i32* %1, i32* %2, i32* %8, i32 %4)
%19 = add nsw i32 %0, -1
%20 = mul nsw i32 %19, %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %1, i64 %21
%23 = tail call i32 @product(i32* %8, i32* %22, i32* %3, i32 %4)
br label %24
24: ; preds = %16, %18
%25 = tail call i32 @free(i32* %8)
ret void
}