; LLVM IR from askforalfred/alfred :: gen/ff_planner (search)

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

%struct._FlConn = type { ptr, i32, ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, i8, ptr, ptr, i32, i8, float, i8, ptr, ptr, i8, float, i32 }
%struct._State = type { ptr, i32, ptr, ptr }

@gfl_conn = external global ptr, align 8

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

; 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 float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @determine_source_val(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %10 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds %struct._FlConn, ptr %10, i64 %12
  %14 = getelementptr inbounds %struct._FlConn, ptr %13, i32 0, i32 10
  %15 = load i8, ptr %14, align 4, !tbaa !11
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %81

17:                                               ; preds = %3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  store float 0.000000e+00, ptr %18, align 4, !tbaa !14
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %77, %17
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct._FlConn, ptr %21, i64 %23
  %25 = getelementptr inbounds %struct._FlConn, ptr %24, i32 0, i32 13
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = icmp slt i32 %20, %26
  br i1 %27, label %28, label %80

28:                                               ; preds = %19
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._State, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct._FlConn, ptr %32, i64 %34
  %36 = getelementptr inbounds %struct._FlConn, ptr %35, i32 0, i32 11
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i8, ptr %31, i64 %42
  %44 = load i8, ptr %43, align 1, !tbaa !19
  %45 = icmp ne i8 %44, 0
  br i1 %45, label %47, label %46

46:                                               ; preds = %28
  store i8 0, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %101

47:                                               ; preds = %28
  %48 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct._FlConn, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct._FlConn, ptr %51, i32 0, i32 12
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds float, ptr %53, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !14
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._State, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  %61 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct._FlConn, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct._FlConn, ptr %64, i32 0, i32 11
  %66 = load ptr, ptr %65, align 8, !tbaa !18
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds i32, ptr %66, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %60, i64 %71
  %73 = load float, ptr %72, align 4, !tbaa !14
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load float, ptr %74, align 4, !tbaa !14
  %76 = call float @llvm.fmuladd.f32(float %57, float %73, float %75)
  store float %76, ptr %74, align 4, !tbaa !14
  br label %77

77:                                               ; preds = %47
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !22

80:                                               ; preds = %19
  br label %100

81:                                               ; preds = %3
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._State, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !16
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds i8, ptr %84, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !19
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %91, label %90

90:                                               ; preds = %81
  store i8 0, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %101

91:                                               ; preds = %81
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._State, ptr %92, i32 0, i32 3
  %94 = load ptr, ptr %93, align 8, !tbaa !21
  %95 = load i32, ptr %6, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds float, ptr %94, i64 %96
  %98 = load float, ptr %97, align 4, !tbaa !14
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  store float %98, ptr %99, align 4, !tbaa !14
  br label %100

100:                                              ; preds = %91, %80
  store i8 1, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %101

101:                                              ; preds = %100, %90, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %102 = load i8, ptr %4, align 1
  ret i8 %102
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 76}
!12 = !{!"_FlConn", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !7, i64 76, !6, i64 80, !6, i64 88, !10, i64 96, !7, i64 100, !13, i64 104, !7, i64 108, !6, i64 112, !6, i64 120, !7, i64 128, !13, i64 132, !10, i64 136}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !10, i64 96}
!16 = !{!17, !6, i64 16}
!17 = !{!"_State", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!12, !6, i64 80}
!19 = !{!7, !7, i64 0}
!20 = !{!12, !6, i64 88}
!21 = !{!17, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"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"

%struct._FlConn = type { ptr, i32, ptr, ptr, ptr, i32, ptr, ptr, ptr, i32, i8, ptr, ptr, i32, i8, float, i8, ptr, ptr, i8, float, i32 }

@gfl_conn = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local zeroext range(i8 0, 2) i8 @determine_source_val(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %5 = sext i32 %1 to i64
  %6 = getelementptr inbounds %struct._FlConn, ptr %4, i64 %5, i32 10
  %7 = load i8, ptr %6, align 4, !tbaa !9
  %.not = icmp eq i8 %7, 0
  br i1 %.not, label %34, label %8

8:                                                ; preds = %3
  store float 0.000000e+00, ptr %2, align 4, !tbaa !13
  %9 = getelementptr inbounds %struct._FlConn, ptr %4, i64 %5
  %10 = getelementptr inbounds i8, ptr %9, i64 96
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %9, i64 80
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %9, i64 88
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %wide.trip.count = zext nneg i32 %11 to i64
  br label %19

19:                                               ; preds = %.lr.ph, %26
  %20 = phi float [ 0.000000e+00, %.lr.ph ], [ %33, %26 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %21 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !18
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %14, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !19
  %.not21 = icmp eq i8 %25, 0
  br i1 %.not21, label %.loopexit, label %26

26:                                               ; preds = %19
  %27 = load ptr, ptr %17, align 8, !tbaa !20
  %28 = getelementptr inbounds float, ptr %27, i64 %indvars.iv
  %29 = load float, ptr %28, align 4, !tbaa !13
  %30 = load ptr, ptr %18, align 8, !tbaa !21
  %31 = getelementptr inbounds float, ptr %30, i64 %23
  %32 = load float, ptr %31, align 4, !tbaa !13
  %33 = tail call float @llvm.fmuladd.f32(float %29, float %32, float %20)
  store float %33, ptr %2, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %19, !llvm.loop !22

34:                                               ; preds = %3
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %36, i64 %5
  %38 = load i8, ptr %37, align 1, !tbaa !19
  %.not20 = icmp eq i8 %38, 0
  br i1 %.not20, label %.loopexit, label %39

39:                                               ; preds = %34
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !21
  %42 = getelementptr inbounds float, ptr %41, i64 %5
  %43 = load float, ptr %42, align 4, !tbaa !13
  store float %43, ptr %2, align 4, !tbaa !13
  br label %.loopexit

.loopexit:                                        ; preds = %19, %26, %8, %39, %34
  %.019 = phi i8 [ 0, %34 ], [ 1, %39 ], [ 1, %8 ], [ 0, %19 ], [ 1, %26 ]
  ret i8 %.019
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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"}
!9 = !{!10, !7, i64 76}
!10 = !{!"_FlConn", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !11, i64 72, !7, i64 76, !6, i64 80, !6, i64 88, !11, i64 96, !7, i64 100, !12, i64 104, !7, i64 108, !6, i64 112, !6, i64 120, !7, i64 128, !12, i64 132, !11, i64 136}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !11, i64 96}
!15 = !{!16, !6, i64 16}
!16 = !{!"_State", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!10, !6, i64 80}
!18 = !{!11, !11, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{!10, !6, i64 88}
!21 = !{!16, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass