#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 || m == 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)
je     11e6 <perm_member+0x36>
cmpl   $0x0,-0x2c(%rbp)
jne    11fa <perm_member+0x4a>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   10c0 <isid@plt>
mov    %eax,-0x4(%rbp)
jmp    13a9 <perm_member+0x1f9>
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     1366 <perm_member+0x1b6>
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    136d <perm_member+0x1bd>
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
test   %edx,%edx
je     134b <perm_member+0x19b>
mov    %r8d,%r12d
test   %r8d,%r8d
je     134b <perm_member+0x19b>
mov    %rsi,%r13
mov    %edx,0x14(%rsp)
lea    0x0(,%rbx,4),%ebp
mov    %rdi,0x40(%rsp)
mov    %ebp,%edi
mov    %rcx,0x50(%rsp)
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,%r15
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
imul   %ebx,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %r12d,%edi
imul   %ebx,%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    0x0(%r13),%edi
sub    $0x8,%rsp
lea    0x24(%rsp),%r9
mov    %r12d,%edx
mov    0x58(%rsp),%r12
mov    %r12,%rsi
mov    %edx,0x18(%rsp)
mov    %ebx,%ecx
mov    %r15,%r8
push   $0x1
mov    %r14,0x18(%rsp)
push   %r14
push   %rbp
call   10b0 <one_schreier_orbit@plt>
add    $0x20,%rsp
mov    %r13,0x48(%rsp)
mov    0x0(%r13),%edi
mov    0x40(%rsp),%rsi
mov    %ebx,%edx
call   10d0 <onpoints@plt>
mov    %eax,%r14d
mov    0x1c(%rsp),%edx
mov    %eax,%edi
mov    %r15,0x38(%rsp)
mov    %r15,%rsi
call   1040 <position@plt>
test   %rax,%rax
je     1360 <perm_member+0x1b0>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    0x8(%rsp),%rdx
mov    %rbp,%r13
mov    0x30(%rsp),%r14
mov    %r14,%rcx
mov    %ebx,%r8d
call   1050 <trace_schreier@plt>
mov    %r14,%rdi
mov    0x28(%rsp),%r15
mov    %r15,%rsi
mov    %ebx,%edx
call   1080 <inverse@plt>
mov    0x40(%rsp),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1070 <product@plt>
sub    $0x8,%rsp
lea    0x20(%rsp),%rax
mov    0x50(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    0x18(%rsp),%ecx
mov    %ebx,%r8d
mov    0x28(%rsp),%r12
mov    %r12,%r9
push   %rax
call   10a0 <stabilizer@plt>
add    $0x10,%rsp
add    $0x4,%rbp
mov    0x14(%rsp),%edx
add    $0xffffffff,%edx
mov    0x18(%rsp),%r8d
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12,%rcx
mov    %ebx,%r9d
call   1090 <perm_member@plt>
mov    %r14,%rdi
mov    %eax,%r14d
mov    %r15,%rbp
mov    0x38(%rsp),%rbx
mov    0x8(%rsp),%r15
jmp    137f <perm_member+0x1cf>
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    %rbp,%r13
mov    0x28(%rsp),%rbp
mov    0x38(%rsp),%rbx
mov    0x8(%rsp),%r15
mov    0x20(%rsp),%r12
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r13,%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 %29, label %26
26: ; preds = %6
%27 = load i32, i32* %12
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26, %6
%30 = load i32*, i32** %8
%31 = load i32, i32* %13
%32 = call i32 @isid(i32* %30, i32 %31)
store i32 %32, i32* %7
br label %141
33: ; preds = %26
%34 = load i32, i32* %13
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 4
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to i32*
store i32* %39, i32** %14
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 4
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i32*
store i32* %45, i32** %15
%46 = load i32, i32* %13
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 4
%49 = trunc i64 %48 to i32
%50 = call i64 @malloc(i32 %49)
%51 = inttoptr i64 %50 to i32*
store i32* %51, i32** %16
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 4
%55 = trunc i64 %54 to i32
%56 = call i64 @malloc(i32 %55)
%57 = inttoptr i64 %56 to i32*
store i32* %57, i32** %18
%58 = load i32, i32* %13
%59 = load i32, i32* %13
%60 = mul nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = mul i64 %61, 4
%63 = trunc i64 %62 to i32
%64 = call i64 @malloc(i32 %63)
%65 = inttoptr i64 %64 to i32*
store i32* %65, i32** %19
%66 = load i32, i32* %12
%67 = load i32, i32* %13
%68 = mul nsw i32 %66, %67
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 4
%71 = trunc i64 %70 to i32
%72 = call i64 @malloc(i32 %71)
%73 = inttoptr i64 %72 to i32*
store i32* %73, i32** %20
%74 = load i32*, i32** %9
%75 = getelementptr inbounds i32, i32* %74, i64 0
%76 = load i32, i32* %75
%77 = load i32*, i32** %11
%78 = load i32, i32* %12
%79 = load i32, i32* %13
%80 = load i32*, i32** %16
%81 = load i32*, i32** %19
%82 = load i32*, i32** %18
%83 = call i32 @one_schreier_orbit(i32 %76, i32* %77, i32 %78, i32 %79, i32* %80, i32* %17, i32* %81, i32* %82, i32 1)
%84 = load i32*, i32** %9
%85 = getelementptr inbounds i32, i32* %84, i64 0
%86 = load i32, i32* %85
%87 = load i32*, i32** %8
%88 = load i32, i32* %13
%89 = call i32 @onpoints(i32 %86, i32* %87, i32 %88)
store i32 %89, i32* %22
%90 = load i32, i32* %22
%91 = load i32*, i32** %16
%92 = load i32, i32* %17
%93 = call i64 @position(i32 %90, i32* %91, i32 %92)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %126
95: ; preds = %33
%96 = load i32, i32* %22
%97 = load i32*, i32** %19
%98 = load i32*, i32** %18
%99 = load i32*, i32** %14
%100 = load i32, i32* %13
%101 = call i32 @trace_schreier(i32 %96, i32* %97, i32* %98, i32* %99, i32 %100)
%102 = load i32*, i32** %14
%103 = load i32*, i32** %15
%104 = load i32, i32* %13
%105 = call i32 @inverse(i32* %102, i32* %103, i32 %104)
%106 = load i32*, i32** %8
%107 = load i32*, i32** %15
%108 = load i32*, i32** %14
%109 = load i32, i32* %13
%110 = call i32 @product(i32* %106, i32* %107, i32* %108, i32 %109)
%111 = load i32*, i32** %9
%112 = load i32*, i32** %11
%113 = load i32, i32* %12
%114 = load i32, i32* %13
%115 = load i32*, i32** %20
%116 = call i32 @stabilizer(i32* %111, i32 1, i32* %112, i32 %113, i32 %114, i32* %115, i32* %21)
%117 = load i32*, i32** %14
%118 = load i32*, i32** %9
%119 = getelementptr inbounds i32, i32* %118, i64 1
%120 = load i32, i32* %10
%121 = sub nsw i32 %120, 1
%122 = load i32*, i32** %20
%123 = load i32, i32* %21
%124 = load i32, i32* %13
%125 = call i32 @perm_member(i32* %117, i32* %119, i32 %121, i32* %122, i32 %123, i32 %124)
store i32 %125, i32* %23
br label %127
126: ; preds = %33
store i32 0, i32* %23
br label %127
127: ; preds = %126, %95
%128 = load i32*, i32** %14
%129 = call i32 @free(i32* %128)
%130 = load i32*, i32** %15
%131 = call i32 @free(i32* %130)
%132 = load i32*, i32** %16
%133 = call i32 @free(i32* %132)
%134 = load i32*, i32** %18
%135 = call i32 @free(i32* %134)
%136 = load i32*, i32** %19
%137 = call i32 @free(i32* %136)
%138 = load i32*, i32** %20
%139 = call i32 @free(i32* %138)
%140 = load i32, i32* %23
store i32 %140, i32* %7
br label %141
141: ; preds = %127, %29
%142 = load i32, i32* %7
ret i32 %142
}

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