#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 ltcmat(double *llh, double t[3][3]) {
  double slat, clat;
  double slon, clon;
  slat = sin(llh[0]);
  clat = cos(llh[0]);
  slon = sin(llh[1]);
  clon = cos(llh[1]);
  t[0][0] = -slat * clon;
  t[0][1] = -slat * slon;
  t[0][2] = clat;
  t[1][0] = -slon;
  t[1][1] = clon;
  t[1][2] = 0.0;
  t[2][0] = clat * clon;
  t[2][1] = clat * slon;
  t[2][2] = slat;
  return;
}


x86 assembly (clang, -O0):
<ltcmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltcmat>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rbx),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
movaps %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
movdqa 0xe97(%rip),%xmm1
movdqa 0x10(%rsp),%xmm4
movdqa %xmm4,%xmm2
pxor   %xmm1,%xmm2
movapd %xmm0,%xmm3
movapd (%rsp),%xmm5
unpcklpd %xmm5,%xmm3
pshufd $0x44,%xmm2,%xmm2
mulpd  %xmm3,%xmm2
movupd %xmm2,(%r14)
movapd 0x20(%rsp),%xmm2
movsd  %xmm2,0x10(%r14)
xorpd  %xmm1,%xmm5
movlpd %xmm5,0x18(%r14)
movsd  %xmm0,0x20(%r14)
movq   $0x0,0x28(%r14)
unpcklpd %xmm2,%xmm2
mulpd  %xmm3,%xmm2
movupd %xmm2,0x30(%r14)
movq   %xmm4,0x40(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @ltcmat(double* %0, [3 x double]* %1) {
%3 = alloca double*
%4 = alloca [3 x double]*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %3
store [3 x double]* %1, [3 x double]** %4
%9 = load double*, double** %3
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = call double @sin(double %11)
store double %12, double* %5
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i64 0
%15 = load double, double* %14
%16 = call double @cos(double %15)
store double %16, double* %6
%17 = load double*, double** %3
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = call double @sin(double %19)
store double %20, double* %7
%21 = load double*, double** %3
%22 = getelementptr inbounds double, double* %21, i64 1
%23 = load double, double* %22
%24 = call double @cos(double %23)
store double %24, double* %8
%25 = load double, double* %5
%26 = fneg double %25
%27 = load double, double* %8
%28 = fmul double %26, %27
%29 = load [3 x double]*, [3 x double]** %4
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 0
%31 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0, i64 0
store double %28, double* %31
%32 = load double, double* %5
%33 = fneg double %32
%34 = load double, double* %7
%35 = fmul double %33, %34
%36 = load [3 x double]*, [3 x double]** %4
%37 = getelementptr inbounds [3 x double], [3 x double]* %36, i64 0
%38 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 0, i64 1
store double %35, double* %38
%39 = load double, double* %6
%40 = load [3 x double]*, [3 x double]** %4
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 0
%42 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 2
store double %39, double* %42
%43 = load double, double* %7
%44 = fneg double %43
%45 = load [3 x double]*, [3 x double]** %4
%46 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 1
%47 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 0, i64 0
store double %44, double* %47
%48 = load double, double* %8
%49 = load [3 x double]*, [3 x double]** %4
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 1
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 1
store double %48, double* %51
%52 = load [3 x double]*, [3 x double]** %4
%53 = getelementptr inbounds [3 x double], [3 x double]* %52, i64 1
%54 = getelementptr inbounds [3 x double], [3 x double]* %53, i64 0, i64 2
store double 0.000000e+00, double* %54
%55 = load double, double* %6
%56 = load double, double* %8
%57 = fmul double %55, %56
%58 = load [3 x double]*, [3 x double]** %4
%59 = getelementptr inbounds [3 x double], [3 x double]* %58, i64 2
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 0, i64 0
store double %57, double* %60
%61 = load double, double* %6
%62 = load double, double* %7
%63 = fmul double %61, %62
%64 = load [3 x double]*, [3 x double]** %4
%65 = getelementptr inbounds [3 x double], [3 x double]* %64, i64 2
%66 = getelementptr inbounds [3 x double], [3 x double]* %65, i64 0, i64 1
store double %63, double* %66
%67 = load double, double* %5
%68 = load [3 x double]*, [3 x double]** %4
%69 = getelementptr inbounds [3 x double], [3 x double]* %68, i64 2
%70 = getelementptr inbounds [3 x double], [3 x double]* %69, i64 0, i64 2
store double %67, double* %70
ret void
}

LLVM IR (-O2):
define void @ltcmat(double* nocapture %0, [3 x double]* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = tail call double @sin(double %3)
%5 = load double, double* %0
%6 = tail call double @cos(double %5)
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = tail call double @sin(double %8)
%10 = load double, double* %7
%11 = tail call double @cos(double %10)
%12 = fneg double %4
%13 = insertelement <2 x double> poison, double %11, i64 0
%14 = insertelement <2 x double> %13, double %9, i64 1
%15 = insertelement <2 x double> poison, double %12, i64 0
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%17 = fmul <2 x double> %14, %16
%18 = bitcast [3 x double]* %1 to <2 x double>*
store <2 x double> %17, <2 x double>* %18
%19 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
store double %6, double* %19
%20 = fneg double %9
%21 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
store double %20, double* %21
%22 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
store double %11, double* %22
%23 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
store double 0.000000e+00, double* %23
%24 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
%25 = insertelement <2 x double> poison, double %6, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%27 = fmul <2 x double> %26, %14
%28 = bitcast double* %24 to <2 x double>*
store <2 x double> %27, <2 x double>* %28
%29 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
store double %4, double* %29
ret void
}