#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 /*<<< orphan*/ mcon(double *, double *, double *, double *);
void cdivid(double ar, double ai, double br, double bi, double *cr,
            double *ci) {
  double r, d, t, infin;
  if (br == 0.0 && bi == 0.0) {
    mcon(&t, &infin, &t, &t);
    *cr = infin;
    *ci = infin;
    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    $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
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a6 <cdivid+0x86>
jp     11a6 <cdivid+0x86>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a6 <cdivid+0x86>
jp     11a6 <cdivid+0x86>
lea    -0x48(%rbp),%rcx
lea    -0x50(%rbp),%rsi
mov    %rcx,%rdi
mov    %rcx,%rdx
call   1040 <mcon@plt>
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12e7 <cdivid+0x1c7>
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
jge    125d <cdivid+0x13d>
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    12e7 <cdivid+0x1c7>
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    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdivid>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm2
jne    1168 <cdivid+0x48>
jp     1168 <cdivid+0x48>
ucomisd %xmm4,%xmm3
jne    1168 <cdivid+0x48>
jp     1168 <cdivid+0x48>
lea    0x20(%rsp),%rsi
lea    0x28(%rsp),%rcx
mov    %rcx,%rdi
mov    %rcx,%rdx
call   1040 <mcon@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r15)
jmp    1230 <cdivid+0x110>
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    11e4 <cdivid+0xc4>
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    1230 <cdivid+0x110>
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    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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