#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 INFINITY;
scalar_t__ fabs(double);
void cdivid(double ar, double ai, double br, double bi, double *cr,
            double *ci) {
  double d, r;
  if (br == 0. && bi == 0.) {
    *cr = *ci = INFINITY;
  } else if (fabs(br) >= fabs(bi)) {
    r = bi / br;
    d = br + r * bi;
    *cr = (ar + ai * r) / d;
    *ci = (ai - ar * r) / d;
  } else {
    r = br / bi;
    d = bi + r * br;
    *cr = (ar * r + ai) / d;
    *ci = (ai * r - ar) / 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    1184 <cdivid+0x74>
jp     1184 <cdivid+0x74>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1184 <cdivid+0x74>
jp     1184 <cdivid+0x74>
mov    0x2e7d(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12ca <cdivid+0x1ba>
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
jl     123b <cdivid+0x12b>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12c5 <cdivid+0x1b5>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x40(%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  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12ca <cdivid+0x1ba>
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    114d <cdivid+0x3d>
jp     114d <cdivid+0x3d>
ucomisd %xmm4,%xmm3
jne    114d <cdivid+0x3d>
jp     114d <cdivid+0x3d>
mov    0x2eae(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,(%r14)
movsd  %xmm0,(%r15)
jmp    121b <cdivid+0x10b>
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    11ce <cdivid+0xbe>
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
movsd  %xmm0,(%r14)
jmp    121b <cdivid+0x10b>
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
movsd  %xmm2,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@INFINITY = 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 %12
10: ; preds = %6
%11 = load double, double* @INFINITY
store double %11, double* %5
store double %11, double* %4
br label %32
12: ; preds = %6
%13 = tail call i64 @fabs(double %2)
%14 = tail call i64 @fabs(double %3)
%15 = icmp slt i64 %13, %14
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = fdiv double %3, %2
%18 = tail call double @llvm.fmuladd.f64(double %17, double %3, double %2)
%19 = tail call double @llvm.fmuladd.f64(double %1, double %17, double %0)
%20 = fdiv double %19, %18
store double %20, double* %4
%21 = fneg double %0
%22 = tail call double @llvm.fmuladd.f64(double %21, double %17, double %1)
%23 = fdiv double %22, %18
store double %23, double* %5
br label %32
24: ; preds = %12
%25 = fdiv double %2, %3
%26 = tail call double @llvm.fmuladd.f64(double %25, double %2, double %3)
%27 = tail call double @llvm.fmuladd.f64(double %0, double %25, double %1)
%28 = fdiv double %27, %26
store double %28, double* %4
%29 = fneg double %0
%30 = tail call double @llvm.fmuladd.f64(double %1, double %25, double %29)
%31 = fdiv double %30, %26
store double %31, double* %5
br label %32
32: ; preds = %16, %24, %10
ret void
}