#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 DBL_MAX;
scalar_t__ fabs(double const);
void cdivid(const double ar, const double ai, const double br, const double bi,
            double *cr, double *ci) {
  double r, d;
  if (br == 0.0 && bi == 0.0) {
    *cr = DBL_MAX;
    *ci = DBL_MAX;
    return;
  }
  if (fabs(br) < fabs(bi)) {
    r = br / bi;
    d = bi + r * br;
    *cr = (ar * r + ai) / d;
    *ci = (ai * r - ar) / d;
    return;
  }
  r = bi / br;
  d = br + r * bi;
  *cr = (ar + ai * r) / d;
  *ci = (ai - ar * r) / d;
}


x86 assembly (clang, -O0):
<cdivid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    118f <cdivid+0x7f>
jp     118f <cdivid+0x7f>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    118f <cdivid+0x7f>
jp     118f <cdivid+0x7f>
mov    0x2e75(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2e62(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12d0 <cdivid+0x1c0>
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jge    1246 <cdivid+0x136>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x38(%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  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12d0 <cdivid+0x1c0>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdivid>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm2
jne    114c <cdivid+0x3c>
jp     114c <cdivid+0x3c>
ucomisd %xmm4,%xmm3
jne    114c <cdivid+0x3c>
jp     114c <cdivid+0x3c>
mov    0x2ea6(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%r15)
movsd  (%rax),%xmm0
jmp    1214 <cdivid+0x104>
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm3,(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jge    11c8 <cdivid+0xb8>
movsd  0x8(%rsp),%xmm4
movapd %xmm4,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm4
addsd  %xmm1,%xmm4
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm4,%xmm1
movsd  %xmm1,(%r15)
mulsd  %xmm2,%xmm0
subsd  %xmm3,%xmm0
divsd  %xmm4,%xmm0
jmp    1214 <cdivid+0x104>
movsd  (%rsp),%xmm4
movapd %xmm4,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm4
addsd  %xmm1,%xmm4
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm3
addsd  %xmm3,%xmm1
divsd  %xmm4,%xmm1
movsd  %xmm1,(%r15)
mulsd  %xmm3,%xmm0
subsd  %xmm0,%xmm2
divsd  %xmm4,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
define void @cdivid(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
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
%15 = load double, double* %9
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %25
17: ; preds = %6
%18 = load double, double* %10
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load double, double* @DBL_MAX
%22 = load double*, double** %11
store double %21, double* %22
%23 = load double, double* @DBL_MAX
%24 = load double*, double** %12
store double %23, double* %24
br label %77
25: ; preds = %17, %6
%26 = load double, double* %9
%27 = call i64 @fabs(double %26)
%28 = load double, double* %10
%29 = call i64 @fabs(double %28)
%30 = icmp slt i64 %27, %29
br i1 %30, label %31, label %54
31: ; preds = %25
%32 = load double, double* %9
%33 = load double, double* %10
%34 = fdiv double %32, %33
store double %34, double* %13
%35 = load double, double* %10
%36 = load double, double* %13
%37 = load double, double* %9
%38 = call double @llvm.fmuladd.f64(double %36, double %37, double %35)
store double %38, double* %14
%39 = load double, double* %7
%40 = load double, double* %13
%41 = load double, double* %8
%42 = call double @llvm.fmuladd.f64(double %39, double %40, double %41)
%43 = load double, double* %14
%44 = fdiv double %42, %43
%45 = load double*, double** %11
store double %44, double* %45
%46 = load double, double* %8
%47 = load double, double* %13
%48 = load double, double* %7
%49 = fneg double %48
%50 = call double @llvm.fmuladd.f64(double %46, double %47, double %49)
%51 = load double, double* %14
%52 = fdiv double %50, %51
%53 = load double*, double** %12
store double %52, double* %53
br label %77
54: ; preds = %25
%55 = load double, double* %10
%56 = load double, double* %9
%57 = fdiv double %55, %56
store double %57, double* %13
%58 = load double, double* %9
%59 = load double, double* %13
%60 = load double, double* %10
%61 = call double @llvm.fmuladd.f64(double %59, double %60, double %58)
store double %61, double* %14
%62 = load double, double* %7
%63 = load double, double* %8
%64 = load double, double* %13
%65 = call double @llvm.fmuladd.f64(double %63, double %64, double %62)
%66 = load double, double* %14
%67 = fdiv double %65, %66
%68 = load double*, double** %11
store double %67, double* %68
%69 = load double, double* %8
%70 = load double, double* %7
%71 = load double, double* %13
%72 = fneg double %70
%73 = call double @llvm.fmuladd.f64(double %72, double %71, double %69)
%74 = load double, double* %14
%75 = fdiv double %73, %74
%76 = load double*, double** %12
store double %75, double* %76
br label %77
77: ; preds = %54, %31, %20
ret void
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
define void @cdivid(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fcmp oeq double %2, 0.000000e+00
%8 = fcmp oeq double %3, 0.000000e+00
%9 = and i1 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load double, double* @DBL_MAX
store double %11, double* %4
%12 = load double, double* @DBL_MAX
br label %33
13: ; preds = %6
%14 = tail call i64 @fabs(double %2)
%15 = tail call i64 @fabs(double %3)
%16 = icmp slt i64 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = fdiv double %2, %3
%19 = tail call double @llvm.fmuladd.f64(double %18, double %2, double %3)
%20 = tail call double @llvm.fmuladd.f64(double %0, double %18, double %1)
%21 = fdiv double %20, %19
store double %21, double* %4
%22 = fneg double %0
%23 = tail call double @llvm.fmuladd.f64(double %1, double %18, double %22)
%24 = fdiv double %23, %19
br label %33
25: ; preds = %13
%26 = fdiv double %3, %2
%27 = tail call double @llvm.fmuladd.f64(double %26, double %3, double %2)
%28 = tail call double @llvm.fmuladd.f64(double %1, double %26, double %0)
%29 = fdiv double %28, %27
store double %29, double* %4
%30 = fneg double %0
%31 = tail call double @llvm.fmuladd.f64(double %30, double %26, double %1)
%32 = fdiv double %31, %27
br label %33
33: ; preds = %25, %17, %10
%34 = phi double [ %32, %25 ], [ %24, %17 ], [ %12, %10 ]
store double %34, double* %5
ret void
}