#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 */
double cos(double);
double sin(double);
void geom_dgam_sph_rtp(double x[], double dgam[2][3][3]) {
  double r = x[0];
  double st = sin(x[1]);
  double ct = cos(x[1]);
  int k, i, j;
  for (k = 0; k < 2; k++)
    for (i = 0; i < 3; i++)
      for (j = 0; j < 3; j++)
        dgam[k][i][j] = 0.0;
  dgam[0][1][1] = 2 * r;
  dgam[0][2][2] = 2 * r * st * st;
  dgam[1][2][2] = 2 * r * r * st * ct;
}


x86 assembly (clang, -O0):
<geom_dgam_sph_rtp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    11f0 <geom_dgam_sph_rtp+0xd0>
movl   $0x0,-0x30(%rbp)
cmpl   $0x3,-0x30(%rbp)
jge    11dd <geom_dgam_sph_rtp+0xbd>
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11ca <geom_dgam_sph_rtp+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
imul   $0x48,%rcx,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118c <geom_dgam_sph_rtp+0x6c>
jmp    11cf <geom_dgam_sph_rtp+0xaf>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    117b <geom_dgam_sph_rtp+0x5b>
jmp    11e2 <geom_dgam_sph_rtp+0xc2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116a <geom_dgam_sph_rtp+0x4a>
movsd  0xe08(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  0xdf2(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  0xdd2(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x88(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geom_dgam_sph_rtp>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  (%rdi),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rdi),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%r14),%xmm0
call   1040 <cos@plt>
xorps  %xmm1,%xmm1
movups %xmm1,0x20(%rbx)
movups %xmm1,0x40(%rbx)
movups %xmm1,(%rbx)
movups %xmm1,0x10(%rbx)
movups %xmm1,0x30(%rbx)
movups %xmm1,0x50(%rbx)
movups %xmm1,0x60(%rbx)
movups %xmm1,0x70(%rbx)
movq   $0x0,0x80(%rbx)
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rbx)
mulsd  %xmm1,%xmm2
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x40(%rbx)
mulsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x88(%rbx)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @geom_dgam_sph_rtp(double* %0, [3 x [3 x double]]* %1) {
%3 = alloca double*
%4 = alloca [3 x [3 x double]]*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %3
store [3 x [3 x double]]* %1, [3 x [3 x double]]** %4
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
store double %13, double* %5
%14 = load double*, double** %3
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = call double @sin(double %16)
store double %17, double* %6
%18 = load double*, double** %3
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = call double @cos(double %20)
store double %21, double* %7
store i32 0, i32* %8
br label %22
22: ; preds = %52, %2
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 2
br i1 %24, label %25, label %55
25: ; preds = %22
store i32 0, i32* %9
br label %26
26: ; preds = %48, %25
%27 = load i32, i32* %9
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %51
29: ; preds = %26
store i32 0, i32* %10
br label %30
30: ; preds = %44, %29
%31 = load i32, i32* %10
%32 = icmp slt i32 %31, 3
br i1 %32, label %33, label %47
33: ; preds = %30
%34 = load [3 x [3 x double]]*, [3 x [3 x double]]** %4
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %34, i64 %36
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %37, i64 0, i64 %39
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 0, i64 %42
store double 0.000000e+00, double* %43
br label %44
44: ; preds = %33
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
store i32 %46, i32* %10
br label %30
47: ; preds = %30
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %26
51: ; preds = %26
br label %52
52: ; preds = %51
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %22
55: ; preds = %22
%56 = load double, double* %5
%57 = fmul double 2.000000e+00, %56
%58 = load [3 x [3 x double]]*, [3 x [3 x double]]** %4
%59 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %58, i64 0
%60 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %59, i64 0, i64 1
%61 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 0, i64 1
store double %57, double* %61
%62 = load double, double* %5
%63 = fmul double 2.000000e+00, %62
%64 = load double, double* %6
%65 = fmul double %63, %64
%66 = load double, double* %6
%67 = fmul double %65, %66
%68 = load [3 x [3 x double]]*, [3 x [3 x double]]** %4
%69 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %68, i64 0
%70 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %69, i64 0, i64 2
%71 = getelementptr inbounds [3 x double], [3 x double]* %70, i64 0, i64 2
store double %67, double* %71
%72 = load double, double* %5
%73 = fmul double 2.000000e+00, %72
%74 = load double, double* %5
%75 = fmul double %73, %74
%76 = load double, double* %6
%77 = fmul double %75, %76
%78 = load double, double* %7
%79 = fmul double %77, %78
%80 = load [3 x [3 x double]]*, [3 x [3 x double]]** %4
%81 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %80, i64 1
%82 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %81, i64 0, i64 2
%83 = getelementptr inbounds [3 x double], [3 x double]* %82, i64 0, i64 2
store double %79, double* %83
ret void
}

LLVM IR (-O2):
define void @geom_dgam_sph_rtp(double* nocapture %0, [3 x [3 x double]]* nocapture writeonly %1) {
%3 = bitcast [3 x [3 x double]]* %1 to i8*
%4 = load double, double* %0
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = tail call double @sin(double %6)
%8 = load double, double* %5
%9 = tail call double @cos(double %8)
%10 = fmul double %4, 2.000000e+00
%11 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 1, i64 1
store double %10, double* %11
%12 = fmul double %10, %7
%13 = fmul double %7, %12
%14 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 0, i64 2, i64 2
store double %13, double* %14
%15 = fmul double %4, %10
%16 = fmul double %15, %7
%17 = fmul double %16, %9
%18 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %1, i64 1, i64 2, i64 2
store double %17, double* %18
ret void
}