#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 TableSize(int, int);
int /*<<< orphan*/ Transpose_CosPmlTableGen(int, int, double *, double *);
scalar_t__ malloc(int);
double **Transpose_Spharmonic_Pml_Table(double **spharmonic_pml_table, int bw,
                                        double *resultspace,
                                        double *workspace) {
  int i;
  double **transpose_spharmonic_pml_table;
  transpose_spharmonic_pml_table = (double **)malloc(sizeof(double *) * bw);
  transpose_spharmonic_pml_table[0] = resultspace;
  for (i = 0; i < bw; i++) {
    Transpose_CosPmlTableGen(bw, i, spharmonic_pml_table[i],
                             transpose_spharmonic_pml_table[i]);
    if (i != (bw - 1)) {
      transpose_spharmonic_pml_table[i + 1] =
          transpose_spharmonic_pml_table[i] + TableSize(i, bw);
    }
  }
  return transpose_spharmonic_pml_table;
}


x86 assembly (clang, -O0):
<Transpose_Spharmonic_Pml_Table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f8 <Transpose_Spharmonic_Pml_Table+0xc8>
mov    -0xc(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
call   1030 <Transpose_CosPmlTableGen@plt>
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11e5 <Transpose_Spharmonic_Pml_Table+0xb5>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <TableSize@plt>
mov    -0x38(%rbp),%rdx
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    11ea <Transpose_Spharmonic_Pml_Table+0xba>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116c <Transpose_Spharmonic_Pml_Table+0x3c>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Transpose_Spharmonic_Pml_Table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0x0(,%r15,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r13,(%rax)
test   %r15d,%r15d
jle    11bd <Transpose_Spharmonic_Pml_Table+0x8d>
lea    -0x1(%r15),%eax
mov    %rax,(%rsp)
mov    %r15d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x0(%rbp,%rbx,8),%rdx
mov    %r15d,%edi
mov    %ebx,%esi
mov    %r13,%rcx
call   1030 <Transpose_CosPmlTableGen@plt>
cmp    (%rsp),%rbx
je     11ae <Transpose_Spharmonic_Pml_Table+0x7e>
mov    %rbp,%r13
mov    (%r12,%rbx,8),%rbp
mov    %ebx,%edi
mov    %r15d,%esi
call   1040 <TableSize@plt>
cltq
lea    0x0(,%rax,8),%rax
add    %rbp,%rax
mov    %r13,%rbp
mov    %rax,0x8(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %r14,%rbx
je     11bd <Transpose_Spharmonic_Pml_Table+0x8d>
mov    (%r12,%rbx,8),%r13
jmp    1170 <Transpose_Spharmonic_Pml_Table+0x40>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double** @Transpose_Spharmonic_Pml_Table(double** nocapture %0, i32 %1, double* %2, double* nocapture readnone %3) {
%5 = shl i32 %1, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double**
store double* %2, double** %7
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %37
9: ; preds = %4
%10 = add nsw i32 %1, -1
%11 = zext i32 %10 to i64
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %34, %9
%14 = phi double* [ %2, %9 ], [ %36, %34 ]
%15 = phi i64 [ 0, %9 ], [ %32, %34 ]
%16 = getelementptr inbounds double*, double** %0, i64 %15
%17 = load double*, double** %16
%18 = trunc i64 %15 to i32
%19 = tail call i32 @Transpose_CosPmlTableGen(i32 %1, i32 %18, double* %17, double* %14)
%20 = icmp eq i64 %15, %11
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = add nuw nsw i64 %15, 1
br label %31
23: ; preds = %13
%24 = getelementptr inbounds double*, double** %7, i64 %15
%25 = load double*, double** %24
%26 = tail call i32 @TableSize(i32 %18, i32 %1)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = add nuw nsw i64 %15, 1
%30 = getelementptr inbounds double*, double** %7, i64 %29
store double* %28, double** %30
br label %31
31: ; preds = %21, %23
%32 = phi i64 [ %22, %21 ], [ %29, %23 ]
%33 = icmp eq i64 %32, %12
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = getelementptr inbounds double*, double** %7, i64 %32
%36 = load double*, double** %35
br label %13
37: ; preds = %31, %4
ret double** %7
}