#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 */
float dichotomy_inv_decfunc(float, float, float, float, float (*)(float));
float *malloc(int);
int /*<<< orphan*/ sarerror_msg(char *, float);
int /*<<< orphan*/ sarerror_perror();
float *lookuptable_inv_decfunc(float y_min, float y_max, int nb,
                               float precision, float x_min, float x_max,
                               float (*func)(float)) {
  float step = (y_max - y_min) / (nb - 1);
  float y;
  float y_min_INF = func(x_max);
  float y_max_SUP = func(x_min);
  if (y_min < y_min_INF) {
    sarerror_msg("Minimum bounds too small (cannot be inferior to %.4g)",
                 y_min_INF);
    return NULL;
  }
  if (y_max > y_max_SUP) {
    sarerror_msg("Maximum bounds too big (cannot be superior to %.4g)",
                 y_max_SUP);
    return NULL;
  }
  float *res = malloc(nb * sizeof(float));
  if (!res) {
    sarerror_perror();
    return NULL;
  }
  int k;
  for (k = 0; k < nb; ++k) {
    y = y_min + k * step;
    res[k] = dichotomy_inv_decfunc(x_min, x_max, y, precision, func);
    x_max = res[k];
  }
  return res;
}


x86 assembly (clang, -O0):
<lookuptable_inv_decfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movss  %xmm2,-0x18(%rbp)
movss  %xmm3,-0x1c(%rbp)
movss  %xmm4,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
movss  -0x20(%rbp),%xmm0
call   *%rax
movss  %xmm0,-0x34(%rbp)
mov    -0x28(%rbp),%rax
movss  -0x1c(%rbp),%xmm0
call   *%rax
movss  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0x34(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11d6 <lookuptable_inv_decfunc+0x96>
movss  -0x34(%rbp),%xmm0
lea    0xe3c(%rip),%rdi
call   1040 <sarerror_msg@plt>
movq   $0x0,-0x8(%rbp)
jmp    12b6 <lookuptable_inv_decfunc+0x176>
movss  -0x10(%rbp),%xmm0
ucomiss -0x38(%rbp),%xmm0
jbe    1203 <lookuptable_inv_decfunc+0xc3>
movss  -0x38(%rbp),%xmm0
lea    0xe45(%rip),%rdi
call   1040 <sarerror_msg@plt>
movq   $0x0,-0x8(%rbp)
jmp    12b6 <lookuptable_inv_decfunc+0x176>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1235 <lookuptable_inv_decfunc+0xf5>
mov    $0x0,%al
call   1060 <sarerror_perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    12b6 <lookuptable_inv_decfunc+0x176>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ae <lookuptable_inv_decfunc+0x16e>
movss  -0xc(%rbp),%xmm1
cvtsi2ssl -0x44(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
movss  -0x18(%rbp),%xmm3
mov    -0x28(%rbp),%rdi
call   1030 <dichotomy_inv_decfunc@plt>
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    123c <lookuptable_inv_decfunc+0xfc>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookuptable_inv_decfunc>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
movss  %xmm3,0x8(%rsp)
movss  %xmm2,0x14(%rsp)
mov    %edi,%r15d
movss  %xmm1,(%rsp)
movss  %xmm0,0x4(%rsp)
movss  %xmm4,0xc(%rsp)
movaps %xmm4,%xmm0
call   *%rsi
movss  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
call   *%r12
movss  0x10(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
ucomiss %xmm2,%xmm1
jbe    119f <lookuptable_inv_decfunc+0x5f>
lea    0xe66(%rip),%rdi
movaps %xmm1,%xmm0
jmp    11b0 <lookuptable_inv_decfunc+0x70>
movss  (%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    11c7 <lookuptable_inv_decfunc+0x87>
lea    0xe86(%rip),%rdi
call   1040 <sarerror_msg@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0x0(,%r15,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1258 <lookuptable_inv_decfunc+0x118>
mov    %rax,%r14
test   %r15d,%r15d
jle    11b8 <lookuptable_inv_decfunc+0x78>
lea    -0x1(%r15),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  (%rsp),%xmm1
movss  0x4(%rsp),%xmm3
subss  %xmm3,%xmm1
divss  %xmm0,%xmm1
mov    %r15d,%r15d
xor    %ebx,%ebx
movss  0xc(%rsp),%xmm4
movss  %xmm1,(%rsp)
nop
xorps  %xmm2,%xmm2
cvtsi2ss %ebx,%xmm2
mulss  %xmm1,%xmm2
addss  %xmm3,%xmm2
movss  0x8(%rsp),%xmm0
movaps %xmm4,%xmm1
movss  0x14(%rsp),%xmm3
mov    %r12,%rdi
call   1030 <dichotomy_inv_decfunc@plt>
movss  0x4(%rsp),%xmm3
movss  (%rsp),%xmm1
movaps %xmm0,%xmm4
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1210 <lookuptable_inv_decfunc+0xd0>
jmp    11b8 <lookuptable_inv_decfunc+0x78>
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <sarerror_perror@plt>
jmp    11b8 <lookuptable_inv_decfunc+0x78>

LLVM IR (-O0):
@.str = [54 x i8] c"Minimum bounds too small (cannot be inferior to %.4g)\00"
@.str.1 = [52 x i8] c"Maximum bounds too big (cannot be superior to %.4g)\00"
define float* @lookuptable_inv_decfunc(float %0, float %1, i32 %2, float %3, float %4, float %5, float (float)* %6) {
%8 = alloca float*
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float (float)*
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float*
%21 = alloca i32
store float %0, float* %9
store float %1, float* %10
store i32 %2, i32* %11
store float %3, float* %12
store float %4, float* %13
store float %5, float* %14
store float (float)* %6, float (float)** %15
%22 = load float, float* %10
%23 = load float, float* %9
%24 = fsub float %22, %23
%25 = load i32, i32* %11
%26 = sub nsw i32 %25, 1
%27 = sitofp i32 %26 to float
%28 = fdiv float %24, %27
store float %28, float* %16
%29 = load float (float)*, float (float)** %15
%30 = load float, float* %14
%31 = call float %29(float %30)
store float %31, float* %18
%32 = load float (float)*, float (float)** %15
%33 = load float, float* %13
%34 = call float %32(float %33)
store float %34, float* %19
%35 = load float, float* %9
%36 = load float, float* %18
%37 = fcmp olt float %35, %36
br i1 %37, label %38, label %41
38: ; preds = %7
%39 = load float, float* %18
%40 = call i32 @sarerror_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), float %39)
store float* null, float** %8
br label %89
41: ; preds = %7
%42 = load float, float* %10
%43 = load float, float* %19
%44 = fcmp ogt float %42, %43
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load float, float* %19
%47 = call i32 @sarerror_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), float %46)
store float* null, float** %8
br label %89
48: ; preds = %41
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = mul i64 %50, 4
%52 = trunc i64 %51 to i32
%53 = call float* @malloc(i32 %52)
store float* %53, float** %20
%54 = load float*, float** %20
%55 = icmp ne float* %54, null
br i1 %55, label %58, label %56
56: ; preds = %48
%57 = call i32 (...) @sarerror_perror()
store float* null, float** %8
br label %89
58: ; preds = %48
store i32 0, i32* %21
br label %59
59: ; preds = %84, %58
%60 = load i32, i32* %21
%61 = load i32, i32* %11
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %87
63: ; preds = %59
%64 = load float, float* %9
%65 = load i32, i32* %21
%66 = sitofp i32 %65 to float
%67 = load float, float* %16
%68 = call float @llvm.fmuladd.f32(float %66, float %67, float %64)
store float %68, float* %17
%69 = load float, float* %13
%70 = load float, float* %14
%71 = load float, float* %17
%72 = load float, float* %12
%73 = load float (float)*, float (float)** %15
%74 = call float @dichotomy_inv_decfunc(float %69, float %70, float %71, float %72, float (float)* %73)
%75 = load float*, float** %20
%76 = load i32, i32* %21
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %75, i64 %77
store float %74, float* %78
%79 = load float*, float** %20
%80 = load i32, i32* %21
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %79, i64 %81
%83 = load float, float* %82
store float %83, float* %14
br label %84
84: ; preds = %63
%85 = load i32, i32* %21
%86 = add nsw i32 %85, 1
store i32 %86, i32* %21
br label %59
87: ; preds = %59
%88 = load float*, float** %20
store float* %88, float** %8
br label %89
89: ; preds = %87, %56, %45, %38
%90 = load float*, float** %8
ret float* %90
}

LLVM IR (-O2):
@.str = [54 x i8] c"Minimum bounds too small (cannot be inferior to %.4g)\00"
@.str.1 = [52 x i8] c"Maximum bounds too big (cannot be superior to %.4g)\00"
define float* @lookuptable_inv_decfunc(float %0, float %1, i32 %2, float %3, float %4, float %5, float (float)* %6) {
%8 = fsub float %1, %0
%9 = add nsw i32 %2, -1
%10 = sitofp i32 %9 to float
%11 = fdiv float %8, %10
%12 = tail call float %6(float %5)
%13 = tail call float %6(float %4)
%14 = fcmp ogt float %12, %0
br i1 %14, label %15, label %17
15: ; preds = %7
%16 = tail call i32 @sarerror_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), float %12)
br label %41
17: ; preds = %7
%18 = fcmp olt float %13, %1
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @sarerror_msg(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), float %13)
br label %41
21: ; preds = %17
%22 = shl i32 %2, 2
%23 = tail call float* @malloc(i32 %22)
%24 = icmp eq float* %23, null
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = icmp sgt i32 %2, 0
br i1 %26, label %27, label %41
27: ; preds = %25
%28 = zext i32 %2 to i64
br label %31
29: ; preds = %21
%30 = tail call i32 (...) @sarerror_perror()
br label %41
31: ; preds = %27, %31
%32 = phi i64 [ 0, %27 ], [ %39, %31 ]
%33 = phi float [ %5, %27 ], [ %37, %31 ]
%34 = trunc i64 %32 to i32
%35 = sitofp i32 %34 to float
%36 = tail call float @llvm.fmuladd.f32(float %35, float %11, float %0)
%37 = tail call float @dichotomy_inv_decfunc(float %4, float %33, float %36, float %3, float (float)* %6)
%38 = getelementptr inbounds float, float* %23, i64 %32
store float %37, float* %38
%39 = add nuw nsw i64 %32, 1
%40 = icmp eq i64 %39, %28
br i1 %40, label %41, label %31
41: ; preds = %31, %25, %29, %19, %15
%42 = phi float* [ null, %15 ], [ null, %19 ], [ null, %29 ], [ %23, %25 ], [ %23, %31 ]
ret float* %42
}