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


x86 assembly (clang, -O0):
<set_monocli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_monocli>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  (%rsi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1161 <set_monocli+0x21>
sqrtsd %xmm0,%xmm0
jmp    116a <set_monocli+0x2a>
call   1060 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rbx),%xmm0
ucomisd %xmm1,%xmm0
jb     1181 <set_monocli+0x41>
sqrtsd %xmm0,%xmm3
jmp    118a <set_monocli+0x4a>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm3
movsd  0x40(%rbx),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119f <set_monocli+0x5f>
sqrtsd %xmm0,%xmm2
jmp    11b4 <set_monocli+0x74>
movsd  %xmm3,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movapd %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%r14)
movsd  %xmm3,0x20(%r14)
movsd  0x10(%rbx),%xmm0
divsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
call   1030 <acos@plt>
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x40(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @set_monocli([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
store [3 x double]* %0, [3 x double]** %3
store [3 x double]* %1, [3 x double]** %4
%9 = load [3 x double]*, [3 x double]** %4
%10 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0
%11 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%12 = load double, double* %11
%13 = call double @sqrt(double %12)
store double %13, double* %5
%14 = load [3 x double]*, [3 x double]** %4
%15 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 1
%16 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 1
%17 = load double, double* %16
%18 = call double @sqrt(double %17)
store double %18, double* %6
%19 = load [3 x double]*, [3 x double]** %4
%20 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 2
%21 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 2
%22 = load double, double* %21
%23 = call double @sqrt(double %22)
store double %23, double* %7
%24 = load double, double* %5
%25 = load [3 x double]*, [3 x double]** %3
%26 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0
%27 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 0, i64 0
store double %24, double* %27
%28 = load double, double* %6
%29 = load [3 x double]*, [3 x double]** %3
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 1
%31 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0, i64 1
store double %28, double* %31
%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 2
%35 = load double, double* %34
%36 = load double, double* %5
%37 = fdiv double %35, %36
%38 = load double, double* %7
%39 = fdiv double %37, %38
%40 = call double @acos(double %39)
store double %40, double* %8
%41 = load double, double* %7
%42 = load double, double* %8
%43 = call double @cos(double %42)
%44 = fmul double %41, %43
%45 = load [3 x double]*, [3 x double]** %3
%46 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 0
%47 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 0, i64 2
store double %44, double* %47
%48 = load double, double* %7
%49 = load double, double* %8
%50 = call double @sin(double %49)
%51 = fmul double %48, %50
%52 = load [3 x double]*, [3 x double]** %3
%53 = getelementptr inbounds [3 x double], [3 x double]* %52, i64 2
%54 = getelementptr inbounds [3 x double], [3 x double]* %53, i64 0, i64 2
store double %51, double* %54
ret void
}

LLVM IR (-O2):
define void @set_monocli([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 = tail call double @sqrt(double %4)
%6 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%7 = load double, double* %6
%8 = tail call double @sqrt(double %7)
%9 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%10 = load double, double* %9
%11 = tail call double @sqrt(double %10)
%12 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
store double %5, double* %12
%13 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double %8, double* %13
%14 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%15 = load double, double* %14
%16 = fdiv double %15, %5
%17 = fdiv double %16, %11
%18 = tail call double @acos(double %17)
%19 = tail call double @cos(double %18)
%20 = fmul double %11, %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double %20, double* %21
%22 = tail call double @sin(double %18)
%23 = fmul double %11, %22
%24 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
store double %23, double* %24
ret void
}