#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 floor(double);
int /*<<< orphan*/ printf(char *, double, double);
void tabulate(double (*f)(double), double first, double last, double incr) {
  double x;
  int i, num_intervals;
  num_intervals = floor((last - first) / incr);
  for (i = 0; i <= num_intervals; i++) {
    x = first + i * incr;
    printf("%10.5f %10.5f\n", x, f(x));
  }
}


x86 assembly (clang, -O0):
<tabulate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jg     11b8 <tabulate+0x98>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1159 <tabulate+0x39>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tabulate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r15
movsd  %xmm0,(%rsp)
subsd  %xmm0,%xmm1
movsd  %xmm2,0x8(%rsp)
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1040 <floor@plt>
test   %eax,%eax
js     1194 <tabulate+0x74>
mov    %eax,%ebp
add    $0x1,%ebp
xor    %ebx,%ebx
lea    0xea5(%rip),%r14
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
call   *%r15
movapd %xmm0,%xmm1
mov    %r14,%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1160 <tabulate+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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