; LLVM IR from CLASS-SZ/class_sz :: class-sz/hyrec (hyrectools)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [70 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind uwtable
declare dso_local double @rec_interp1d(double noundef, double noundef, ptr noundef, i32 noundef, double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

; Function Attrs: nounwind uwtable
define dso_local double @rec_interp2d(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, double noundef %7, double noundef %8) #4 {
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca i32, align 4
  %20 = alloca i64, align 8
  %21 = alloca double, align 8
  %22 = alloca [4 x double], align 16
  store double %0, ptr %10, align 8, !tbaa !5
  store double %1, ptr %11, align 8, !tbaa !5
  store double %2, ptr %12, align 8, !tbaa !5
  store double %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !9
  store i32 %5, ptr %15, align 4, !tbaa !11
  store i32 %6, ptr %16, align 4, !tbaa !11
  store double %7, ptr %17, align 8, !tbaa !5
  store double %8, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %22) #5
  %23 = load double, ptr %17, align 8, !tbaa !5
  %24 = load double, ptr %10, align 8, !tbaa !5
  %25 = fcmp olt double %23, %24
  br i1 %25, label %35, label %26

26:                                               ; preds = %9
  %27 = load double, ptr %17, align 8, !tbaa !5
  %28 = load double, ptr %10, align 8, !tbaa !5
  %29 = load double, ptr %11, align 8, !tbaa !5
  %30 = load i32, ptr %15, align 4, !tbaa !11
  %31 = sub i32 %30, 1
  %32 = uitofp i32 %31 to double
  %33 = call double @llvm.fmuladd.f64(double %29, double %32, double %28)
  %34 = fcmp ogt double %27, %33
  br i1 %34, label %35, label %38

35:                                               ; preds = %26, %9
  %36 = load ptr, ptr @stderr, align 8, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.4) #5
  call void @exit(i32 noundef 1) #6
  unreachable

38:                                               ; preds = %26
  %39 = load double, ptr %17, align 8, !tbaa !5
  %40 = load double, ptr %10, align 8, !tbaa !5
  %41 = fsub double %39, %40
  %42 = load double, ptr %11, align 8, !tbaa !5
  %43 = fdiv double %41, %42
  %44 = call double @llvm.floor.f64(double %43)
  %45 = fptosi double %44 to i64
  store i64 %45, ptr %20, align 8, !tbaa !13
  %46 = load i64, ptr %20, align 8, !tbaa !13
  %47 = icmp slt i64 %46, 1
  br i1 %47, label %48, label %49

48:                                               ; preds = %38
  store i64 1, ptr %20, align 8, !tbaa !13
  br label %49

49:                                               ; preds = %48, %38
  %50 = load i64, ptr %20, align 8, !tbaa !13
  %51 = load i32, ptr %15, align 4, !tbaa !11
  %52 = sub i32 %51, 3
  %53 = zext i32 %52 to i64
  %54 = icmp sgt i64 %50, %53
  br i1 %54, label %55, label %59

55:                                               ; preds = %49
  %56 = load i32, ptr %15, align 4, !tbaa !11
  %57 = sub i32 %56, 3
  %58 = zext i32 %57 to i64
  store i64 %58, ptr %20, align 8, !tbaa !13
  br label %59

59:                                               ; preds = %55, %49
  %60 = load double, ptr %17, align 8, !tbaa !5
  %61 = load double, ptr %10, align 8, !tbaa !5
  %62 = fsub double %60, %61
  %63 = load double, ptr %11, align 8, !tbaa !5
  %64 = fdiv double %62, %63
  %65 = load i64, ptr %20, align 8, !tbaa !13
  %66 = sitofp i64 %65 to double
  %67 = fsub double %64, %66
  store double %67, ptr %21, align 8, !tbaa !5
  %68 = load i64, ptr %20, align 8, !tbaa !13
  %69 = sub nsw i64 %68, 1
  %70 = load ptr, ptr %14, align 8, !tbaa !9
  %71 = getelementptr inbounds ptr, ptr %70, i64 %69
  store ptr %71, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %72

72:                                               ; preds = %89, %59
  %73 = load i32, ptr %19, align 4, !tbaa !11
  %74 = icmp slt i32 %73, 4
  br i1 %74, label %75, label %92

75:                                               ; preds = %72
  %76 = load double, ptr %12, align 8, !tbaa !5
  %77 = load double, ptr %13, align 8, !tbaa !5
  %78 = load ptr, ptr %14, align 8, !tbaa !9
  %79 = load i32, ptr %19, align 4, !tbaa !11
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %78, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = load i32, ptr %16, align 4, !tbaa !11
  %84 = load double, ptr %18, align 8, !tbaa !5
  %85 = call double @rec_interp1d(double noundef %76, double noundef %77, ptr noundef %82, i32 noundef %83, double noundef %84)
  %86 = load i32, ptr %19, align 4, !tbaa !11
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [4 x double], ptr %22, i64 0, i64 %87
  store double %85, ptr %88, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %75
  %90 = load i32, ptr %19, align 4, !tbaa !11
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %19, align 4, !tbaa !11
  br label %72, !llvm.loop !15

