#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*/ dd_dec_d(double *, double);
int /*<<< orphan*/ dd_exp(double *, double *);
int /*<<< orphan*/ dd_inc(double *, double *);
int dd_is_one(double const *);
int /*<<< orphan*/ dd_mlt(double *, double const *);
double log(double const);
int /*<<< orphan*/ printf(char *);
void dd_log(const double *a, double *b) {
  double acc[2];
  if (dd_is_one(a) == 1) {
    b[0] = 0.0;
    b[1] = 0.0;
    return;
  }
  if (a[0] <= 0.0) {
    printf("(dd_log): argument is not positive");
    b[0] = -1.0;
    b[0] = 0.0;
    return;
  }
  b[0] = log(a[0]);
  b[1] = 0.0;
  acc[0] = -b[0];
  acc[1] = -b[1];
  dd_exp(acc, acc);
  dd_mlt(acc, a);
  dd_inc(b, acc);
  dd_dec_d(b, 1.0);
}


x86 assembly (clang, -O0):
<dd_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <dd_is_one@plt>
cmp    $0x1,%eax
jne    11ae <dd_log+0x3e>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
jmp    128d <dd_log+0x11d>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     11eb <dd_log+0x7b>
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
movsd  0xe31(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    128d <dd_log+0x11d>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1090 <log@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <dd_exp@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <dd_mlt@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <dd_inc@plt>
mov    -0x10(%rbp),%rdi
movsd  0xd78(%rip),%xmm0
call   1060 <dd_dec_d@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dd_log>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1080 <dd_is_one@plt>
cmp    $0x1,%eax
jne    1197 <dd_log+0x27>
xorpd  %xmm0,%xmm0
movupd %xmm0,(%r14)
jmp    121c <dd_log+0xac>
movsd  (%rbx),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1209 <dd_log+0x99>
call   1090 <log@plt>
movsd  %xmm0,(%r14)
xorpd  0xe49(%rip),%xmm0
movq   $0x0,0x8(%r14)
movlpd %xmm0,(%rsp)
movabs $0x8000000000000000,%rax
mov    %rax,0x8(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r15,%rsi
call   1070 <dd_exp@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <dd_mlt@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <dd_inc@plt>
movsd  0xe11(%rip),%xmm0
mov    %r14,%rdi
call   1060 <dd_dec_d@plt>
jmp    121c <dd_log+0xac>
lea    0xe08(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"(dd_log): argument is not positive\00"
define void @dd_log(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca [2 x double]
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %3
%7 = call i32 @dd_is_one(double* %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 0
store double 0.000000e+00, double* %11
%12 = load double*, double** %4
%13 = getelementptr inbounds double, double* %12, i64 1
store double 0.000000e+00, double* %13
br label %55
14: ; preds = %2
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = fcmp ole double %17, 0.000000e+00
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double -1.000000e+00, double* %22
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 0
store double 0.000000e+00, double* %24
br label %55
25: ; preds = %14
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = call double @log(double %28)
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 0
store double %29, double* %31
%32 = load double*, double** %4
%33 = getelementptr inbounds double, double* %32, i64 1
store double 0.000000e+00, double* %33
%34 = load double*, double** %4
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = fneg double %36
%38 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
store double %37, double* %38
%39 = load double*, double** %4
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = fneg double %41
%43 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
store double %42, double* %43
%44 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%45 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%46 = call i32 @dd_exp(double* %44, double* %45)
%47 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%48 = load double*, double** %3
%49 = call i32 @dd_mlt(double* %47, double* %48)
%50 = load double*, double** %4
%51 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%52 = call i32 @dd_inc(double* %50, double* %51)
%53 = load double*, double** %4
%54 = call i32 @dd_dec_d(double* %53, double 1.000000e+00)
br label %55
55: ; preds = %25, %19, %9
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"(dd_log): argument is not positive\00"
define void @dd_log(double* %0, double* %1) {
%3 = alloca [2 x double]
%4 = bitcast [2 x double]* %3 to i8*
%5 = tail call i32 @dd_is_one(double* %0)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = bitcast double* %1 to i8*
br label %24
9: ; preds = %2
%10 = load double, double* %0
%11 = fcmp ugt double %10, 0.000000e+00
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %1
br label %24
14: ; preds = %9
%15 = tail call double @log(double %10)
store double %15, double* %1
%16 = getelementptr inbounds double, double* %1, i64 1
store double 0.000000e+00, double* %16
%17 = fneg double %15
%18 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
store double %17, double* %18
%19 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
store double -0.000000e+00, double* %19
%20 = call i32 @dd_exp(double* %18, double* %18)
%21 = call i32 @dd_mlt(double* %18, double* %0)
%22 = call i32 @dd_inc(double* %1, double* %18)
%23 = call i32 @dd_dec_d(double* %1, double 1.000000e+00)
br label %24
24: ; preds = %14, %12, %7
ret void
}