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


x86 assembly (clang, -O0):
<Spharmonic_Pml_Table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11be <Spharmonic_Pml_Table+0x8e>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
sub    $0x1,%edi
mov    -0x4(%rbp),%esi
call   1030 <TableSize@plt>
mov    -0x30(%rbp),%rdx
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1168 <Spharmonic_Pml_Table+0x38>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11fa <Spharmonic_Pml_Table+0xca>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rcx
call   1050 <CosPmlTableGen@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c5 <Spharmonic_Pml_Table+0x95>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Spharmonic_Pml_Table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x0(,%rbp,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rbx,(%rax)
mov    %ebp,%r13d
mov    %rbp,(%rsp)
cmp    $0x2,%ebp
jl     118e <Spharmonic_Pml_Table+0x5e>
lea    -0x1(%r13),%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r13d,%esi
call   1030 <TableSize@plt>
cltq
lea    (%rbx,%rax,8),%rbx
mov    %rbx,0x8(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1170 <Spharmonic_Pml_Table+0x40>
cmpl   $0x0,(%rsp)
jle    11ba <Spharmonic_Pml_Table+0x8a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdx
mov    %r13d,%edi
mov    %ebx,%esi
mov    %r14,%rcx
call   1050 <CosPmlTableGen@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11a0 <Spharmonic_Pml_Table+0x70>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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