92:                                               ; preds = %72
  %93 = getelementptr inbounds [4 x double], ptr %22, i64 0, i64 0
  %94 = load double, ptr %93, align 16, !tbaa !5
  %95 = fneg double %94
  %96 = load double, ptr %21, align 8, !tbaa !5
  %97 = fmul double %95, %96
  %98 = load double, ptr %21, align 8, !tbaa !5
  %99 = fsub double 1.000000e+00, %98
  %100 = fmul double %97, %99
  %101 = load double, ptr %21, align 8, !tbaa !5
  %102 = fsub double 2.000000e+00, %101
  %103 = fmul double %100, %102
  %104 = fdiv double %103, 6.000000e+00
  %105 = getelementptr inbounds [4 x double], ptr %22, i64 0, i64 1
  %106 = load double, ptr %105, align 8, !tbaa !5
  %107 = load double, ptr %21, align 8, !tbaa !5
  %108 = fadd double 1.000000e+00, %107
  %109 = fmul double %106, %108
  %110 = load double, ptr %21, align 8, !tbaa !5
  %111 = fsub double 1.000000e+00, %110
  %112 = fmul double %109, %111
  %113 = load double, ptr %21, align 8, !tbaa !5
  %114 = fsub double 2.000000e+00, %113
  %115 = fmul double %112, %114
  %116 = fdiv double %115, 2.000000e+00
  %117 = fadd double %104, %116
  %118 = getelementptr inbounds [4 x double], ptr %22, i64 0, i64 2
  %119 = load double, ptr %118, align 16, !tbaa !5
  %120 = load double, ptr %21, align 8, !tbaa !5
  %121 = fadd double 1.000000e+00, %120
  %122 = fmul double %119, %121
  %123 = load double, ptr %21, align 8, !tbaa !5
  %124 = fmul double %122, %123
  %125 = load double, ptr %21, align 8, !tbaa !5
  %126 = fsub double 2.000000e+00, %125
  %127 = fmul double %124, %126
  %128 = fdiv double %127, 2.000000e+00
  %129 = fadd double %117, %128
  %130 = getelementptr inbounds [4 x double], ptr %22, i64 0, i64 3
  %131 = load double, ptr %130, align 8, !tbaa !5
  %132 = load double, ptr %21, align 8, !tbaa !5
  %133 = fadd double 1.000000e+00, %132
  %134 = fmul double %131, %133
  %135 = load double, ptr %21, align 8, !tbaa !5
  %136 = fmul double %134, %135
  %137 = load double, ptr %21, align 8, !tbaa !5
  %138 = fsub double %137, 1.000000e+00
  %139 = fmul double %136, %138
  %140 = fdiv double %139, 6.000000e+00
  %141 = fadd double %129, %140
  call void @llvm.lifetime.end.p0(i64 32, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  ret double %141
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [70 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind uwtable
declare dso_local double @rec_interp1d(double noundef, double noundef, ptr noundef, i32 noundef, double noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

; Function Attrs: nounwind uwtable
define dso_local double @rec_interp2d(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef readonly %4, i32 noundef %5, i32 noundef %6, double noundef %7, double noundef %8) local_unnamed_addr #3 {
  %10 = fcmp olt double %7, %0
  br i1 %10, label %16, label %11

11:                                               ; preds = %9
  %12 = add i32 %5, -1
  %13 = uitofp i32 %12 to double
  %14 = tail call double @llvm.fmuladd.f64(double %1, double %13, double %0)
  %15 = fcmp olt double %14, %7
  br i1 %15, label %16, label %19

16:                                               ; preds = %11, %9
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.4) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

19:                                               ; preds = %11
  %20 = fsub double %7, %0
  %21 = fdiv double %20, %1
  %22 = tail call double @llvm.floor.f64(double %21)
  %23 = fptosi double %22 to i64
  %spec.store.select = tail call i64 @llvm.smax.i64(i64 %23, i64 1)
  %24 = add i32 %5, -3
  %25 = zext i32 %24 to i64
  %spec.select = tail call i64 @llvm.umin.i64(i64 %spec.store.select, i64 %25)
  %26 = getelementptr ptr, ptr %4, i64 %spec.select
  %27 = getelementptr i8, ptr %26, i64 -8
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = tail call double @rec_interp1d(double noundef %2, double noundef %3, ptr noundef %28, i32 noundef %6, double noundef %8)
  %30 = load ptr, ptr %26, align 8, !tbaa !5
  %31 = tail call double @rec_interp1d(double noundef %2, double noundef %3, ptr noundef %30, i32 noundef %6, double noundef %8)
  %32 = getelementptr i8, ptr %26, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = tail call double @rec_interp1d(double noundef %2, double noundef %3, ptr noundef %33, i32 noundef %6, double noundef %8)
  %35 = getelementptr i8, ptr %26, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = tail call double @rec_interp1d(double noundef %2, double noundef %3, ptr noundef %36, i32 noundef %6, double noundef %8)
  %38 = uitofp nneg i64 %spec.select to double
  %39 = fsub double %21, %38
  %40 = fneg double %29
  %41 = fmul double %39, %40
  %42 = fsub double 1.000000e+00, %39
  %43 = fmul double %42, %41
  %44 = fsub double 2.000000e+00, %39
  %45 = fmul double %44, %43
  %46 = fdiv double %45, 6.000000e+00
  %47 = fadd double %39, 1.000000e+00
  %48 = fmul double %47, %31
  %49 = fmul double %42, %48
  %50 = fmul double %44, %49
  %51 = fmul double %50, 5.000000e-01
  %52 = fadd double %46, %51
  %53 = fmul double %47, %34
  %54 = fmul double %39, %53
  %55 = fmul double %44, %54
  %56 = fmul double %55, 5.000000e-01
  %57 = fadd double %52, %56
  %58 = fmul double %47, %37
  %59 = fmul double %39, %58
  %60 = fadd double %39, -1.000000e+00
  %61 = fmul double %60, %59
  %62 = fdiv double %61, 6.000000e+00
  %63 = fadd double %57, %62
  ret double %63
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #4

attributes #0 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { cold nounwind }
attributes #6 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass