#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 */
float cos(double);
float sin(double);
void calculateDH(float a, float alpha, float d, float theta, float mat[4][4]) {
  double theta_rads = theta * (3.14159265 / 180.0);
  double alpha_rads = alpha * (3.14159265 / 180.0);
  mat[0][0] = cos(theta_rads);
  mat[0][1] = -sin(theta_rads) * cos(alpha_rads);
  mat[0][2] = sin(theta_rads) * sin(alpha_rads);
  mat[0][3] = a * cos(theta_rads);
  mat[1][0] = sin(theta_rads);
  mat[1][1] = cos(theta_rads) * cos(alpha_rads);
  mat[1][2] = -cos(theta_rads) * sin(alpha_rads);
  mat[1][3] = a * sin(theta_rads);
  mat[2][0] = 0;
  mat[2][1] = sin(alpha_rads);
  mat[2][2] = cos(alpha_rads);
  mat[2][3] = d;
  mat[3][0] = 0;
  mat[3][1] = 0;
  mat[3][2] = 0;
  mat[3][3] = 1;
}


x86 assembly (clang, -O0):
<calculateDH>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x4(%rax)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,-0x3c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x3c(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0xc(%rax)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x10(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movss  %xmm0,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x14(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x18(%rax)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x1c(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x20(%rax)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x24(%rax)
movsd  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,0x28(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,0x2c(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x30(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x34(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x38(%rax)
mov    -0x18(%rbp),%rax
movss  0xcd3(%rip),%xmm0
movss  %xmm0,0x3c(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculateDH>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movss  %xmm2,0x3c(%rsp)
movss  %xmm0,0x1c(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
movsd  0xebd(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1040 <cos@plt>
movss  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
xorps  0xe9a(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulss  0x20(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulss  0x20(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulss  0x1c(%rsp),%xmm0
movss  %xmm0,0xc(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,0x10(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movss  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulss  0x20(%rsp),%xmm0
movss  %xmm0,0x14(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
xorps  0xdf9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulss  0x20(%rsp),%xmm0
movss  %xmm0,0x18(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulss  0x1c(%rsp),%xmm0
movss  %xmm0,0x1c(%rbx)
movl   $0x0,0x20(%rbx)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,0x24(%rbx)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movss  %xmm0,0x28(%rbx)
movss  0x3c(%rsp),%xmm0
movss  %xmm0,0x2c(%rbx)
movaps 0xd9f(%rip),%xmm0
movups %xmm0,0x30(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @calculateDH(float %0, float %1, float %2, float %3, [4 x float]* %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca [4 x float]*
%11 = alloca double
%12 = alloca double
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store [4 x float]* %4, [4 x float]** %10
%13 = load float, float* %9
%14 = fpext float %13 to double
%15 = fmul double %14, 0x3F91DF46A1FAE712
store double %15, double* %11
%16 = load float, float* %7
%17 = fpext float %16 to double
%18 = fmul double %17, 0x3F91DF46A1FAE712
store double %18, double* %12
%19 = load double, double* %11
%20 = call float @cos(double %19)
%21 = load [4 x float]*, [4 x float]** %10
%22 = getelementptr inbounds [4 x float], [4 x float]* %21, i64 0
%23 = getelementptr inbounds [4 x float], [4 x float]* %22, i64 0, i64 0
store float %20, float* %23
%24 = load double, double* %11
%25 = call float @sin(double %24)
%26 = fneg float %25
%27 = load double, double* %12
%28 = call float @cos(double %27)
%29 = fmul float %26, %28
%30 = load [4 x float]*, [4 x float]** %10
%31 = getelementptr inbounds [4 x float], [4 x float]* %30, i64 0
%32 = getelementptr inbounds [4 x float], [4 x float]* %31, i64 0, i64 1
store float %29, float* %32
%33 = load double, double* %11
%34 = call float @sin(double %33)
%35 = load double, double* %12
%36 = call float @sin(double %35)
%37 = fmul float %34, %36
%38 = load [4 x float]*, [4 x float]** %10
%39 = getelementptr inbounds [4 x float], [4 x float]* %38, i64 0
%40 = getelementptr inbounds [4 x float], [4 x float]* %39, i64 0, i64 2
store float %37, float* %40
%41 = load float, float* %6
%42 = load double, double* %11
%43 = call float @cos(double %42)
%44 = fmul float %41, %43
%45 = load [4 x float]*, [4 x float]** %10
%46 = getelementptr inbounds [4 x float], [4 x float]* %45, i64 0
%47 = getelementptr inbounds [4 x float], [4 x float]* %46, i64 0, i64 3
store float %44, float* %47
%48 = load double, double* %11
%49 = call float @sin(double %48)
%50 = load [4 x float]*, [4 x float]** %10
%51 = getelementptr inbounds [4 x float], [4 x float]* %50, i64 1
%52 = getelementptr inbounds [4 x float], [4 x float]* %51, i64 0, i64 0
store float %49, float* %52
%53 = load double, double* %11
%54 = call float @cos(double %53)
%55 = load double, double* %12
%56 = call float @cos(double %55)
%57 = fmul float %54, %56
%58 = load [4 x float]*, [4 x float]** %10
%59 = getelementptr inbounds [4 x float], [4 x float]* %58, i64 1
%60 = getelementptr inbounds [4 x float], [4 x float]* %59, i64 0, i64 1
store float %57, float* %60
%61 = load double, double* %11
%62 = call float @cos(double %61)
%63 = fneg float %62
%64 = load double, double* %12
%65 = call float @sin(double %64)
%66 = fmul float %63, %65
%67 = load [4 x float]*, [4 x float]** %10
%68 = getelementptr inbounds [4 x float], [4 x float]* %67, i64 1
%69 = getelementptr inbounds [4 x float], [4 x float]* %68, i64 0, i64 2
store float %66, float* %69
%70 = load float, float* %6
%71 = load double, double* %11
%72 = call float @sin(double %71)
%73 = fmul float %70, %72
%74 = load [4 x float]*, [4 x float]** %10
%75 = getelementptr inbounds [4 x float], [4 x float]* %74, i64 1
%76 = getelementptr inbounds [4 x float], [4 x float]* %75, i64 0, i64 3
store float %73, float* %76
%77 = load [4 x float]*, [4 x float]** %10
%78 = getelementptr inbounds [4 x float], [4 x float]* %77, i64 2
%79 = getelementptr inbounds [4 x float], [4 x float]* %78, i64 0, i64 0
store float 0.000000e+00, float* %79
%80 = load double, double* %12
%81 = call float @sin(double %80)
%82 = load [4 x float]*, [4 x float]** %10
%83 = getelementptr inbounds [4 x float], [4 x float]* %82, i64 2
%84 = getelementptr inbounds [4 x float], [4 x float]* %83, i64 0, i64 1
store float %81, float* %84
%85 = load double, double* %12
%86 = call float @cos(double %85)
%87 = load [4 x float]*, [4 x float]** %10
%88 = getelementptr inbounds [4 x float], [4 x float]* %87, i64 2
%89 = getelementptr inbounds [4 x float], [4 x float]* %88, i64 0, i64 2
store float %86, float* %89
%90 = load float, float* %8
%91 = load [4 x float]*, [4 x float]** %10
%92 = getelementptr inbounds [4 x float], [4 x float]* %91, i64 2
%93 = getelementptr inbounds [4 x float], [4 x float]* %92, i64 0, i64 3
store float %90, float* %93
%94 = load [4 x float]*, [4 x float]** %10
%95 = getelementptr inbounds [4 x float], [4 x float]* %94, i64 3
%96 = getelementptr inbounds [4 x float], [4 x float]* %95, i64 0, i64 0
store float 0.000000e+00, float* %96
%97 = load [4 x float]*, [4 x float]** %10
%98 = getelementptr inbounds [4 x float], [4 x float]* %97, i64 3
%99 = getelementptr inbounds [4 x float], [4 x float]* %98, i64 0, i64 1
store float 0.000000e+00, float* %99
%100 = load [4 x float]*, [4 x float]** %10
%101 = getelementptr inbounds [4 x float], [4 x float]* %100, i64 3
%102 = getelementptr inbounds [4 x float], [4 x float]* %101, i64 0, i64 2
store float 0.000000e+00, float* %102
%103 = load [4 x float]*, [4 x float]** %10
%104 = getelementptr inbounds [4 x float], [4 x float]* %103, i64 3
%105 = getelementptr inbounds [4 x float], [4 x float]* %104, i64 0, i64 3
store float 1.000000e+00, float* %105
ret void
}

LLVM IR (-O2):
define void @calculateDH(float %0, float %1, float %2, float %3, [4 x float]* nocapture writeonly %4) {
%6 = fpext float %3 to double
%7 = fmul double %6, 0x3F91DF46A1FAE712
%8 = fpext float %1 to double
%9 = fmul double %8, 0x3F91DF46A1FAE712
%10 = tail call float @cos(double %7)
%11 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 0
store float %10, float* %11
%12 = tail call float @sin(double %7)
%13 = fneg float %12
%14 = tail call float @cos(double %9)
%15 = fmul float %14, %13
%16 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 1
store float %15, float* %16
%17 = tail call float @sin(double %7)
%18 = tail call float @sin(double %9)
%19 = fmul float %17, %18
%20 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 2
store float %19, float* %20
%21 = tail call float @cos(double %7)
%22 = fmul float %21, %0
%23 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 3
store float %22, float* %23
%24 = tail call float @sin(double %7)
%25 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 1, i64 0
store float %24, float* %25
%26 = tail call float @cos(double %7)
%27 = tail call float @cos(double %9)
%28 = fmul float %26, %27
%29 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 1, i64 1
store float %28, float* %29
%30 = tail call float @cos(double %7)
%31 = fneg float %30
%32 = tail call float @sin(double %9)
%33 = fmul float %32, %31
%34 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 1, i64 2
store float %33, float* %34
%35 = tail call float @sin(double %7)
%36 = fmul float %35, %0
%37 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 1, i64 3
store float %36, float* %37
%38 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 2, i64 0
store float 0.000000e+00, float* %38
%39 = tail call float @sin(double %9)
%40 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 2, i64 1
store float %39, float* %40
%41 = tail call float @cos(double %9)
%42 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 2, i64 2
store float %41, float* %42
%43 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 2, i64 3
store float %2, float* %43
%44 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 3, i64 0
%45 = bitcast float* %44 to <4 x float>*
store <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00>, <4 x float>* %45
ret void
}