#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 acos(double);
int cos(double);
int sin(double);
int sqrt(int);
void set_rhomb(double lattice[3][3], double metric[3][3]) {
  double a, b, c, angle, ahex, chex;
  a = sqrt(metric[0][0]);
  b = sqrt(metric[1][1]);
  c = sqrt(metric[2][2]);
  angle = acos(
      (metric[0][1] / a / b + metric[0][2] / a / c + metric[1][2] / b / c) / 3);
  ahex = 2 * (a + b + c) / 3 * sin(angle / 2);
  chex = (a + b + c) / 3 * sqrt(3 * (1 + 2 * cos(angle)));
  lattice[0][0] = ahex / 2;
  lattice[1][0] = -ahex / (2 * sqrt(3));
  lattice[2][0] = chex / 3;
  lattice[1][1] = ahex / sqrt(3);
  lattice[2][1] = chex / 3;
  lattice[0][2] = -ahex / 2;
  lattice[1][2] = -ahex / (2 * sqrt(3));
  lattice[2][2] = chex / 3;
}


x86 assembly (clang, -O0):
<set_rhomb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cvttsd2si (%rax),%edi
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cvttsd2si 0x20(%rax),%edi
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cvttsd2si 0x40(%rax),%edi
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
divsd  -0x18(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm1
divsd  -0x20(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe23(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  0xe06(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdf2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xde4(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  -0x68(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
shl    $0x1,%eax
add    $0x1,%eax
imul   $0x3,%eax,%edi
call   1060 <sqrt@plt>
movsd  -0x60(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xd72(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
movsd  -0x58(%rbp),%xmm0
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xd0d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xcc9(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xca0(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
movsd  -0x48(%rbp),%xmm0
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xc3a(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_rhomb>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
cvttsd2si (%rsi),%edi
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x20(%rbx),%edi
call   1060 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si 0x40(%rbx),%edi
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm4
movsd  0x8(%rbx),%xmm0
movsd  0x10(%rbx),%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm3
divsd  %xmm3,%xmm0
divsd  %xmm2,%xmm1
movsd  %xmm4,0x20(%rsp)
divsd  %xmm4,%xmm1
addsd  %xmm0,%xmm1
movsd  0x28(%rbx),%xmm0
divsd  %xmm3,%xmm0
divsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe32(%rip),%xmm0
call   1030 <acos@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  %xmm0,%xmm0
divsd  0xdff(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  0xdf9(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
divsd  0xdc7(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
call   1050 <cos@plt>
add    %eax,%eax
add    $0x1,%eax
lea    (%rax,%rax,2),%edi
call   1060 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
movsd  0xd90(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movapd 0xd97(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%r14)
movsd  0x8(%rsp),%xmm0
divsd  0xd3c(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,0x30(%r14)
mov    $0x3,%edi
call   1060 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%r14)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x38(%r14)
mulsd  0xd07(%rip),%xmm2
movsd  %xmm2,0x10(%r14)
mov    $0x3,%edi
call   1060 <sqrt@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%r14)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x40(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @set_rhomb([3 x double]* %0, [3 x double]* %1) {
%3 = alloca [3 x double]*
%4 = alloca [3 x double]*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store [3 x double]* %0, [3 x double]** %3
store [3 x double]* %1, [3 x double]** %4
%11 = load [3 x double]*, [3 x double]** %4
%12 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0
%13 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%14 = load double, double* %13
%15 = fptosi double %14 to i32
%16 = call i32 @sqrt(i32 %15)
%17 = sitofp i32 %16 to double
store double %17, double* %5
%18 = load [3 x double]*, [3 x double]** %4
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 1
%20 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 1
%21 = load double, double* %20
%22 = fptosi double %21 to i32
%23 = call i32 @sqrt(i32 %22)
%24 = sitofp i32 %23 to double
store double %24, double* %6
%25 = load [3 x double]*, [3 x double]** %4
%26 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 2
%27 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 2
%28 = load double, double* %27
%29 = fptosi double %28 to i32
%30 = call i32 @sqrt(i32 %29)
%31 = sitofp i32 %30 to double
store double %31, double* %7
%32 = load [3 x double]*, [3 x double]** %4
%33 = getelementptr inbounds [3 x double], [3 x double]* %32, i64 0
%34 = getelementptr inbounds [3 x double], [3 x double]* %33, i64 0, i64 1
%35 = load double, double* %34
%36 = load double, double* %5
%37 = fdiv double %35, %36
%38 = load double, double* %6
%39 = fdiv double %37, %38
%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
%43 = load double, double* %42
%44 = load double, double* %5
%45 = fdiv double %43, %44
%46 = load double, double* %7
%47 = fdiv double %45, %46
%48 = fadd double %39, %47
%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 2
%52 = load double, double* %51
%53 = load double, double* %6
%54 = fdiv double %52, %53
%55 = load double, double* %7
%56 = fdiv double %54, %55
%57 = fadd double %48, %56
%58 = fdiv double %57, 3.000000e+00
%59 = call double @acos(double %58)
store double %59, double* %8
%60 = load double, double* %5
%61 = load double, double* %6
%62 = fadd double %60, %61
%63 = load double, double* %7
%64 = fadd double %62, %63
%65 = fmul double 2.000000e+00, %64
%66 = fdiv double %65, 3.000000e+00
%67 = load double, double* %8
%68 = fdiv double %67, 2.000000e+00
%69 = call i32 @sin(double %68)
%70 = sitofp i32 %69 to double
%71 = fmul double %66, %70
store double %71, double* %9
%72 = load double, double* %5
%73 = load double, double* %6
%74 = fadd double %72, %73
%75 = load double, double* %7
%76 = fadd double %74, %75
%77 = fdiv double %76, 3.000000e+00
%78 = load double, double* %8
%79 = call i32 @cos(double %78)
%80 = mul nsw i32 2, %79
%81 = add nsw i32 1, %80
%82 = mul nsw i32 3, %81
%83 = call i32 @sqrt(i32 %82)
%84 = sitofp i32 %83 to double
%85 = fmul double %77, %84
store double %85, double* %10
%86 = load double, double* %9
%87 = fdiv double %86, 2.000000e+00
%88 = load [3 x double]*, [3 x double]** %3
%89 = getelementptr inbounds [3 x double], [3 x double]* %88, i64 0
%90 = getelementptr inbounds [3 x double], [3 x double]* %89, i64 0, i64 0
store double %87, double* %90
%91 = load double, double* %9
%92 = fneg double %91
%93 = call i32 @sqrt(i32 3)
%94 = mul nsw i32 2, %93
%95 = sitofp i32 %94 to double
%96 = fdiv double %92, %95
%97 = load [3 x double]*, [3 x double]** %3
%98 = getelementptr inbounds [3 x double], [3 x double]* %97, i64 1
%99 = getelementptr inbounds [3 x double], [3 x double]* %98, i64 0, i64 0
store double %96, double* %99
%100 = load double, double* %10
%101 = fdiv double %100, 3.000000e+00
%102 = load [3 x double]*, [3 x double]** %3
%103 = getelementptr inbounds [3 x double], [3 x double]* %102, i64 2
%104 = getelementptr inbounds [3 x double], [3 x double]* %103, i64 0, i64 0
store double %101, double* %104
%105 = load double, double* %9
%106 = call i32 @sqrt(i32 3)
%107 = sitofp i32 %106 to double
%108 = fdiv double %105, %107
%109 = load [3 x double]*, [3 x double]** %3
%110 = getelementptr inbounds [3 x double], [3 x double]* %109, i64 1
%111 = getelementptr inbounds [3 x double], [3 x double]* %110, i64 0, i64 1
store double %108, double* %111
%112 = load double, double* %10
%113 = fdiv double %112, 3.000000e+00
%114 = load [3 x double]*, [3 x double]** %3
%115 = getelementptr inbounds [3 x double], [3 x double]* %114, i64 2
%116 = getelementptr inbounds [3 x double], [3 x double]* %115, i64 0, i64 1
store double %113, double* %116
%117 = load double, double* %9
%118 = fneg double %117
%119 = fdiv double %118, 2.000000e+00
%120 = load [3 x double]*, [3 x double]** %3
%121 = getelementptr inbounds [3 x double], [3 x double]* %120, i64 0
%122 = getelementptr inbounds [3 x double], [3 x double]* %121, i64 0, i64 2
store double %119, double* %122
%123 = load double, double* %9
%124 = fneg double %123
%125 = call i32 @sqrt(i32 3)
%126 = mul nsw i32 2, %125
%127 = sitofp i32 %126 to double
%128 = fdiv double %124, %127
%129 = load [3 x double]*, [3 x double]** %3
%130 = getelementptr inbounds [3 x double], [3 x double]* %129, i64 1
%131 = getelementptr inbounds [3 x double], [3 x double]* %130, i64 0, i64 2
store double %128, double* %131
%132 = load double, double* %10
%133 = fdiv double %132, 3.000000e+00
%134 = load [3 x double]*, [3 x double]** %3
%135 = getelementptr inbounds [3 x double], [3 x double]* %134, i64 2
%136 = getelementptr inbounds [3 x double], [3 x double]* %135, i64 0, i64 2
store double %133, double* %136
ret void
}

LLVM IR (-O2):
define void @set_rhomb([3 x double]* nocapture writeonly %0, [3 x double]* nocapture %1) {
%3 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%4 = load double, double* %3
%5 = fptosi double %4 to i32
%6 = tail call i32 @sqrt(i32 %5)
%7 = sitofp i32 %6 to double
%8 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%9 = load double, double* %8
%10 = fptosi double %9 to i32
%11 = tail call i32 @sqrt(i32 %10)
%12 = sitofp i32 %11 to double
%13 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%14 = load double, double* %13
%15 = fptosi double %14 to i32
%16 = tail call i32 @sqrt(i32 %15)
%17 = sitofp i32 %16 to double
%18 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%19 = load double, double* %18
%20 = fdiv double %19, %7
%21 = fdiv double %20, %12
%22 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%23 = load double, double* %22
%24 = fdiv double %23, %7
%25 = fdiv double %24, %17
%26 = fadd double %21, %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
%28 = load double, double* %27
%29 = fdiv double %28, %12
%30 = fdiv double %29, %17
%31 = fadd double %26, %30
%32 = fdiv double %31, 3.000000e+00
%33 = tail call double @acos(double %32)
%34 = fadd double %7, %12
%35 = fadd double %34, %17
%36 = fmul double %35, 2.000000e+00
%37 = fdiv double %36, 3.000000e+00
%38 = fmul double %33, 5.000000e-01
%39 = tail call i32 @sin(double %38)
%40 = sitofp i32 %39 to double
%41 = fmul double %37, %40
%42 = fdiv double %35, 3.000000e+00
%43 = tail call i32 @cos(double %33)
%44 = shl nsw i32 %43, 1
%45 = or i32 %44, 1
%46 = mul nsw i32 %45, 3
%47 = tail call i32 @sqrt(i32 %46)
%48 = sitofp i32 %47 to double
%49 = fmul double %42, %48
%50 = fmul double %41, 5.000000e-01
%51 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
store double %50, double* %51
%52 = fneg double %41
%53 = tail call i32 @sqrt(i32 3)
%54 = shl nsw i32 %53, 1
%55 = sitofp i32 %54 to double
%56 = fdiv double %52, %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
store double %56, double* %57
%58 = fdiv double %49, 3.000000e+00
%59 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
store double %58, double* %59
%60 = tail call i32 @sqrt(i32 3)
%61 = sitofp i32 %60 to double
%62 = fdiv double %41, %61
%63 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double %62, double* %63
%64 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double %58, double* %64
%65 = fmul double %41, -5.000000e-01
%66 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double %65, double* %66
%67 = tail call i32 @sqrt(i32 3)
%68 = shl nsw i32 %67, 1
%69 = sitofp i32 %68 to double
%70 = fdiv double %52, %69
%71 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
store double %70, double* %71
%72 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
store double %58, double* %72
ret void
}