#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 */
scalar_t__ fabs(double);
int SuiteSparse_divcomplex(double ar, double ai, double br, double bi,
                           double *cr, double *ci) {
  double tr, ti, r, den;
  if (fabs(br) >= fabs(bi)) {
    r = bi / br;
    den = br + r * bi;
    tr = (ar + ai * r) / den;
    ti = (ai - ar * r) / den;
  } else {
    r = br / bi;
    den = r * br + bi;
    tr = (ar * r + ai) / den;
    ti = (ai * r - ar) / den;
  }
  *cr = tr;
  *ci = ti;
  return (den == 0.);
}


x86 assembly (clang, -O0):
<SuiteSparse_divcomplex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jl     11e5 <SuiteSparse_divcomplex+0xd5>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1269 <SuiteSparse_divcomplex+0x159>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SuiteSparse_divcomplex>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movaps %xmm3,(%rsp)
movaps %xmm1,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm2,0x10(%rsp)
movaps %xmm2,%xmm0
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jge    11a4 <SuiteSparse_divcomplex+0x94>
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
movapd (%rsp),%xmm2
divsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
movapd 0xe92(%rip),%xmm1
movapd 0x20(%rsp),%xmm4
xorpd  %xmm4,%xmm1
movapd 0x30(%rsp),%xmm3
unpcklpd %xmm3,%xmm4
unpcklpd %xmm0,%xmm0
mulpd  %xmm4,%xmm0
unpcklpd %xmm1,%xmm3
addpd  %xmm0,%xmm3
movapd %xmm2,%xmm0
unpcklpd %xmm2,%xmm0
divpd  %xmm0,%xmm3
movapd %xmm3,%xmm0
jmp    11f7 <SuiteSparse_divcomplex+0xe7>
movapd (%rsp),%xmm2
movapd %xmm2,%xmm0
movapd 0x10(%rsp),%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movapd 0xe39(%rip),%xmm1
movapd 0x20(%rsp),%xmm4
xorpd  %xmm4,%xmm1
movapd 0x30(%rsp),%xmm3
unpcklpd %xmm3,%xmm4
unpcklpd %xmm1,%xmm3
unpcklpd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
addpd  %xmm4,%xmm0
movapd %xmm2,%xmm1
unpcklpd %xmm2,%xmm1
divpd  %xmm1,%xmm0
movlpd %xmm0,(%r15)
movhpd %xmm0,(%r14)
xorpd  %xmm0,%xmm0
cmpeqsd %xmm2,%xmm0
movq   %xmm0,%rax
and    $0x1,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @SuiteSparse_divcomplex(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = tail call i64 @fabs(double %2)
%8 = tail call i64 @fabs(double %3)
%9 = icmp slt i64 %7, %8
br i1 %9, label %24, label %10
10: ; preds = %6
%11 = fdiv double %3, %2
%12 = tail call double @llvm.fmuladd.f64(double %11, double %3, double %2)
%13 = fneg double %0
%14 = insertelement <2 x double> poison, double %1, i64 0
%15 = insertelement <2 x double> %14, double %13, i64 1
%16 = insertelement <2 x double> poison, double %11, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = insertelement <2 x double> poison, double %0, i64 0
%19 = insertelement <2 x double> %18, double %1, i64 1
%20 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %17, <2 x double> %19)
%21 = insertelement <2 x double> poison, double %12, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = fdiv <2 x double> %20, %22
br label %38
24: ; preds = %6
%25 = fdiv double %2, %3
%26 = tail call double @llvm.fmuladd.f64(double %25, double %2, double %3)
%27 = fneg double %0
%28 = insertelement <2 x double> poison, double %0, i64 0
%29 = insertelement <2 x double> %28, double %1, i64 1
%30 = insertelement <2 x double> poison, double %25, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x double> poison, double %1, i64 0
%33 = insertelement <2 x double> %32, double %27, i64 1
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %31, <2 x double> %33)
%35 = insertelement <2 x double> poison, double %26, i64 0
%36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
%37 = fdiv <2 x double> %34, %36
br label %38
38: ; preds = %24, %10
%39 = phi double [ %12, %10 ], [ %26, %24 ]
%40 = phi <2 x double> [ %23, %10 ], [ %37, %24 ]
%41 = extractelement <2 x double> %40, i64 0
store double %41, double* %4
%42 = extractelement <2 x double> %40, i64 1
store double %42, double* %5
%43 = fcmp oeq double %39, 0.000000e+00
%44 = zext i1 %43 to i32
ret i32 %44
}