#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 */
double exp(unsigned long);
int /*<<< orphan*/ free_vector(float *, int, int);
int /*<<< orphan*/ hunt(float *, int, float, unsigned long *);
int /*<<< orphan*/ printf(char *, ...);
float *vector(int, int);
int main(void) {
  unsigned long i, j, ji;
  float x, *xx;
  xx = vector(1, 100);
  for (i = 1; i <= 100; i++)
    xx[i] = exp(i / 20.0) - 74.0;
  printf("\n  result of:   j=0 indicates x too small\n");
  printf("%14s j=100 indicates x too large", " ");
  printf("\n%12s %8s %4s %11s %13s \n", "locate:", "guess", "j", "xx(j)",
         "xx(j+1)");
  for (i = 1; i <= 19; i++) {
    x = -100.0 + 10.0 * i;
    j = (ji = 5 * i);
    hunt(xx, 100, x, &j);
    if ((j < 100) && (j > 0))
      printf("%12.5f %6lu %6lu %12.6f %12.6f \n", x, ji, j, xx[j], xx[j + 1]);
    else if (j == 100)
      printf("%12.5f %6lu %6lu %12.6f %s \n", x, ji, j, xx[j], "   upper lim");
    else
      printf("%12.5f %6lu %6lu %s %12.6f \n", x, ji, j, "   lower lim",
             xx[j + 1]);
  }
  free_vector(xx, 1, 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0x64,%esi
call   1060 <vector@plt>
mov    %rax,-0x30(%rbp)
movq   $0x1,-0x10(%rbp)
cmpq   $0x64,-0x10(%rbp)
ja     1211 <main+0xc1>
movaps 0xea4(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xea3(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe64(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
movsd  0xe51(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1070 <exp@plt>
movsd  0xe25(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    117a <main+0x2a>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    0xe76(%rip),%rsi
lea    0xe77(%rip),%rdx
lea    0xe76(%rip),%rcx
lea    0xe71(%rip),%r8
lea    0xe70(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x1,-0x10(%rbp)
cmpq   $0x13,-0x10(%rbp)
ja     13db <main+0x28b>
movaps 0xdb1(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xdb0(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd59(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd55(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
imul   $0x5,-0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
movss  -0x24(%rbp),%xmm0
mov    $0x64,%esi
lea    -0x18(%rbp),%rdx
call   1030 <hunt@plt>
cmpq   $0x64,-0x18(%rbp)
jae    1341 <main+0x1f1>
cmpq   $0x0,-0x18(%rbp)
jbe    1341 <main+0x1f1>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  0x4(%rax,%rcx,4),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xda1(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    13c5 <main+0x275>
cmpq   $0x64,-0x18(%rbp)
jne    1388 <main+0x238>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd82(%rip),%rdi
lea    0xd98(%rip),%rcx
mov    $0x2,%al
call   1040 <printf@plt>
jmp    13c0 <main+0x270>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movss  0x4(%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd6f(%rip),%rdi
lea    0xd85(%rip),%rcx
mov    $0x2,%al
call   1040 <printf@plt>
jmp    13c5 <main+0x275>
jmp    13ca <main+0x27a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    126d <main+0x11d>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   1050 <free_vector@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%edi
mov    $0x64,%esi
call   1070 <vector@plt>
mov    %rax,%r14
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movq   %rbx,%xmm0
punpckldq 0xe63(%rip),%xmm0
subpd  0xe6b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0xe67(%rip),%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xe5b(%rip),%xmm1
cvttsd2si %xmm1,%rdi
and    %rcx,%rdi
or     %rax,%rdi
call   1080 <exp@plt>
addsd  0xe4b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x65,%rbx
jne    1190 <main+0x30>
lea    0xf18(%rip),%rdi
call   1040 <puts@plt>
lea    0xe3c(%rip),%rdi
lea    0xe56(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe4a(%rip),%rdi
lea    0xe5d(%rip),%rsi
lea    0xe5e(%rip),%rdx
lea    0xe5d(%rip),%rcx
lea    0xe58(%rip),%r8
lea    0xe57(%rip),%r9
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r13d
mov    $0x5,%ebx
lea    0x10(%rsp),%r15
lea    0xe41(%rip),%r12
lea    0xea2(%rip),%rbp
movdqa 0xd8f(%rip),%xmm1
movapd 0xd97(%rip),%xmm2
jmp    12ce <main+0x16e>
nopl   0x0(%rax,%rax,1)
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%r14,%rdx,4),%xmm1
movss  0x4(%r14,%rdx,4),%xmm2
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x3,%al
call   1050 <printf@plt>
movdqa 0xd4c(%rip),%xmm1
movapd 0xd54(%rip),%xmm2
add    $0x1,%r13
add    $0x5,%rbx
cmp    $0x14,%r13
je     1394 <main+0x234>
movq   %r13,%xmm0
punpckldq %xmm1,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
mulsd  0xd49(%rip),%xmm1
addsd  0xd49(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
mov    %rbx,0x10(%rsp)
mov    %r14,%rdi
mov    $0x64,%esi
movss  %xmm0,0xc(%rsp)
mov    %r15,%rdx
call   1030 <hunt@plt>
mov    0x10(%rsp),%rdx
lea    -0x1(%rdx),%rax
cmp    $0x62,%rax
jbe    1280 <main+0x120>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cmp    $0x64,%rdx
jne    1370 <main+0x210>
movss  0x190(%r14),%xmm1
cvtss2sd %xmm1,%xmm1
mov    $0x64,%edx
lea    0xd6f(%rip),%rdi
mov    %rbx,%rsi
lea    0xd82(%rip),%rcx
mov    $0x2,%al
call   1050 <printf@plt>
jmp    12ac <main+0x14c>
nopl   0x0(%rax,%rax,1)
movss  0x4(%r14,%rdx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd6c(%rip),%rdi
mov    %rbx,%rsi
mov    %rbp,%rcx
mov    $0x2,%al
call   1050 <printf@plt>
jmp    12ac <main+0x14c>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   1060 <free_vector@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"\0A result of: j=0 indicates x too small\0A\00"
@.str.1 = [33 x i8] c"%14s j=100 indicates x too large\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [26 x i8] c"\0A%12s %8s %4s %11s %13s \0A\00"
@.str.4 = [8 x i8] c"locate:\00"
@.str.5 = [6 x i8] c"guess\00"
@.str.6 = [2 x i8] c"j\00"
@.str.7 = [6 x i8] c"xx(j)\00"
@.str.8 = [8 x i8] c"xx(j+1)\00"
@.str.9 = [33 x i8] c"%12.5f %6lu %6lu %12.6f %12.6f \0A\00"
@.str.10 = [29 x i8] c"%12.5f %6lu %6lu %12.6f %s \0A\00"
@.str.11 = [13 x i8] c" upper lim\00"
@.str.12 = [29 x i8] c"%12.5f %6lu %6lu %s %12.6f \0A\00"
@.str.13 = [13 x i8] c" lower lim\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca float
%6 = alloca float*
store i32 0, i32* %1
%7 = call float* @vector(i32 1, i32 100)
store float* %7, float** %6
store i64 1, i64* %2
br label %8
8: ; preds = %22, %0
%9 = load i64, i64* %2
%10 = icmp ule i64 %9, 100
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i64, i64* %2
%13 = uitofp i64 %12 to double
%14 = fdiv double %13, 2.000000e+01
%15 = fptoui double %14 to i64
%16 = call double @exp(i64 %15)
%17 = fsub double %16, 7.400000e+01
%18 = fptrunc double %17 to float
%19 = load float*, float** %6
%20 = load i64, i64* %2
%21 = getelementptr inbounds float, float* %19, i64 %20
store float %18, float* %21
br label %22
22: ; preds = %11
%23 = load i64, i64* %2
%24 = add i64 %23, 1
store i64 %24, i64* %2
br label %8
25: ; preds = %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
store i64 1, i64* %2
br label %29
29: ; preds = %92, %25
%30 = load i64, i64* %2
%31 = icmp ule i64 %30, 19
br i1 %31, label %32, label %95
32: ; preds = %29
%33 = load i64, i64* %2
%34 = uitofp i64 %33 to double
%35 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %34, double -1.000000e+02)
%36 = fptrunc double %35 to float
store float %36, float* %5
%37 = load i64, i64* %2
%38 = mul i64 5, %37
store i64 %38, i64* %4
store i64 %38, i64* %3
%39 = load float*, float** %6
%40 = load float, float* %5
%41 = call i32 @hunt(float* %39, i32 100, float %40, i64* %3)
%42 = load i64, i64* %3
%43 = icmp ult i64 %42, 100
br i1 %43, label %44, label %64
44: ; preds = %32
%45 = load i64, i64* %3
%46 = icmp ugt i64 %45, 0
br i1 %46, label %47, label %64
47: ; preds = %44
%48 = load float, float* %5
%49 = fpext float %48 to double
%50 = load i64, i64* %4
%51 = load i64, i64* %3
%52 = load float*, float** %6
%53 = load i64, i64* %3
%54 = getelementptr inbounds float, float* %52, i64 %53
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = load float*, float** %6
%58 = load i64, i64* %3
%59 = add i64 %58, 1
%60 = getelementptr inbounds float, float* %57, i64 %59
%61 = load float, float* %60
%62 = fpext float %61 to double
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), double %49, i64 %50, i64 %51, double %56, double %62)
br label %91
64: ; preds = %44, %32
%65 = load i64, i64* %3
%66 = icmp eq i64 %65, 100
br i1 %66, label %67, label %78
67: ; preds = %64
%68 = load float, float* %5
%69 = fpext float %68 to double
%70 = load i64, i64* %4
%71 = load i64, i64* %3
%72 = load float*, float** %6
%73 = load i64, i64* %3
%74 = getelementptr inbounds float, float* %72, i64 %73
%75 = load float, float* %74
%76 = fpext float %75 to double
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), double %69, i64 %70, i64 %71, double %76, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %90
78: ; preds = %64
%79 = load float, float* %5
%80 = fpext float %79 to double
%81 = load i64, i64* %4
%82 = load i64, i64* %3
%83 = load float*, float** %6
%84 = load i64, i64* %3
%85 = add i64 %84, 1
%86 = getelementptr inbounds float, float* %83, i64 %85
%87 = load float, float* %86
%88 = fpext float %87 to double
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), double %80, i64 %81, i64 %82, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), double %88)
br label %90
90: ; preds = %78, %67
br label %91
91: ; preds = %90, %47
br label %92
92: ; preds = %91
%93 = load i64, i64* %2
%94 = add i64 %93, 1
store i64 %94, i64* %2
br label %29
95: ; preds = %29
%96 = load float*, float** %6
%97 = call i32 @free_vector(float* %96, i32 1, i32 100)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [33 x i8] c"%14s j=100 indicates x too large\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [26 x i8] c"\0A%12s %8s %4s %11s %13s \0A\00"
@.str.4 = [8 x i8] c"locate:\00"
@.str.5 = [6 x i8] c"guess\00"
@.str.6 = [2 x i8] c"j\00"
@.str.7 = [6 x i8] c"xx(j)\00"
@.str.8 = [8 x i8] c"xx(j+1)\00"
@.str.9 = [33 x i8] c"%12.5f %6lu %6lu %12.6f %12.6f \0A\00"
@.str.10 = [29 x i8] c"%12.5f %6lu %6lu %12.6f %s \0A\00"
@.str.11 = [13 x i8] c" upper lim\00"
@.str.12 = [29 x i8] c"%12.5f %6lu %6lu %s %12.6f \0A\00"
@.str.13 = [13 x i8] c" lower lim\00"
@str = [42 x i8] c"\0A result of: j=0 indicates x too small\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call float* @vector(i32 1, i32 100)
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 1, %0 ], [ %13, %4 ]
%6 = uitofp i64 %5 to double
%7 = fdiv double %6, 2.000000e+01
%8 = fptoui double %7 to i64
%9 = tail call double @exp(i64 %8)
%10 = fadd double %9, -7.400000e+01
%11 = fptrunc double %10 to float
%12 = getelementptr inbounds float, float* %3, i64 %5
store float %11, float* %12
%13 = add nuw nsw i64 %5, 1
%14 = icmp eq i64 %13, 101
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%19 = getelementptr inbounds float, float* %3, i64 100
br label %20
20: ; preds = %15, %53
%21 = phi i64 [ 1, %15 ], [ %54, %53 ]
%22 = uitofp i64 %21 to double
%23 = call double @llvm.fmuladd.f64(double %22, double 1.000000e+01, double -1.000000e+02)
%24 = fptrunc double %23 to float
%25 = mul nuw nsw i64 %21, 5
store i64 %25, i64* %1
%26 = call i32 @hunt(float* %3, i32 100, float %24, i64* %1)
%27 = load i64, i64* %1
%28 = add i64 %27, -1
%29 = icmp ult i64 %28, 99
br i1 %29, label %30, label %40
30: ; preds = %20
%31 = fpext float %24 to double
%32 = getelementptr inbounds float, float* %3, i64 %27
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = add nuw nsw i64 %27, 1
%36 = getelementptr inbounds float, float* %3, i64 %35
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), double %31, i64 %25, i64 %27, double %34, double %38)
br label %53
40: ; preds = %20
%41 = icmp eq i64 %27, 100
%42 = fpext float %24 to double
br i1 %41, label %43, label %47
43: ; preds = %40
%44 = load float, float* %19
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), double %42, i64 %25, i64 100, double %45, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %53
47: ; preds = %40
%48 = add i64 %27, 1
%49 = getelementptr inbounds float, float* %3, i64 %48
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), double %42, i64 %25, i64 %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), double %51)
br label %53
53: ; preds = %30, %47, %43
%54 = add nuw nsw i64 %21, 1
%55 = icmp eq i64 %54, 20
br i1 %55, label %56, label %20
56: ; preds = %53
%57 = call i32 @free_vector(float* %3, i32 1, i32 100)
ret i32 0
}