; 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._State = type { ptr, i32, ptr, ptr }
%struct._FtConn = type { ptr, i32, ptr, i32, ptr, i32, ptr, i32, i32, float, i8, i32, i32, i8, i32, i8 }
%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 }

@gnum_real_fl_conn = external global i32, align 4
@gfl_conn = external global ptr, align 8
@gft_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: nounwind uwtable
define dso_local i32 @state_sum(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %26, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._State, ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp slt i32 %6, %9
  br i1 %10, label %11, label %29

11:                                               ; preds = %5
  %12 = load ptr, ptr @gft_conn, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._State, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load i32, ptr %3, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i32, ptr %15, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds %struct._FtConn, ptr %12, i64 %20
  %22 = getelementptr inbounds %struct._FtConn, ptr %21, i32 0, i32 14
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = add nsw i32 %24, %23
  store i32 %25, ptr %4, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %11
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !17

29:                                               ; preds = %5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %71, %29
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = load i32, ptr @gnum_real_fl_conn, align 4, !tbaa !9
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %74

34:                                               ; preds = %30
  %35 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds %struct._FlConn, ptr %35, i64 %37
  %39 = getelementptr inbounds %struct._FlConn, ptr %38, i32 0, i32 16
  %40 = load i8, ptr %39, align 4, !tbaa !19
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %34
  br label %71

43:                                               ; preds = %34
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._State, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !21
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !22
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %53, label %52

52:                                               ; preds = %43
  br label %71

53:                                               ; preds = %43
  %54 = load ptr, ptr @gfl_conn, align 8, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %struct._FlConn, ptr %54, i64 %56
  %58 = getelementptr inbounds %struct._FlConn, ptr %57, i32 0, i32 21
  %59 = load i32, ptr %58, align 8, !tbaa !23
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._State, ptr %60, i32 0, i32 3
  %62 = load ptr, ptr %61, align 8, !tbaa !24
  %63 = load i32, ptr %3, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %62, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !25
  %67 = fptosi float %66 to i32
  %68 = mul nsw i32 %59, %67
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = add nsw i32 %69, %68
  store i32 %70, ptr %4, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %53, %52, %42
  %72 = load i32, ptr %3, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %3, align 4, !tbaa !9
  br label %30, !llvm.loop !26

74:                                               ; preds = %30
  %75 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %75
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !10, i64 8}
!12 = !{!"_State", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 0}
!14 = !{!15, !10, i64 84}
!15 = !{!"_FtConn", !6, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !16, i64 64, !7, i64 68, !10, i64 72, !10, i64 76, !7, i64 80, !10, i64 84, !7, i64 88}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !7, i64 108}
!20 = !{!"_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, !16, i64 104, !7, i64 108, !6, i64 112, !6, i64 120, !7, i64 128, !16, i64 132, !10, i64 136}
!21 = !{!12, !6, i64 16}
!22 = !{!7, !7, i64 0}
!23 = !{!20, !10, i64 136}
!24 = !{!12, !6, i64 24}
!25 = !{!16, !16, i64 0}
!26 = distinct !{!26, !18}


; 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._FtConn = type { ptr, i32, ptr, i32, ptr, i32, ptr, i32, i32, float, i8, i32, i32, i8, i32, i8 }
%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 }

