#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);
double 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[0][1] = -ahex / 2;
  lattice[1][1] = ahex / (2 * sqrt(3));
  lattice[2][1] = chex / 3;
  lattice[0][2] = 0;
  lattice[1][2] = -ahex / 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>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cvttsd2si 0x20(%rax),%edi
call   1060 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cvttsd2si 0x40(%rax),%edi
call   1060 <sqrt@plt>
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  0xe2f(%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  0xe12(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdfe(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdf0(%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  0xdb6(%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>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xd7f(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
movsd  0xd4f(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xd29(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd00(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    $0x3,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  0xccf(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xca9(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
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>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xc43(%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>
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x20(%rbx),%edi
call   1060 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
cvttsd2si 0x40(%rbx),%edi
call   1060 <sqrt@plt>
movsd  0x8(%rbx),%xmm4
movsd  0x10(%rbx),%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm2,%xmm4
movsd  0x10(%rsp),%xmm3
divsd  %xmm3,%xmm4
divsd  %xmm2,%xmm1
movapd %xmm0,%xmm2
movsd  %xmm0,0x20(%rsp)
divsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  0x28(%rbx),%xmm0
divsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe3d(%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  0xe0a(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
mulsd  0xe04(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
divsd  0xdd2(%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>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xda8(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14)
mov    $0x3,%edi
call   1060 <sqrt@plt>
addsd  %xmm0,%xmm0
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%r14)
movsd  0x8(%rsp),%xmm0
divsd  0xd65(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,0x30(%r14)
movapd 0xd71(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0xd4f(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%r14)
mov    $0x3,%edi
call   1060 <sqrt@plt>
addsd  %xmm0,%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%r14)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x38(%r14)
movq   $0x0,0x10(%r14)
mov    $0x3,%edi
call   1060 <sqrt@plt>
movapd 0x20(%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 double @sqrt(i32 %15)
store double %16, double* %5
%17 = load [3 x double]*, [3 x double]** %4
%18 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 1
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 1
%20 = load double, double* %19
%21 = fptosi double %20 to i32
%22 = call double @sqrt(i32 %21)
store double %22, double* %6
%23 = load [3 x double]*, [3 x double]** %4
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 2
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 2
%26 = load double, double* %25
%27 = fptosi double %26 to i32
%28 = call double @sqrt(i32 %27)
store double %28, double* %7
%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 1
%32 = load double, double* %31
%33 = load double, double* %5
%34 = fdiv double %32, %33
%35 = load double, double* %6
%36 = fdiv double %34, %35
%37 = load [3 x double]*, [3 x double]** %4
%38 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 0
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 2
%40 = load double, double* %39
%41 = load double, double* %5
%42 = fdiv double %40, %41
%43 = load double, double* %7
%44 = fdiv double %42, %43
%45 = fadd double %36, %44
%46 = load [3 x double]*, [3 x double]** %4
%47 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 1
%48 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 0, i64 2
%49 = load double, double* %48
%50 = load double, double* %6
%51 = fdiv double %49, %50
%52 = load double, double* %7
%53 = fdiv double %51, %52
%54 = fadd double %45, %53
%55 = fdiv double %54, 3.000000e+00
%56 = call double @acos(double %55)
store double %56, double* %8
%57 = load double, double* %5
%58 = load double, double* %6
%59 = fadd double %57, %58
%60 = load double, double* %7
%61 = fadd double %59, %60
%62 = fmul double 2.000000e+00, %61
%63 = fdiv double %62, 3.000000e+00
%64 = load double, double* %8
%65 = fdiv double %64, 2.000000e+00
%66 = call i32 @sin(double %65)
%67 = sitofp i32 %66 to double
%68 = fmul double %63, %67
store double %68, double* %9
%69 = load double, double* %5
%70 = load double, double* %6
%71 = fadd double %69, %70
%72 = load double, double* %7
%73 = fadd double %71, %72
%74 = fdiv double %73, 3.000000e+00
%75 = load double, double* %8
%76 = call i32 @cos(double %75)
%77 = mul nsw i32 2, %76
%78 = add nsw i32 1, %77
%79 = mul nsw i32 3, %78
%80 = call double @sqrt(i32 %79)
%81 = fmul double %74, %80
store double %81, double* %10
%82 = load double, double* %9
%83 = fdiv double %82, 2.000000e+00
%84 = load [3 x double]*, [3 x double]** %3
%85 = getelementptr inbounds [3 x double], [3 x double]* %84, i64 0
%86 = getelementptr inbounds [3 x double], [3 x double]* %85, i64 0, i64 0
store double %83, double* %86
%87 = load double, double* %9
%88 = call double @sqrt(i32 3)
%89 = fmul double 2.000000e+00, %88
%90 = fdiv double %87, %89
%91 = load [3 x double]*, [3 x double]** %3
%92 = getelementptr inbounds [3 x double], [3 x double]* %91, i64 1
%93 = getelementptr inbounds [3 x double], [3 x double]* %92, i64 0, i64 0
store double %90, double* %93
%94 = load double, double* %10
%95 = fdiv double %94, 3.000000e+00
%96 = load [3 x double]*, [3 x double]** %3
%97 = getelementptr inbounds [3 x double], [3 x double]* %96, i64 2
%98 = getelementptr inbounds [3 x double], [3 x double]* %97, i64 0, i64 0
store double %95, double* %98
%99 = load double, double* %9
%100 = fneg double %99
%101 = fdiv double %100, 2.000000e+00
%102 = load [3 x double]*, [3 x double]** %3
%103 = getelementptr inbounds [3 x double], [3 x double]* %102, i64 0
%104 = getelementptr inbounds [3 x double], [3 x double]* %103, i64 0, i64 1
store double %101, double* %104
%105 = load double, double* %9
%106 = call double @sqrt(i32 3)
%107 = fmul double 2.000000e+00, %106
%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 [3 x double]*, [3 x double]** %3
%118 = getelementptr inbounds [3 x double], [3 x double]* %117, i64 0
%119 = getelementptr inbounds [3 x double], [3 x double]* %118, i64 0, i64 2
store double 0.000000e+00, double* %119
%120 = load double, double* %9
%121 = fneg double %120
%122 = call double @sqrt(i32 3)
%123 = fdiv double %121, %122
%124 = load [3 x double]*, [3 x double]** %3
%125 = getelementptr inbounds [3 x double], [3 x double]* %124, i64 1
%126 = getelementptr inbounds [3 x double], [3 x double]* %125, i64 0, i64 2
store double %123, double* %126
%127 = load double, double* %10
%128 = fdiv double %127, 3.000000e+00
%129 = load [3 x double]*, [3 x double]** %3
%130 = getelementptr inbounds [3 x double], [3 x double]* %129, i64 2
%131 = getelementptr inbounds [3 x double], [3 x double]* %130, i64 0, i64 2
store double %128, double* %131
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 double @sqrt(i32 %5)
%7 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%8 = load double, double* %7
%9 = fptosi double %8 to i32
%10 = tail call double @sqrt(i32 %9)
%11 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%12 = load double, double* %11
%13 = fptosi double %12 to i32
%14 = tail call double @sqrt(i32 %13)
%15 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%16 = load double, double* %15
%17 = fdiv double %16, %6
%18 = fdiv double %17, %10
%19 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%20 = load double, double* %19
%21 = fdiv double %20, %6
%22 = fdiv double %21, %14
%23 = fadd double %18, %22
%24 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
%25 = load double, double* %24
%26 = fdiv double %25, %10
%27 = fdiv double %26, %14
%28 = fadd double %23, %27
%29 = fdiv double %28, 3.000000e+00
%30 = tail call double @acos(double %29)
%31 = fadd double %6, %10
%32 = fadd double %31, %14
%33 = fmul double %32, 2.000000e+00
%34 = fdiv double %33, 3.000000e+00
%35 = fmul double %30, 5.000000e-01
%36 = tail call i32 @sin(double %35)
%37 = sitofp i32 %36 to double
%38 = fmul double %34, %37
%39 = fdiv double %32, 3.000000e+00
%40 = tail call i32 @cos(double %30)
%41 = shl nsw i32 %40, 1
%42 = or i32 %41, 1
%43 = mul nsw i32 %42, 3
%44 = tail call double @sqrt(i32 %43)
%45 = fmul double %39, %44
%46 = fmul double %38, 5.000000e-01
%47 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
store double %46, double* %47
%48 = tail call double @sqrt(i32 3)
%49 = fmul double %48, 2.000000e+00
%50 = fdiv double %38, %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
store double %50, double* %51
%52 = fdiv double %45, 3.000000e+00
%53 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
store double %52, double* %53
%54 = fneg double %38
%55 = fmul double %38, -5.000000e-01
%56 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
store double %55, double* %56
%57 = tail call double @sqrt(i32 3)
%58 = fmul double %57, 2.000000e+00
%59 = fdiv double %38, %58
%60 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double %59, double* %60
%61 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double %52, double* %61
%62 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double 0.000000e+00, double* %62
%63 = tail call double @sqrt(i32 3)
%64 = fdiv double %54, %63
%65 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
store double %64, double* %65
%66 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
store double %52, double* %66
ret void
}