#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*/ copy_list(int *, int *, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ inverse(int *, int *, int);
scalar_t__ malloc(int);
int onpoints(int, int *, int);
int /*<<< orphan*/ product(int *, int *, int *, int);
int /*<<< orphan*/ range(int *, int);
int /*<<< orphan*/ sorted_schreier_vector(int, int *, int, int *, int, int,
                                          int *, int *);
int /*<<< orphan*/ stabilizer(int *, int, int *, int, int, int *, int *);
int /*<<< orphan*/ trace_schreier(int, int *, int *, int *, int);
void from_base_image(int *images, int ll, int *base, int bl, int *GS, int m,
                     int n, int *perm) {
  int *list = (int *)malloc(bl * sizeof(int));
  int *nu = (int *)malloc(n * n * sizeof(int));
  int *w = (int *)malloc(n * sizeof(int));
  int *u = (int *)malloc(n * sizeof(int));
  int *tmp = (int *)malloc(n * sizeof(int));
  int *stab = (int *)malloc(m * n * sizeof(int)), sl;
  int i, j;
  copy_list(images, list, ll);
  range(perm, n);
  for (i = 0; i < ll; i++) {
    stabilizer(base, i, GS, m, n, stab, &sl);
    sorted_schreier_vector(list[i], base + i, bl - i, stab, sl, n, nu, w);
    trace_schreier(list[i], nu, w, u, n);
    product(u, perm, tmp, n);
    copy_list(tmp, perm, n);
    inverse(u, tmp, n);
    for (j = 0; j < ll; j++) {
      list[j] = onpoints(list[j], tmp, n);
    }
  }
  free(list);
  free(nu);
  free(w);
  free(u);
  free(tmp);
  free(stab);
}


x86 assembly (clang, -O0):
<from_base_image>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    0x10(%rbp),%eax
imul   0x10(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
imul   0x10(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   10b0 <copy_list@plt>
mov    0x18(%rbp),%rdi
mov    0x10(%rbp),%esi
call   1080 <range@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1384 <from_base_image+0x1e4>
mov    -0x18(%rbp),%rdi
mov    -0x68(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    0x10(%rbp),%r8d
mov    -0x60(%rbp),%r9
lea    -0x64(%rbp),%rax
mov    %rax,(%rsp)
call   10a0 <stabilizer@plt>
mov    -0x38(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x18(%rbp),%rsi
movslq -0x68(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
sub    -0x68(%rbp),%edx
mov    -0x60(%rbp),%rcx
mov    -0x64(%rbp),%r8d
mov    0x10(%rbp),%r9d
mov    -0x40(%rbp),%r10
mov    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1070 <sorted_schreier_vector@plt>
mov    -0x38(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    0x10(%rbp),%r8d
call   1040 <trace_schreier@plt>
mov    -0x50(%rbp),%rdi
mov    0x18(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    0x10(%rbp),%ecx
call   1060 <product@plt>
mov    -0x58(%rbp),%rdi
mov    0x18(%rbp),%rsi
mov    0x10(%rbp),%edx
call   10b0 <copy_list@plt>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    0x10(%rbp),%edx
call   1090 <inverse@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1371 <from_base_image+0x1d1>
mov    -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x58(%rbp),%rsi
mov    0x10(%rbp),%edx
call   10c0 <onpoints@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1333 <from_base_image+0x193>
jmp    1376 <from_base_image+0x1d6>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1267 <from_base_image+0xc7>
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    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<from_base_image>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%r12d
mov    %r8,0x40(%rsp)
mov    %rdx,0x30(%rsp)
mov    %esi,%ebx
mov    %rdi,(%rsp)
mov    0x88(%rsp),%r13
mov    0x80(%rsp),%r15d
mov    %rcx,0x38(%rsp)
lea    0x0(,%rcx,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0x0(,%r15,4),%ebp
mov    %ebp,%edi
imul   %r15d,%edi
call   1050 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %r12d,0x18(%rsp)
imul   %r15d,%r12d
shl    $0x2,%r12d
mov    %r12d,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   10b0 <copy_list@plt>
mov    %r13,%rdi
mov    %r15d,%esi
call   1080 <range@plt>
test   %ebx,%ebx
jle    134d <from_base_image+0x1ad>
mov    %ebx,%r12d
xor    %ebx,%ebx
nop
sub    $0x8,%rsp
mov    0x38(%rsp),%r13
mov    %r13,%rdi
mov    %ebx,%esi
mov    0x48(%rsp),%rdx
mov    0x20(%rsp),%ecx
mov    %r15d,%r8d
mov    0x10(%rsp),%r9
lea    0x24(%rsp),%rax
push   %rax
call   10a0 <stabilizer@plt>
add    $0x10,%rsp
mov    (%r14,%rbx,4),%edi
lea    0x0(,%rbx,4),%rsi
add    %r13,%rsi
mov    0x38(%rsp),%rax
mov    %eax,%edx
sub    %ebx,%edx
mov    0x1c(%rsp),%r8d
mov    0x8(%rsp),%rcx
mov    %r15d,%r9d
push   0x10(%rsp)
mov    0x30(%rsp),%r13
push   %r13
call   1070 <sorted_schreier_vector@plt>
add    $0x10,%rsp
mov    %rbx,(%rsp)
mov    (%r14,%rbx,4),%edi
mov    %r13,%rsi
mov    0x10(%rsp),%rdx
mov    0x20(%rsp),%rbx
mov    %rbx,%rcx
mov    %r15d,%r8d
call   1040 <trace_schreier@plt>
mov    %rbx,%rdi
mov    0x88(%rsp),%r13
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
call   1060 <product@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   10b0 <copy_list@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1090 <inverse@plt>
xor    %r13d,%r13d
nop
mov    (%r14,%r13,4),%edi
mov    %rbp,%rsi
mov    %r15d,%edx
call   10c0 <onpoints@plt>
mov    %eax,(%r14,%r13,4)
add    $0x1,%r13
cmp    %r13,%r12
jne    1320 <from_base_image+0x180>
mov    (%rsp),%rbx
add    $0x1,%rbx
cmp    %r12,%rbx
jne    1260 <from_base_image+0xc0>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @from_base_image(i32* %0, i32 %1, i32* %2, i32 %3, i32* %4, i32 %5, i32 %6, i32* %7) {
%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
%24 = alloca i32
%25 = alloca i32
store i32* %0, i32** %9
store i32 %1, i32* %10
store i32* %2, i32** %11
store i32 %3, i32* %12
store i32* %4, i32** %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32* %7, i32** %16
%26 = load i32, i32* %12
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i32*
store i32* %31, i32** %17
%32 = load i32, i32* %15
%33 = load i32, i32* %15
%34 = mul nsw i32 %32, %33
%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** %18
%40 = load i32, i32* %15
%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** %19
%46 = load i32, i32* %15
%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** %20
%52 = load i32, i32* %15
%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** %21
%58 = load i32, i32* %14
%59 = load i32, i32* %15
%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** %22
%66 = load i32*, i32** %9
%67 = load i32*, i32** %17
%68 = load i32, i32* %10
%69 = call i32 @copy_list(i32* %66, i32* %67, i32 %68)
%70 = load i32*, i32** %16
%71 = load i32, i32* %15
%72 = call i32 @range(i32* %70, i32 %71)
store i32 0, i32* %24
br label %73
73: ; preds = %147, %8
%74 = load i32, i32* %24
%75 = load i32, i32* %10
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %150
77: ; preds = %73
%78 = load i32*, i32** %11
%79 = load i32, i32* %24
%80 = load i32*, i32** %13
%81 = load i32, i32* %14
%82 = load i32, i32* %15
%83 = load i32*, i32** %22
%84 = call i32 @stabilizer(i32* %78, i32 %79, i32* %80, i32 %81, i32 %82, i32* %83, i32* %23)
%85 = load i32*, i32** %17
%86 = load i32, i32* %24
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = load i32*, i32** %11
%91 = load i32, i32* %24
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %90, i64 %92
%94 = load i32, i32* %12
%95 = load i32, i32* %24
%96 = sub nsw i32 %94, %95
%97 = load i32*, i32** %22
%98 = load i32, i32* %23
%99 = load i32, i32* %15
%100 = load i32*, i32** %18
%101 = load i32*, i32** %19
%102 = call i32 @sorted_schreier_vector(i32 %89, i32* %93, i32 %96, i32* %97, i32 %98, i32 %99, i32* %100, i32* %101)
%103 = load i32*, i32** %17
%104 = load i32, i32* %24
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32, i32* %103, i64 %105
%107 = load i32, i32* %106
%108 = load i32*, i32** %18
%109 = load i32*, i32** %19
%110 = load i32*, i32** %20
%111 = load i32, i32* %15
%112 = call i32 @trace_schreier(i32 %107, i32* %108, i32* %109, i32* %110, i32 %111)
%113 = load i32*, i32** %20
%114 = load i32*, i32** %16
%115 = load i32*, i32** %21
%116 = load i32, i32* %15
%117 = call i32 @product(i32* %113, i32* %114, i32* %115, i32 %116)
%118 = load i32*, i32** %21
%119 = load i32*, i32** %16
%120 = load i32, i32* %15
%121 = call i32 @copy_list(i32* %118, i32* %119, i32 %120)
%122 = load i32*, i32** %20
%123 = load i32*, i32** %21
%124 = load i32, i32* %15
%125 = call i32 @inverse(i32* %122, i32* %123, i32 %124)
store i32 0, i32* %25
br label %126
126: ; preds = %143, %77
%127 = load i32, i32* %25
%128 = load i32, i32* %10
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %146
130: ; preds = %126
%131 = load i32*, i32** %17
%132 = load i32, i32* %25
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i32, i32* %131, i64 %133
%135 = load i32, i32* %134
%136 = load i32*, i32** %21
%137 = load i32, i32* %15
%138 = call i32 @onpoints(i32 %135, i32* %136, i32 %137)
%139 = load i32*, i32** %17
%140 = load i32, i32* %25
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i32, i32* %139, i64 %141
store i32 %138, i32* %142
br label %143
143: ; preds = %130
%144 = load i32, i32* %25
%145 = add nsw i32 %144, 1
store i32 %145, i32* %25
br label %126
146: ; preds = %126
br label %147
147: ; preds = %146
%148 = load i32, i32* %24
%149 = add nsw i32 %148, 1
store i32 %149, i32* %24
br label %73
150: ; preds = %73
%151 = load i32*, i32** %17
%152 = call i32 @free(i32* %151)
%153 = load i32*, i32** %18
%154 = call i32 @free(i32* %153)
%155 = load i32*, i32** %19
%156 = call i32 @free(i32* %155)
%157 = load i32*, i32** %20
%158 = call i32 @free(i32* %157)
%159 = load i32*, i32** %21
%160 = call i32 @free(i32* %159)
%161 = load i32*, i32** %22
%162 = call i32 @free(i32* %161)
ret void
}

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