@gnum_real_fl_conn = external local_unnamed_addr global i32, align 4
@gfl_conn = external local_unnamed_addr global ptr, align 8
@gft_conn = external local_unnamed_addr global ptr, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local i32 @state_sum(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %1
  %5 = load ptr, ptr @gft_conn, align 8, !tbaa !11
  %6 = load ptr, ptr %0, align 8, !tbaa !12
  %wide.trip.count = zext nneg i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %7 = icmp ult i32 %3, 4
  br i1 %7, label %.preheader.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %19

.preheader.loopexit.unr-lcssa:                    ; preds = %19, %.lr.ph
  %.lcssa.ph = phi i32 [ poison, %.lr.ph ], [ %43, %19 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %19 ]
  %.019.unr = phi i32 [ 0, %.lr.ph ], [ %43, %19 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.epil.preheader

.epil.preheader:                                  ; preds = %.preheader.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %.preheader.loopexit.unr-lcssa ]
  %.019.epil = phi i32 [ %13, %.epil.preheader ], [ %.019.unr, %.preheader.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.preheader.loopexit.unr-lcssa ]
  %8 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv.epil
  %9 = load i32, ptr %8, align 4, !tbaa !13
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds %struct._FtConn, ptr %5, i64 %10, i32 14
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %13 = add nsw i32 %12, %.019.epil
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.epil.preheader, !llvm.loop !17

.preheader:                                       ; preds = %.preheader.loopexit.unr-lcssa, %.epil.preheader, %1
  %.0.lcssa = phi i32 [ 0, %1 ], [ %.lcssa.ph, %.preheader.loopexit.unr-lcssa ], [ %13, %.epil.preheader ]
  %14 = load i32, ptr @gnum_real_fl_conn, align 4, !tbaa !13
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph22, label %._crit_edge

.lr.ph22:                                         ; preds = %.preheader
  %16 = load ptr, ptr @gfl_conn, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %wide.trip.count28 = zext nneg i32 %14 to i64
  br label %44

19:                                               ; preds = %19, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %19 ]
  %.019 = phi i32 [ 0, %.lr.ph.new ], [ %43, %19 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %19 ]
  %20 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv
  %21 = load i32, ptr %20, align 4, !tbaa !13
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct._FtConn, ptr %5, i64 %22, i32 14
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = add nsw i32 %24, %.019
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %26 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv.next
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct._FtConn, ptr %5, i64 %28, i32 14
  %30 = load i32, ptr %29, align 4, !tbaa !14
  %31 = add nsw i32 %30, %25
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %32 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv.next.1
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct._FtConn, ptr %5, i64 %34, i32 14
  %36 = load i32, ptr %35, align 4, !tbaa !14
  %37 = add nsw i32 %36, %31
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %38 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv.next.2
  %39 = load i32, ptr %38, align 4, !tbaa !13
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct._FtConn, ptr %5, i64 %40, i32 14
  %42 = load i32, ptr %41, align 4, !tbaa !14
  %43 = add nsw i32 %42, %37
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.loopexit.unr-lcssa, label %19, !llvm.loop !19

44:                                               ; preds = %.lr.ph22, %61
  %indvars.iv25 = phi i64 [ 0, %.lr.ph22 ], [ %indvars.iv.next26, %61 ]
  %.121 = phi i32 [ %.0.lcssa, %.lr.ph22 ], [ %.2, %61 ]
  %45 = getelementptr inbounds %struct._FlConn, ptr %16, i64 %indvars.iv25
  %46 = getelementptr inbounds i8, ptr %45, i64 108
  %47 = load i8, ptr %46, align 4, !tbaa !21
  %.not = icmp eq i8 %47, 0
  br i1 %.not, label %61, label %48

48:                                               ; preds = %44
  %49 = load ptr, ptr %17, align 8, !tbaa !23
  %50 = getelementptr inbounds i8, ptr %49, i64 %indvars.iv25
  %51 = load i8, ptr %50, align 1, !tbaa !24
  %.not17 = icmp eq i8 %51, 0
  br i1 %.not17, label %61, label %52

52:                                               ; preds = %48
  %53 = getelementptr inbounds i8, ptr %45, i64 136
  %54 = load i32, ptr %53, align 8, !tbaa !25
  %55 = load ptr, ptr %18, align 8, !tbaa !26
  %56 = getelementptr inbounds float, ptr %55, i64 %indvars.iv25
  %57 = load float, ptr %56, align 4, !tbaa !27
  %58 = fptosi float %57 to i32
  %59 = mul nsw i32 %54, %58
  %60 = add nsw i32 %59, %.121
  br label %61

61:                                               ; preds = %48, %44, %52
  %.2 = phi i32 [ %60, %52 ], [ %.121, %48 ], [ %.121, %44 ]
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond29.not = icmp eq i64 %indvars.iv.next26, %wide.trip.count28
  br i1 %exitcond29.not, label %._crit_edge, label %44, !llvm.loop !28

._crit_edge:                                      ; preds = %61, %.preheader
  %.1.lcssa = phi i32 [ %.0.lcssa, %.preheader ], [ %.2, %61 ]
  ret i32 %.1.lcssa
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, 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, !10, i64 8}
!6 = !{!"_State", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !10, i64 84}
!15 = !{!"_FtConn", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !16, i64 64, !8, i64 68, !10, i64 72, !10, i64 76, !8, i64 80, !10, i64 84, !8, i64 88}
!16 = !{!"float", !8, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.unroll.disable"}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !8, i64 108}
!22 = !{!"_FlConn", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !8, i64 76, !7, i64 80, !7, i64 88, !10, i64 96, !8, i64 100, !16, i64 104, !8, i64 108, !7, i64 112, !7, i64 120, !8, i64 128, !16, i64 132, !10, i64 136}
!23 = !{!6, !7, i64 16}
!24 = !{!8, !8, i64 0}
!25 = !{!22, !10, i64 136}
!26 = !{!6, !7, i64 24}
!27 = !{!16, !16, i64 0}
!28 = distinct !{!28, !20}


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