#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 fabs(double);
int /*<<< orphan*/ unit(double *);
int /*<<< orphan*/ v_mult(double *, double *, double *);
void makeCoordinateSystem(double *z, double *x, double *y) {
  double ax;
  double ay;
  double az;
  double edir[3];
  edir[0] = edir[1] = edir[2] = 0.0;
  ax = fabs(z[0]);
  ay = fabs(z[1]);
  az = fabs(z[2]);
  if (ax > ay) {
    if (ax > az) {
      if (ay > az)
        edir[2] = 1.0;
      else
        edir[1] = 1.0;
    } else
      edir[1] = 1.0;
  } else {
    if (ax < az)
      edir[0] = 1.0;
    else
      edir[2] = 1.0;
  }
  unit(z);
  v_mult(x, z, edir);
  unit(x);
  v_mult(y, z, x);
  unit(y);
}


x86 assembly (clang, -O0):
<makeCoordinateSystem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xea5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movaps 0xe8c(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movaps 0xe73(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11fc <makeCoordinateSystem+0xdc>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11ea <makeCoordinateSystem+0xca>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11d8 <makeCoordinateSystem+0xb8>
movsd  0xe42(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11e5 <makeCoordinateSystem+0xc5>
movsd  0xe30(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11f7 <makeCoordinateSystem+0xd7>
movsd  0xe1e(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1234 <makeCoordinateSystem+0x114>
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1222 <makeCoordinateSystem+0x102>
movsd  0xdf8(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    122f <makeCoordinateSystem+0x10f>
movsd  0xde6(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1234 <makeCoordinateSystem+0x114>
mov    -0x8(%rbp),%rdi
call   1030 <unit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <v_mult@plt>
mov    -0x10(%rbp),%rdi
call   1030 <unit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <v_mult@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeCoordinateSystem>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
movdqu (%rdi),%xmm1
movdqa 0xeb2(%rip),%xmm2
pand   %xmm2,%xmm1
movq   0x10(%rdi),%xmm0
pand   %xmm2,%xmm0
pshufd $0xee,%xmm1,%xmm2
ucomisd %xmm2,%xmm1
jbe    1183 <makeCoordinateSystem+0x63>
ucomisd %xmm0,%xmm1
jbe    1172 <makeCoordinateSystem+0x52>
ucomisd %xmm0,%xmm2
ja     1199 <makeCoordinateSystem+0x79>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x8(%rsp)
jmp    11a8 <makeCoordinateSystem+0x88>
ucomisd %xmm1,%xmm0
jbe    1199 <makeCoordinateSystem+0x79>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rsp)
jmp    11a8 <makeCoordinateSystem+0x88>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <unit@plt>
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <v_mult@plt>
mov    %r15,%rdi
call   1030 <unit@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <v_mult@plt>
mov    %r14,%rdi
call   1030 <unit@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @makeCoordinateSystem(double* %0, double* %1, double* %2) {
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %4 to i8*
%6 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%7 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%8 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%9 = bitcast [3 x double]* %4 to i8*
%10 = bitcast double* %0 to <2 x double>*
%11 = load <2 x double>, <2 x double>* %10
%12 = call <2 x double> @llvm.fabs.v2f64(<2 x double> %11)
%13 = getelementptr inbounds double, double* %0, i64 2
%14 = load double, double* %13
%15 = tail call double @llvm.fabs.f64(double %14)
%16 = extractelement <2 x double> %12, i64 0
%17 = extractelement <2 x double> %12, i64 1
%18 = fcmp ogt double %16, %17
br i1 %18, label %19, label %26
19: ; preds = %3
%20 = fcmp ogt double %16, %15
br i1 %20, label %21, label %25
21: ; preds = %19
%22 = fcmp ogt double %17, %15
br i1 %22, label %23, label %24
23: ; preds = %21
store double 1.000000e+00, double* %6
br label %30
24: ; preds = %21
store double 1.000000e+00, double* %7
br label %30
25: ; preds = %19
store double 1.000000e+00, double* %7
br label %30
26: ; preds = %3
%27 = fcmp olt double %16, %15
br i1 %27, label %28, label %29
28: ; preds = %26
store double 1.000000e+00, double* %8
br label %30
29: ; preds = %26
store double 1.000000e+00, double* %6
br label %30
30: ; preds = %28, %29, %25, %24, %23
%31 = tail call i32 @unit(double* %0)
%32 = call i32 @v_mult(double* %1, double* %0, double* %8)
%33 = call i32 @unit(double* %1)
%34 = call i32 @v_mult(double* %2, double* %0, double* %1)
%35 = call i32 @unit(double* %2)
ret void
}