; LLVM IR from garethcmurphy/Interstellar-Jet-MHD-Simulation :: src/tabfind.ll (Z7tabfinddPdS_)

; 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"

@__const._Z7tabfinddPdS_.cooling_tab = external hidden unnamed_addr constant [50 x double], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7tabfinddPdS_(double noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [50 x double], align 16
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store double %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 400, ptr %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const._Z7tabfinddPdS_.cooling_tab, i64 400, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %27, %3
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = icmp slt i32 %16, 50
  br i1 %17, label %18, label %30

18:                                               ; preds = %15
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [50 x double], ptr %7, i64 0, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = fadd double %22, 2.200000e+01
  %24 = load i32, ptr %8, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [50 x double], ptr %7, i64 0, i64 %25
  store double %23, ptr %26, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %18
  %28 = load i32, ptr %8, align 4, !tbaa !11
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %8, align 4, !tbaa !11
  br label %15, !llvm.loop !13

30:                                               ; preds = %15
  %31 = load double, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !9
  call void @_Z6locatedPdPii(double noundef %31, ptr noundef %32, ptr noundef %8, i32 noundef 50)
  %33 = load i32, ptr %8, align 4, !tbaa !11
  %34 = icmp eq i32 %33, 50
  br i1 %34, label %35, label %41

35:                                               ; preds = %30
  %36 = load i32, ptr %8, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [50 x double], ptr %7, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  store double %39, ptr %40, align 8, !tbaa !5
  br label %78

41:                                               ; preds = %30
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = load i32, ptr %8, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %42, i64 %44
  %46 = load double, ptr %45, align 8, !tbaa !5
  store double %46, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = load i32, ptr %8, align 4, !tbaa !11
  %49 = add nsw i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds double, ptr %47, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !5
  store double %52, ptr %10, align 8, !tbaa !5
  %53 = load double, ptr %10, align 8, !tbaa !5
  %54 = load double, ptr %9, align 8, !tbaa !5
  %55 = fsub double %53, %54
  store double %55, ptr %13, align 8, !tbaa !5
  %56 = load i32, ptr %8, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [50 x double], ptr %7, i64 0, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !5
  store double %59, ptr %11, align 8, !tbaa !5
  %60 = load i32, ptr %8, align 4, !tbaa !11
  %61 = add nsw i32 %60, 1
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [50 x double], ptr %7, i64 0, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !5
  store double %64, ptr %12, align 8, !tbaa !5
  %65 = load double, ptr %12, align 8, !tbaa !5
  %66 = load double, ptr %11, align 8, !tbaa !5
  %67 = fsub double %65, %66
  store double %67, ptr %14, align 8, !tbaa !5
  %68 = load double, ptr %11, align 8, !tbaa !5
  %69 = load double, ptr %4, align 8, !tbaa !5
  %70 = load double, ptr %9, align 8, !tbaa !5
  %71 = fsub double %69, %70
  %72 = load double, ptr %14, align 8, !tbaa !5
  %73 = fmul double %71, %72
  %74 = load double, ptr %13, align 8, !tbaa !5
  %75 = fdiv double %73, %74
  %76 = fadd double %68, %75
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  store double %76, ptr %77, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %41, %35
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = load double, ptr %79, align 8, !tbaa !5
  %81 = call double @pow(double noundef 1.000000e+01, double noundef %80) #5
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  store double %81, ptr %82, align 8, !tbaa !5
  %83 = load ptr, ptr %5, align 8, !tbaa !9
  %84 = load double, ptr %83, align 8, !tbaa !5
  %85 = fmul double 1.000000e-02, %84
  %86 = load ptr, ptr %5, align 8, !tbaa !9
  store double %85, ptr %86, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 400, ptr %7) #5
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @_Z6locatedPdPii(double noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #4

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

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@__const._Z7tabfinddPdS_.cooling_tab = external hidden unnamed_addr constant [50 x double], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7tabfinddPdS_(double noundef %0, ptr nocapture noundef writeonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [50 x double], align 16
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) %4, ptr noundef nonnull align 16 dereferenceable(400) @__const._Z7tabfinddPdS_.cooling_tab, i64 400, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %6 = load <2 x double>, ptr %4, align 16, !tbaa !5
  %7 = fadd <2 x double> %6, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %7, ptr %4, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %4, i64 16
  %9 = load <2 x double>, ptr %8, align 16, !tbaa !5
  %10 = fadd <2 x double> %9, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %10, ptr %8, align 16, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %4, i64 32
  %12 = load <2 x double>, ptr %11, align 16, !tbaa !5
  %13 = fadd <2 x double> %12, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %13, ptr %11, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %4, i64 48
  %15 = load <2 x double>, ptr %14, align 16, !tbaa !5
  %16 = fadd <2 x double> %15, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %16, ptr %14, align 16, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %4, i64 64
  %18 = load <2 x double>, ptr %17, align 16, !tbaa !5
  %19 = fadd <2 x double> %18, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %19, ptr %17, align 16, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %4, i64 80
  %21 = load <2 x double>, ptr %20, align 16, !tbaa !5
  %22 = fadd <2 x double> %21, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %22, ptr %20, align 16, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %4, i64 96
  %24 = load <2 x double>, ptr %23, align 16, !tbaa !5
  %25 = fadd <2 x double> %24, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %25, ptr %23, align 16, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %4, i64 112
  %27 = load <2 x double>, ptr %26, align 16, !tbaa !5
  %28 = fadd <2 x double> %27, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %28, ptr %26, align 16, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %4, i64 128
  %30 = load <2 x double>, ptr %29, align 16, !tbaa !5
  %31 = fadd <2 x double> %30, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %31, ptr %29, align 16, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %4, i64 144
  %33 = load <2 x double>, ptr %32, align 16, !tbaa !5
  %34 = fadd <2 x double> %33, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %34, ptr %32, align 16, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %4, i64 160
  %36 = load <2 x double>, ptr %35, align 16, !tbaa !5
  %37 = fadd <2 x double> %36, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %37, ptr %35, align 16, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %4, i64 176
  %39 = load <2 x double>, ptr %38, align 16, !tbaa !5
  %40 = fadd <2 x double> %39, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %40, ptr %38, align 16, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %4, i64 192
  %42 = load <2 x double>, ptr %41, align 16, !tbaa !5
  %43 = fadd <2 x double> %42, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %43, ptr %41, align 16, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %4, i64 208
  %45 = load <2 x double>, ptr %44, align 16, !tbaa !5
  %46 = fadd <2 x double> %45, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %46, ptr %44, align 16, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %4, i64 224
  %48 = load <2 x double>, ptr %47, align 16, !tbaa !5
  %49 = fadd <2 x double> %48, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %49, ptr %47, align 16, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %4, i64 240
  %51 = load <2 x double>, ptr %50, align 16, !tbaa !5
  %52 = fadd <2 x double> %51, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %52, ptr %50, align 16, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %4, i64 256
  %54 = load <2 x double>, ptr %53, align 16, !tbaa !5
  %55 = fadd <2 x double> %54, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %55, ptr %53, align 16, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %4, i64 272
  %57 = load <2 x double>, ptr %56, align 16, !tbaa !5
  %58 = fadd <2 x double> %57, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %58, ptr %56, align 16, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %4, i64 288
  %60 = load <2 x double>, ptr %59, align 16, !tbaa !5
  %61 = fadd <2 x double> %60, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %61, ptr %59, align 16, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %4, i64 304
  %63 = load <2 x double>, ptr %62, align 16, !tbaa !5
  %64 = fadd <2 x double> %63, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %64, ptr %62, align 16, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %4, i64 320
  %66 = load <2 x double>, ptr %65, align 16, !tbaa !5
  %67 = fadd <2 x double> %66, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %67, ptr %65, align 16, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %4, i64 336
  %69 = load <2 x double>, ptr %68, align 16, !tbaa !5
  %70 = fadd <2 x double> %69, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %70, ptr %68, align 16, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %4, i64 352
  %72 = load <2 x double>, ptr %71, align 16, !tbaa !5
  %73 = fadd <2 x double> %72, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %73, ptr %71, align 16, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %4, i64 368
  %75 = load <2 x double>, ptr %74, align 16, !tbaa !5
  %76 = fadd <2 x double> %75, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %76, ptr %74, align 16, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %4, i64 384
  %78 = load <2 x double>, ptr %77, align 16, !tbaa !5
  %79 = fadd <2 x double> %78, <double 2.200000e+01, double 2.200000e+01>
  store <2 x double> %79, ptr %77, align 16, !tbaa !5
  store i32 50, ptr %5, align 4, !tbaa !9
  call void @_Z6locatedPdPii(double noundef %0, ptr noundef %2, ptr noundef nonnull %5, i32 noundef 50)
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = icmp eq i32 %80, 50
  br i1 %81, label %82, label %85

82:                                               ; preds = %3
  %83 = getelementptr inbounds i8, ptr %4, i64 400
  %84 = load double, ptr %83, align 16, !tbaa !5
  br label %103

85:                                               ; preds = %3
  %86 = sext i32 %80 to i64
  %87 = getelementptr inbounds double, ptr %2, i64 %86
  %88 = load double, ptr %87, align 8, !tbaa !5
  %89 = add nsw i32 %80, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds double, ptr %2, i64 %90
  %92 = load double, ptr %91, align 8, !tbaa !5
  %93 = fsub double %92, %88
  %94 = getelementptr inbounds [50 x double], ptr %4, i64 0, i64 %86
  %95 = load double, ptr %94, align 8, !tbaa !5
  %96 = getelementptr inbounds [50 x double], ptr %4, i64 0, i64 %90
  %97 = load double, ptr %96, align 8, !tbaa !5
  %98 = fsub double %97, %95
  %99 = fsub double %0, %88
  %100 = fmul double %99, %98
  %101 = fdiv double %100, %93
  %102 = fadd double %95, %101
  br label %103

103:                                              ; preds = %85, %82
  %storemerge20 = phi double [ %102, %85 ], [ %84, %82 ]
  %104 = call double @pow(double noundef 1.000000e+01, double noundef %storemerge20) #5
  %105 = fmul double %104, 1.000000e-02
  store double %105, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %4) #5
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @_Z6locatedPdPii(double noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { mustprogress nofree nounwind willreturn memory(write) "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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass