#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*/ printf(char *, double, double);
double stub1(double);
void table(double x0, double deltaX, unsigned rows, double (*f)(double x)) {
  unsigned r = 0;
  for (r; r < rows; r++) {
    double x = x0 + r * deltaX;
    double y = (*f)(x);
    printf("%g:  %g\n", x, y);
  }
}


x86 assembly (clang, -O0):
<table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    118f <table+0x7f>
movsd  -0x8(%rbp),%xmm1
mov    -0x24(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsd  -0x30(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1130 <table+0x20>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<table>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
je     118a <table+0x7a>
mov    %rsi,%rbx
mov    %edi,%ebp
xorpd  %xmm2,%xmm2
lea    0xedc(%rip),%r14
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x18(%rsp)
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
call   *%rbx
movapd %xmm0,%xmm1
mov    %r14,%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  0xe7b(%rip),%xmm2
add    $0xffffffff,%ebp
jne    1140 <table+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%g: %g\0A\00"
define void @table(double %0, double %1, i32 %2, double (double)* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double (double)*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
store double (double)* %3, double (double)** %8
store i32 0, i32* %9
%12 = load i32, i32* %9
br label %13
13: ; preds = %29, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = icmp ult i32 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = load double, double* %5
%19 = load i32, i32* %9
%20 = uitofp i32 %19 to double
%21 = load double, double* %6
%22 = call double @llvm.fmuladd.f64(double %20, double %21, double %18)
store double %22, double* %10
%23 = load double (double)*, double (double)** %8
%24 = load double, double* %10
%25 = call double %23(double %24)
store double %25, double* %11
%26 = load double, double* %10
%27 = load double, double* %11
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %26, double %27)
br label %29
29: ; preds = %17
%30 = load i32, i32* %9
%31 = add i32 %30, 1
store i32 %31, i32* %9
br label %13
32: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%g: %g\0A\00"
define void @table(double %0, double %1, i32 %2, double (double)* nocapture %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %14, label %6
6: ; preds = %4, %6
%7 = phi i32 [ %12, %6 ], [ 0, %4 ]
%8 = uitofp i32 %7 to double
%9 = tail call double @llvm.fmuladd.f64(double %8, double %1, double %0)
%10 = tail call double %3(double %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %9, double %10)
%12 = add nuw i32 %7, 1
%13 = icmp eq i32 %12, %2
br i1 %13, label %14, label %6
14: ; preds = %6, %4
ret void
}