#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 det_by_minor(double *, int);
int fabs(double);
int /*<<< orphan*/ random_seed(int);
int /*<<< orphan*/ uniform_01(int, double *);
int correct_det_by_minor(void) {
  double a[9], det, check;
  random_seed(123);
  uniform_01(9, a);
  det = det_by_minor(a, 3);
  check = 0.;
  check += a[0] * (a[4] * a[8] - a[5] * a[7]);
  check -= a[1] * (a[3] * a[8] - a[5] * a[6]);
  check += a[2] * (a[3] * a[7] - a[4] * a[6]);
  if (fabs(det / check - 1.0) < 1e-10)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<correct_det_by_minor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    $0x7b,%edi
call   1060 <random_seed@plt>
lea    -0x50(%rbp),%rsi
mov    $0x9,%edi
call   1050 <uniform_01@plt>
lea    -0x50(%rbp),%rdi
mov    $0x3,%esi
call   1030 <det_by_minor@plt>
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x60(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  0xd86(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd69(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ad <correct_det_by_minor+0x16d>
movl   $0x1,-0x4(%rbp)
jmp    12b4 <correct_det_by_minor+0x174>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<correct_det_by_minor>:
push   %rbx
sub    $0x50,%rsp
mov    $0x7b,%edi
call   1060 <random_seed@plt>
mov    %rsp,%rbx
mov    $0x9,%edi
mov    %rbx,%rsi
call   1050 <uniform_01@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <det_by_minor@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
movsd  0x38(%rsp),%xmm5
movapd %xmm2,%xmm6
mulsd  %xmm3,%xmm6
mulsd  %xmm1,%xmm3
mulsd  %xmm5,%xmm1
mulsd  %xmm4,%xmm5
subsd  %xmm5,%xmm6
mulsd  (%rsp),%xmm6
xorpd  %xmm5,%xmm5
addsd  %xmm6,%xmm5
movsd  0x30(%rsp),%xmm6
mulsd  %xmm6,%xmm4
subsd  %xmm4,%xmm3
mulsd  0x8(%rsp),%xmm3
subsd  %xmm3,%xmm5
mulsd  %xmm2,%xmm6
subsd  %xmm6,%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm5,%xmm1
divsd  %xmm1,%xmm0
addsd  0xe1b(%rip),%xmm0
call   1040 <fabs@plt>
xor    %ecx,%ecx
test   %eax,%eax
setle  %cl
mov    %ecx,%eax
add    $0x50,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @correct_det_by_minor() {
%1 = alloca [9 x double]
%2 = bitcast [9 x double]* %1 to i8*
%3 = tail call i32 @random_seed(i32 123)
%4 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 0
%5 = call i32 @uniform_01(i32 9, double* %4)
%6 = call double @det_by_minor(double* %4, i32 3)
%7 = load double, double* %4
%8 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 4
%9 = load double, double* %8
%10 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 8
%11 = load double, double* %10
%12 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 5
%13 = load double, double* %12
%14 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 7
%15 = load double, double* %14
%16 = fneg double %13
%17 = fmul double %15, %16
%18 = call double @llvm.fmuladd.f64(double %9, double %11, double %17)
%19 = call double @llvm.fmuladd.f64(double %7, double %18, double 0.000000e+00)
%20 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 1
%21 = load double, double* %20
%22 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 3
%23 = load double, double* %22
%24 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 6
%25 = load double, double* %24
%26 = fmul double %25, %16
%27 = call double @llvm.fmuladd.f64(double %23, double %11, double %26)
%28 = fneg double %21
%29 = call double @llvm.fmuladd.f64(double %28, double %27, double %19)
%30 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 2
%31 = load double, double* %30
%32 = fneg double %9
%33 = fmul double %25, %32
%34 = call double @llvm.fmuladd.f64(double %23, double %15, double %33)
%35 = call double @llvm.fmuladd.f64(double %31, double %34, double %29)
%36 = fdiv double %6, %35
%37 = fadd double %36, -1.000000e+00
%38 = call i32 @fabs(double %37)
%39 = icmp slt i32 %38, 1
%40 = zext i1 %39 to i32
ret i32 %40
}