#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 *);
int /*<<< orphan*/ inverse(int *, int *, int);
int isid(int *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ one_schreier_orbit(int, int *, int, int, int *, int *, int *,
                                      int *, int);
int onpoints(int, int *, int);
scalar_t__ position(int, int *, int);
int /*<<< orphan*/ product(int *, int *, int *, int);
int /*<<< orphan*/ stabilizer(int *, int, int *, int, int, int *, int *);
int /*<<< orphan*/ trace_schreier(int, int *, int *, int *, int);
int perm_member(int *p, int *base, int bl, int *GS, int m, int n) {
  if (bl == 0)
    return (isid(p, n));
  else {
    int *pp = (int *)malloc(n * sizeof(int));
    int *ip = (int *)malloc(n * sizeof(int));
    int *orbit = (int *)malloc(n * sizeof(int)), ol;
    int *w = (int *)malloc(n * sizeof(int));
    int *nu = (int *)malloc(n * n * sizeof(int));
    int *stab = (int *)malloc(m * n * sizeof(int)), sl;
    int point, ret;
    one_schreier_orbit(base[0], GS, m, n, orbit, &ol, nu, w, 1);
    point = onpoints(base[0], p, n);
    if (position(point, orbit, ol)) {
      trace_schreier(point, nu, w, pp, n);
      inverse(pp, ip, n);
      product(p, ip, pp, n);
      stabilizer(base, 1, GS, m, n, stab, &sl);
      ret = perm_member(pp, base + 1, bl - 1, stab, sl, n);
    } else
      ret = 0;
    free(pp);
    free(ip);
    free(orbit);
    free(w);
    free(nu);
    free(stab);
    return (ret);
  }
}


x86 assembly (clang, -O0):
<perm_member>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11f0 <perm_member+0x40>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   10c0 <isid@plt>
mov    %eax,-0x4(%rbp)
jmp    139f <perm_member+0x1ef>
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x48(%rbp),%r8
mov    -0x60(%rbp),%r10
mov    -0x58(%rbp),%rax
lea    -0x4c(%rbp),%r9
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
movl   $0x1,0x10(%rsp)
call   10b0 <one_schreier_orbit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   10d0 <onpoints@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x4c(%rbp),%edx
call   1040 <position@plt>
cmp    $0x0,%rax
je     135c <perm_member+0x1ac>
mov    -0x70(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8d
call   1050 <trace_schreier@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   1080 <inverse@plt>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%ecx
call   1070 <product@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x68(%rbp),%r9
mov    $0x1,%esi
lea    -0x6c(%rbp),%rax
mov    %rax,(%rsp)
call   10a0 <stabilizer@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x4,%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
mov    -0x68(%rbp),%rcx
mov    -0x6c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1090 <perm_member@plt>
mov    %eax,-0x74(%rbp)
jmp    1363 <perm_member+0x1b3>
movl   $0x0,-0x74(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perm_member>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9d,%ebx
mov    %rcx,0x38(%rsp)
test   %edx,%edx
je     1342 <perm_member+0x192>
mov    %r8d,%r14d
mov    %rsi,%r15
mov    %edx,0x10(%rsp)
mov    %rdi,0x48(%rsp)
lea    0x0(,%rbx,4),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
imul   %ebx,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %r14d,%edi
imul   %ebx,%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    (%r15),%edi
sub    $0x8,%rsp
lea    0x24(%rsp),%r9
mov    0x40(%rsp),%rsi
mov    %r14d,0x1c(%rsp)
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %r12,%r8
push   $0x1
mov    %r13,0x18(%rsp)
push   %r13
mov    %rbp,%rax
mov    0x60(%rsp),%rbp
mov    %rax,%r13
push   %rax
call   10b0 <one_schreier_orbit@plt>
add    $0x20,%rsp
mov    (%r15),%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   10d0 <onpoints@plt>
mov    %eax,%r14d
mov    0x1c(%rsp),%edx
mov    %eax,%edi
mov    %r12,0x50(%rsp)
mov    %r12,%rsi
call   1040 <position@plt>
test   %rax,%rax
je     1357 <perm_member+0x1a7>
mov    %r14d,%edi
mov    %r13,%rsi
mov    %r13,0x40(%rsp)
mov    0x8(%rsp),%rdx
mov    %rbp,%r14
mov    0x30(%rsp),%rbp
mov    %rbp,%rcx
mov    %ebx,%r8d
call   1050 <trace_schreier@plt>
mov    %rbp,%rdi
mov    0x28(%rsp),%r13
mov    %r13,%rsi
mov    %ebx,%edx
call   1080 <inverse@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %ebx,%ecx
call   1070 <product@plt>
sub    $0x8,%rsp
lea    0x20(%rsp),%rax
mov    %r15,%rdi
mov    $0x1,%esi
mov    0x40(%rsp),%rdx
mov    0x1c(%rsp),%ecx
mov    %ebx,%r8d
mov    0x28(%rsp),%r12
mov    %r12,%r9
push   %rax
call   10a0 <stabilizer@plt>
add    $0x10,%rsp
add    $0x4,%r15
mov    0x10(%rsp),%edx
add    $0xffffffff,%edx
mov    0x18(%rsp),%r8d
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r12,%rcx
mov    %ebx,%r9d
call   1090 <perm_member@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
mov    %r13,%rbp
mov    0x8(%rsp),%rbx
mov    0x40(%rsp),%r15
jmp    1371 <perm_member+0x1c1>
mov    %ebx,%esi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <isid@plt>
xor    %r14d,%r14d
mov    0x30(%rsp),%rdi
mov    0x28(%rsp),%rbp
mov    0x8(%rsp),%rbx
mov    %r13,%r15
mov    0x20(%rsp),%r12
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x50(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @perm_member(i32* %0, i32* %1, i32 %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32 %2, i32* %10
store i32* %3, i32** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%24 = load i32, i32* %10
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %6
%27 = load i32*, i32** %8
%28 = load i32, i32* %13
%29 = call i32 @isid(i32* %27, i32 %28)
store i32 %29, i32* %7
br label %138
30: ; preds = %6
%31 = load i32, i32* %13
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 4
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to i32*
store i32* %36, i32** %14
%37 = load i32, i32* %13
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 4
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to i32*
store i32* %42, i32** %15
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 4
%46 = trunc i64 %45 to i32
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to i32*
store i32* %48, i32** %16
%49 = load i32, i32* %13
%50 = sext i32 %49 to i64
%51 = mul i64 %50, 4
%52 = trunc i64 %51 to i32
%53 = call i64 @malloc(i32 %52)
%54 = inttoptr i64 %53 to i32*
store i32* %54, i32** %18
%55 = load i32, i32* %13
%56 = load i32, i32* %13
%57 = mul nsw i32 %55, %56
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 4
%60 = trunc i64 %59 to i32
%61 = call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to i32*
store i32* %62, i32** %19
%63 = load i32, i32* %12
%64 = load i32, i32* %13
%65 = mul nsw i32 %63, %64
%66 = sext i32 %65 to i64
%67 = mul i64 %66, 4
%68 = trunc i64 %67 to i32
%69 = call i64 @malloc(i32 %68)
%70 = inttoptr i64 %69 to i32*
store i32* %70, i32** %20
%71 = load i32*, i32** %9
%72 = getelementptr inbounds i32, i32* %71, i64 0
%73 = load i32, i32* %72
%74 = load i32*, i32** %11
%75 = load i32, i32* %12
%76 = load i32, i32* %13
%77 = load i32*, i32** %16
%78 = load i32*, i32** %19
%79 = load i32*, i32** %18
%80 = call i32 @one_schreier_orbit(i32 %73, i32* %74, i32 %75, i32 %76, i32* %77, i32* %17, i32* %78, i32* %79, i32 1)
%81 = load i32*, i32** %9
%82 = getelementptr inbounds i32, i32* %81, i64 0
%83 = load i32, i32* %82
%84 = load i32*, i32** %8
%85 = load i32, i32* %13
%86 = call i32 @onpoints(i32 %83, i32* %84, i32 %85)
store i32 %86, i32* %22
%87 = load i32, i32* %22
%88 = load i32*, i32** %16
%89 = load i32, i32* %17
%90 = call i64 @position(i32 %87, i32* %88, i32 %89)
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %123
92: ; preds = %30
%93 = load i32, i32* %22
%94 = load i32*, i32** %19
%95 = load i32*, i32** %18
%96 = load i32*, i32** %14
%97 = load i32, i32* %13
%98 = call i32 @trace_schreier(i32 %93, i32* %94, i32* %95, i32* %96, i32 %97)
%99 = load i32*, i32** %14
%100 = load i32*, i32** %15
%101 = load i32, i32* %13
%102 = call i32 @inverse(i32* %99, i32* %100, i32 %101)
%103 = load i32*, i32** %8
%104 = load i32*, i32** %15
%105 = load i32*, i32** %14
%106 = load i32, i32* %13
%107 = call i32 @product(i32* %103, i32* %104, i32* %105, i32 %106)
%108 = load i32*, i32** %9
%109 = load i32*, i32** %11
%110 = load i32, i32* %12
%111 = load i32, i32* %13
%112 = load i32*, i32** %20
%113 = call i32 @stabilizer(i32* %108, i32 1, i32* %109, i32 %110, i32 %111, i32* %112, i32* %21)
%114 = load i32*, i32** %14
%115 = load i32*, i32** %9
%116 = getelementptr inbounds i32, i32* %115, i64 1
%117 = load i32, i32* %10
%118 = sub nsw i32 %117, 1
%119 = load i32*, i32** %20
%120 = load i32, i32* %21
%121 = load i32, i32* %13
%122 = call i32 @perm_member(i32* %114, i32* %116, i32 %118, i32* %119, i32 %120, i32 %121)
store i32 %122, i32* %23
br label %124
123: ; preds = %30
store i32 0, i32* %23
br label %124
124: ; preds = %123, %92
%125 = load i32*, i32** %14
%126 = call i32 @free(i32* %125)
%127 = load i32*, i32** %15
%128 = call i32 @free(i32* %127)
%129 = load i32*, i32** %16
%130 = call i32 @free(i32* %129)
%131 = load i32*, i32** %18
%132 = call i32 @free(i32* %131)
%133 = load i32*, i32** %19
%134 = call i32 @free(i32* %133)
%135 = load i32*, i32** %20
%136 = call i32 @free(i32* %135)
%137 = load i32, i32* %23
store i32 %137, i32* %7
br label %138
138: ; preds = %124, %26
%139 = load i32, i32* %7
ret i32 %139
}

LLVM IR (-O2):
define i32 @perm_member(i32* %0, i32* %1, i32 %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = icmp eq i32 %2, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @isid(i32* %0, i32 %5)
br label %55
12: ; preds = %6
%13 = shl i32 %5, 2
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = tail call i64 @malloc(i32 %13)
%17 = inttoptr i64 %16 to i32*
%18 = tail call i64 @malloc(i32 %13)
%19 = inttoptr i64 %18 to i32*
%20 = bitcast i32* %7 to i8*
%21 = tail call i64 @malloc(i32 %13)
%22 = inttoptr i64 %21 to i32*
%23 = mul i32 %13, %5
%24 = tail call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to i32*
%26 = shl i32 %4, 2
%27 = mul i32 %26, %5
%28 = tail call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i32*
%30 = bitcast i32* %8 to i8*
%31 = load i32, i32* %1
%32 = call i32 @one_schreier_orbit(i32 %31, i32* %3, i32 %4, i32 %5, i32* %19, i32* %7, i32* %25, i32* %22, i32 1)
%33 = load i32, i32* %1
%34 = call i32 @onpoints(i32 %33, i32* %0, i32 %5)
%35 = load i32, i32* %7
%36 = call i64 @position(i32 %34, i32* %19, i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %47, label %38
38: ; preds = %12
%39 = call i32 @trace_schreier(i32 %34, i32* %25, i32* %22, i32* %15, i32 %5)
%40 = call i32 @inverse(i32* %15, i32* %17, i32 %5)
%41 = call i32 @product(i32* %0, i32* %17, i32* %15, i32 %5)
%42 = call i32 @stabilizer(i32* %1, i32 1, i32* %3, i32 %4, i32 %5, i32* %29, i32* %8)
%43 = getelementptr inbounds i32, i32* %1, i64 1
%44 = add nsw i32 %2, -1
%45 = load i32, i32* %8
%46 = call i32 @perm_member(i32* %15, i32* %43, i32 %44, i32* %29, i32 %45, i32 %5)
br label %47
47: ; preds = %12, %38
%48 = phi i32 [ %46, %38 ], [ 0, %12 ]
%49 = call i32 @free(i32* %15)
%50 = call i32 @free(i32* %17)
%51 = call i32 @free(i32* %19)
%52 = call i32 @free(i32* %22)
%53 = call i32 @free(i32* %25)
%54 = call i32 @free(i32* %29)
br label %55
55: ; preds = %47, %10
%56 = phi i32 [ %11, %10 ], [ %48, %47 ]
ret i32 %56
}