#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*/ differential(int /*<<< orphan*/ (*)(double), double, double);
int /*<<< orphan*/ log(double);
int /*<<< orphan*/ printf(char *, double, double, double, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int main() {
  double h = 0;
  double x = 0;
  x = 1.8;
  h = 0.1;
  printf("h = %2.5lf, f(%2.5lf + %2.5lf) = %10.5lf, f' = %10.5lf\n", h, x, h,
         log(x + h), differential(log, h, x));
  h = 0.01;
  printf("h = %2.5lf, f(%2.5lf + %2.5lf) = %10.5lf, f' = %10.5lf\n", h, x, h,
         log(x + h), differential(log, h, x));
  h = 0.001;
  printf("h = %2.5lf, f(%2.5lf + %2.5lf) = %10.5lf, f' = %10.5lf\n", h, x, h,
         log(x + h), differential(log, h, x));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,-0x5c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    0x2e4b(%rip),%rdi
call   1030 <differential@plt>
movsd  -0x78(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
mov    -0x5c(%rbp),%esi
mov    %eax,%edx
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
movsd  0xe3e(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,-0x3c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    0x2dd8(%rip),%rdi
call   1030 <differential@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
mov    -0x3c(%rbp),%esi
mov    %eax,%edx
lea    0xdf0(%rip),%rdi
call   1040 <printf@plt>
movsd  0xdc3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    0x2d65(%rip),%rdi
call   1030 <differential@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xd7d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
movsd  0xed4(%rip),%xmm0
call   1050 <log@plt>
mov    %eax,%ebp
mov    0x2eae(%rip),%r14
movsd  0xec6(%rip),%xmm0
movsd  0xec6(%rip),%xmm1
mov    %r14,%rdi
call   1030 <differential@plt>
lea    0xedf(%rip),%rbx
mov    %rbx,%rdi
movsd  0xea4(%rip),%xmm0
movsd  0xea4(%rip),%xmm1
movaps %xmm0,%xmm2
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
movsd  0xe98(%rip),%xmm0
call   1050 <log@plt>
mov    %eax,%ebp
movsd  0xe91(%rip),%xmm0
mov    %r14,%rdi
movsd  0xe76(%rip),%xmm1
call   1030 <differential@plt>
mov    %rbx,%rdi
movsd  0xe76(%rip),%xmm0
movsd  0xe5e(%rip),%xmm1
movaps %xmm0,%xmm2
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
movsd  0xe62(%rip),%xmm0
call   1050 <log@plt>
mov    %eax,%ebp
movsd  0xe5b(%rip),%xmm0
mov    %r14,%rdi
movsd  0xe30(%rip),%xmm1
call   1030 <differential@plt>
mov    %rbx,%rdi
movsd  0xe40(%rip),%xmm0
movsd  0xe18(%rip),%xmm1
movaps %xmm0,%xmm2
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"h = %2.5lf, f(%2.5lf + %2.5lf) = %10.5lf, f' = %10.5lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
store double 1.800000e+00, double* %3
store double 1.000000e-01, double* %2
%4 = load double, double* %2
%5 = load double, double* %3
%6 = load double, double* %2
%7 = load double, double* %3
%8 = load double, double* %2
%9 = fadd double %7, %8
%10 = call i32 @log(double %9)
%11 = load double, double* %2
%12 = load double, double* %3
%13 = call i32 @differential(i32 (double)* @log, double %11, double %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double %4, double %5, double %6, i32 %10, i32 %13)
store double 1.000000e-02, double* %2
%15 = load double, double* %2
%16 = load double, double* %3
%17 = load double, double* %2
%18 = load double, double* %3
%19 = load double, double* %2
%20 = fadd double %18, %19
%21 = call i32 @log(double %20)
%22 = load double, double* %2
%23 = load double, double* %3
%24 = call i32 @differential(i32 (double)* @log, double %22, double %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double %15, double %16, double %17, i32 %21, i32 %24)
store double 1.000000e-03, double* %2
%26 = load double, double* %2
%27 = load double, double* %3
%28 = load double, double* %2
%29 = load double, double* %3
%30 = load double, double* %2
%31 = fadd double %29, %30
%32 = call i32 @log(double %31)
%33 = load double, double* %2
%34 = load double, double* %3
%35 = call i32 @differential(i32 (double)* @log, double %33, double %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double %26, double %27, double %28, i32 %32, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"h = %2.5lf, f(%2.5lf + %2.5lf) = %10.5lf, f' = %10.5lf\0A\00"
define i32 @main() {
%1 = tail call i32 @log(double 0x3FFE666666666667)
%2 = tail call i32 @differential(i32 (double)* @log, double 1.000000e-01, double 1.800000e+00)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double 1.000000e-01, double 1.800000e+00, double 1.000000e-01, i32 %1, i32 %2)
%4 = tail call i32 @log(double 1.810000e+00)
%5 = tail call i32 @differential(i32 (double)* @log, double 1.000000e-02, double 1.800000e+00)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double 1.000000e-02, double 1.800000e+00, double 1.000000e-02, i32 %4, i32 %5)
%7 = tail call i32 @log(double 1.801000e+00)
%8 = tail call i32 @differential(i32 (double)* @log, double 1.000000e-03, double 1.800000e+00)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double 1.000000e-03, double 1.800000e+00, double 1.000000e-03, i32 %7, i32 %8)
ret i32 0
}