#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 */
int /*<<< orphan*/ qd_mul_d(double const *, double, double *);
int /*<<< orphan*/ qd_renorm5(double *, double *, double *, double *, double *);
int /*<<< orphan*/ qd_sub(double const *, double *, double *);
void qd_div(const double *a, const double *b, double *c) {
  double q0, q1, q2, q3, q4;
  double acc[4];
  double r[4];
  q0 = a[0] / b[0];
  qd_mul_d(b, q0, acc);
  qd_sub(a, acc, r);
  q1 = r[0] / b[0];
  qd_mul_d(b, q1, acc);
  qd_sub(r, acc, r);
  q2 = r[0] / b[0];
  qd_mul_d(b, q2, acc);
  qd_sub(r, acc, r);
  q3 = r[0] / b[0];
  qd_mul_d(b, q3, acc);
  qd_sub(r, acc, r);
  q4 = r[0] / b[0];
  qd_renorm5(&q0, &q1, &q2, &q3, &q4);
  c[0] = q0;
  c[1] = q1;
  c[2] = q2;
  c[3] = q3;
}


x86 assembly (clang, -O0):
<qd_div>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
call   1050 <qd_mul_d@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1030 <qd_sub@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
call   1050 <qd_mul_d@plt>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1030 <qd_sub@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
call   1050 <qd_mul_d@plt>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1030 <qd_sub@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x38(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
call   1050 <qd_mul_d@plt>
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1030 <qd_sub@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
call   1040 <qd_renorm5@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qd_div>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r13
movsd  (%rdi),%xmm0
divsd  (%rsi),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x50(%rsp),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1050 <qd_mul_d@plt>
lea    0x30(%rsp),%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <qd_sub@plt>
movsd  0x30(%rsp),%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <qd_mul_d@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <qd_sub@plt>
movsd  0x30(%rsp),%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <qd_mul_d@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <qd_sub@plt>
movsd  0x30(%rsp),%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <qd_mul_d@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <qd_sub@plt>
movsd  0x30(%rsp),%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x28(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x28(%rsp),%r8
call   1040 <qd_renorm5@plt>
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%r14)
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @qd_div(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca [4 x double]
%13 = alloca [4 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
%17 = load double*, double** %5
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = fdiv double %16, %19
store double %20, double* %7
%21 = load double*, double** %5
%22 = load double, double* %7
%23 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%24 = call i32 @qd_mul_d(double* %21, double %22, double* %23)
%25 = load double*, double** %4
%26 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%27 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%28 = call i32 @qd_sub(double* %25, double* %26, double* %27)
%29 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%30 = load double, double* %29
%31 = load double*, double** %5
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = fdiv double %30, %33
store double %34, double* %8
%35 = load double*, double** %5
%36 = load double, double* %8
%37 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%38 = call i32 @qd_mul_d(double* %35, double %36, double* %37)
%39 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%40 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%41 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%42 = call i32 @qd_sub(double* %39, double* %40, double* %41)
%43 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%44 = load double, double* %43
%45 = load double*, double** %5
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = fdiv double %44, %47
store double %48, double* %9
%49 = load double*, double** %5
%50 = load double, double* %9
%51 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%52 = call i32 @qd_mul_d(double* %49, double %50, double* %51)
%53 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%54 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%55 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%56 = call i32 @qd_sub(double* %53, double* %54, double* %55)
%57 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%58 = load double, double* %57
%59 = load double*, double** %5
%60 = getelementptr inbounds double, double* %59, i64 0
%61 = load double, double* %60
%62 = fdiv double %58, %61
store double %62, double* %10
%63 = load double*, double** %5
%64 = load double, double* %10
%65 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%66 = call i32 @qd_mul_d(double* %63, double %64, double* %65)
%67 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%68 = getelementptr inbounds [4 x double], [4 x double]* %12, i64 0, i64 0
%69 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%70 = call i32 @qd_sub(double* %67, double* %68, double* %69)
%71 = getelementptr inbounds [4 x double], [4 x double]* %13, i64 0, i64 0
%72 = load double, double* %71
%73 = load double*, double** %5
%74 = getelementptr inbounds double, double* %73, i64 0
%75 = load double, double* %74
%76 = fdiv double %72, %75
store double %76, double* %11
%77 = call i32 @qd_renorm5(double* %7, double* %8, double* %9, double* %10, double* %11)
%78 = load double, double* %7
%79 = load double*, double** %6
%80 = getelementptr inbounds double, double* %79, i64 0
store double %78, double* %80
%81 = load double, double* %8
%82 = load double*, double** %6
%83 = getelementptr inbounds double, double* %82, i64 1
store double %81, double* %83
%84 = load double, double* %9
%85 = load double*, double** %6
%86 = getelementptr inbounds double, double* %85, i64 2
store double %84, double* %86
%87 = load double, double* %10
%88 = load double*, double** %6
%89 = getelementptr inbounds double, double* %88, i64 3
store double %87, double* %89
ret void
}

LLVM IR (-O2):
define void @qd_div(double* %0, double* %1, double* nocapture writeonly %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca [4 x double]
%10 = alloca [4 x double]
%11 = bitcast double* %4 to i8*
%12 = bitcast double* %5 to i8*
%13 = bitcast double* %6 to i8*
%14 = bitcast double* %7 to i8*
%15 = bitcast double* %8 to i8*
%16 = bitcast [4 x double]* %9 to i8*
%17 = bitcast [4 x double]* %10 to i8*
%18 = load double, double* %0
%19 = load double, double* %1
%20 = fdiv double %18, %19
store double %20, double* %4
%21 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 0
%22 = call i32 @qd_mul_d(double* %1, double %20, double* %21)
%23 = getelementptr inbounds [4 x double], [4 x double]* %10, i64 0, i64 0
%24 = call i32 @qd_sub(double* %0, double* %21, double* %23)
%25 = load double, double* %23
%26 = load double, double* %1
%27 = fdiv double %25, %26
store double %27, double* %5
%28 = call i32 @qd_mul_d(double* %1, double %27, double* %21)
%29 = call i32 @qd_sub(double* %23, double* %21, double* %23)
%30 = load double, double* %23
%31 = load double, double* %1
%32 = fdiv double %30, %31
store double %32, double* %6
%33 = call i32 @qd_mul_d(double* %1, double %32, double* %21)
%34 = call i32 @qd_sub(double* %23, double* %21, double* %23)
%35 = load double, double* %23
%36 = load double, double* %1
%37 = fdiv double %35, %36
store double %37, double* %7
%38 = call i32 @qd_mul_d(double* %1, double %37, double* %21)
%39 = call i32 @qd_sub(double* %23, double* %21, double* %23)
%40 = load double, double* %23
%41 = load double, double* %1
%42 = fdiv double %40, %41
store double %42, double* %8
%43 = call i32 @qd_renorm5(double* %4, double* %5, double* %6, double* %7, double* %8)
%44 = load double, double* %4
store double %44, double* %2
%45 = load double, double* %5
%46 = getelementptr inbounds double, double* %2, i64 1
store double %45, double* %46
%47 = load double, double* %6
%48 = getelementptr inbounds double, double* %2, i64 2
store double %47, double* %48
%49 = load double, double* %7
%50 = getelementptr inbounds double, double* %2, i64 3
store double %49, double* %50
ret void
}