#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*/ err_msg(char *);
double evaluate(int *);
double get_ivar(int /*<<< orphan*/);
scalar_t__ parse_expr(char *, int *, int *);
int /*<<< orphan*/ set_ivar(int /*<<< orphan*/, double);
int eval_fun_table(int n, double xlo, double xhi, char *formula, double *y) {
  int i;
  double dx;
  double oldt;
  int command[200];
  if (parse_expr(formula, command, &i)) {
    err_msg("Illegal formula...");
    return (0);
  }
  oldt = get_ivar(0);
  dx = (xhi - xlo) / ((double)(n - 1));
  for (i = 0; i < n; i++) {
    set_ivar(0, dx * i + xlo);
    y[i] = evaluate(command);
  }
  set_ivar(0, oldt);
  return (1);
}


x86 assembly (clang, -O0):
<eval_fun_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x360,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x360(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <parse_expr@plt>
cmp    $0x0,%rax
je     11a6 <eval_fun_table+0x56>
lea    0xe6b(%rip),%rdi
call   1060 <err_msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    123a <eval_fun_table+0xea>
xor    %edi,%edi
call   1050 <get_ivar@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1227 <eval_fun_table+0xd7>
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xor    %edi,%edi
call   1030 <set_ivar@plt>
lea    -0x360(%rbp),%rdi
call   1040 <evaluate@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d6 <eval_fun_table+0x86>
movsd  -0x40(%rbp),%xmm0
xor    %edi,%edi
call   1030 <set_ivar@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x360,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_fun_table>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x348,%rsp
mov    %rdx,%r14
mov    %rsi,%rax
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %edi,%ebx
lea    0x20(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1070 <parse_expr@plt>
test   %rax,%rax
je     119b <eval_fun_table+0x4b>
lea    0xe71(%rip),%rdi
call   1060 <err_msg@plt>
xor    %eax,%eax
jmp    1232 <eval_fun_table+0xe2>
xor    %ebp,%ebp
xor    %edi,%edi
call   1050 <get_ivar@plt>
movsd  %xmm0,0x18(%rsp)
movl   $0x0,0x4(%rsp)
test   %ebx,%ebx
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
jle    1220 <eval_fun_table+0xd0>
subsd  %xmm2,%xmm1
lea    -0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
lea    0x20(%rsp),%r15
movsd  %xmm1,0x8(%rsp)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
xor    %edi,%edi
call   1030 <set_ivar@plt>
mov    %r15,%rdi
call   1040 <evaluate@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
movslq 0x4(%rsp),%rax
movsd  %xmm0,(%r14,%rax,8)
lea    0x1(%rax),%ebp
mov    %ebp,0x4(%rsp)
cmp    %ebx,%ebp
jl     11e0 <eval_fun_table+0x90>
xor    %edi,%edi
movsd  0x18(%rsp),%xmm0
call   1030 <set_ivar@plt>
mov    $0x1,%eax
add    $0x348,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Illegal formula...\00"
define i32 @eval_fun_table(i32 %0, double %1, double %2, i8* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i8*
%11 = alloca double*
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca [200 x i32]
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store i8* %3, i8** %10
store double* %4, double** %11
%16 = load i8*, i8** %10
%17 = getelementptr inbounds [200 x i32], [200 x i32]* %15, i64 0, i64 0
%18 = call i64 @parse_expr(i8* %16, i32* %17, i32* %12)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %5
%21 = call i32 @err_msg(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %54
22: ; preds = %5
%23 = call double @get_ivar(i32 0)
store double %23, double* %14
%24 = load double, double* %9
%25 = load double, double* %8
%26 = fsub double %24, %25
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, 1
%29 = sitofp i32 %28 to double
%30 = fdiv double %26, %29
store double %30, double* %13
store i32 0, i32* %12
br label %31
31: ; preds = %48, %22
%32 = load i32, i32* %12
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %51
35: ; preds = %31
%36 = load double, double* %13
%37 = load i32, i32* %12
%38 = sitofp i32 %37 to double
%39 = load double, double* %8
%40 = call double @llvm.fmuladd.f64(double %36, double %38, double %39)
%41 = call i32 @set_ivar(i32 0, double %40)
%42 = getelementptr inbounds [200 x i32], [200 x i32]* %15, i64 0, i64 0
%43 = call double @evaluate(i32* %42)
%44 = load double*, double** %11
%45 = load i32, i32* %12
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %48
48: ; preds = %35
%49 = load i32, i32* %12
%50 = add nsw i32 %49, 1
store i32 %50, i32* %12
br label %31
51: ; preds = %31
%52 = load double, double* %14
%53 = call i32 @set_ivar(i32 0, double %52)
store i32 1, i32* %6
br label %54
54: ; preds = %51, %20
%55 = load i32, i32* %6
ret i32 %55
}

LLVM IR (-O2):
@.str = [19 x i8] c"Illegal formula...\00"
define i32 @eval_fun_table(i32 %0, double %1, double %2, i8* %3, double* nocapture writeonly %4) {
%6 = alloca i32
%7 = alloca [200 x i32]
%8 = bitcast i32* %6 to i8*
%9 = bitcast [200 x i32]* %7 to i8*
%10 = getelementptr inbounds [200 x i32], [200 x i32]* %7, i64 0, i64 0
%11 = call i64 @parse_expr(i8* %3, i32* %10, i32* %6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %5
%14 = call i32 @err_msg(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %35
15: ; preds = %5
%16 = call double @get_ivar(i32 0)
%17 = fsub double %2, %1
%18 = add nsw i32 %0, -1
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
store i32 0, i32* %6
%21 = icmp sgt i32 %0, 0
br i1 %21, label %22, label %33
22: ; preds = %15, %22
%23 = phi i32 [ %31, %22 ], [ 0, %15 ]
%24 = sitofp i32 %23 to double
%25 = call double @llvm.fmuladd.f64(double %20, double %24, double %1)
%26 = call i32 @set_ivar(i32 0, double %25)
%27 = call double @evaluate(i32* %10)
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %4, i64 %29
store double %27, double* %30
%31 = add nsw i32 %28, 1
store i32 %31, i32* %6
%32 = icmp slt i32 %31, %0
br i1 %32, label %22, label %33
33: ; preds = %22, %15
%34 = call i32 @set_ivar(i32 0, double %16)
br label %35
35: ; preds = %33, %13
%36 = phi i32 [ 0, %13 ], [ 1, %33 ]
ret i32 %36
}