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

@gnum_ft_conn = external global i32, align 4
@gnum_fl_conn = external global i32, align 4
@lH = external dso_local global i8, align 1
@gnum_H = external global i32, align 4
@gH = external global ptr, align 8
@gnum_A = external global i32, align 4
@gA = external global ptr, align 8
@lehc_current_start = external dso_local global ptr, align 8
@expand_first_node.fc = external hidden global i8, align 1
@expand_first_node.S_ = external hidden global %struct._State, align 8

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

declare void @make_state(ptr noundef, i32 noundef, i32 noundef) #1

declare i32 @get_1P_and_H(ptr noundef) #1

declare i32 @get_1P_and_A(ptr noundef) #1

; 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
declare dso_local zeroext i8 @result_to_dest(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @add_to_ehc_space(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @expand_first_node(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %7 = load i8, ptr @expand_first_node.fc, align 1, !tbaa !9
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %9, label %12

9:                                                ; preds = %1
  %10 = load i32, ptr @gnum_ft_conn, align 4, !tbaa !5
  %11 = load i32, ptr @gnum_fl_conn, align 4, !tbaa !5
  call void @make_state(ptr noundef @expand_first_node.S_, i32 noundef %10, i32 noundef %11)
  store i8 0, ptr @expand_first_node.fc, align 1, !tbaa !9
  br label %12

12:                                               ; preds = %9, %1
  %13 = load i8, ptr @lH, align 1, !tbaa !9
  %14 = icmp ne i8 %13, 0
  br i1 %14, label %15, label %19

15:                                               ; preds = %12
  %16 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %17 = getelementptr inbounds %struct._EhcNode, ptr %16, i32 0, i32 0
  %18 = call i32 @get_1P_and_H(ptr noundef %17)
  store i32 %18, ptr %4, align 4, !tbaa !5
  br label %23

19:                                               ; preds = %12
  %20 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %21 = getelementptr inbounds %struct._EhcNode, ptr %20, i32 0, i32 0
  %22 = call i32 @get_1P_and_A(ptr noundef %21)
  store i32 %22, ptr %4, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %19, %15
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %26, label %31

26:                                               ; preds = %23
  %27 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %28 = getelementptr inbounds %struct._EhcNode, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  store ptr %29, ptr @lehc_current_start, align 8, !tbaa !10
  %30 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %30, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %99

31:                                               ; preds = %23
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %31
  %36 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %36, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %99

37:                                               ; preds = %31
  %38 = load i8, ptr @lH, align 1, !tbaa !9
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %67

40:                                               ; preds = %37
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %63, %40
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = load i32, ptr @gnum_H, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %66

45:                                               ; preds = %41
  %46 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %47 = getelementptr inbounds %struct._EhcNode, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr @gH, align 8, !tbaa !10
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr %48, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = call zeroext i8 @result_to_dest(ptr noundef @expand_first_node.S_, ptr noundef %47, i32 noundef %52)
  %54 = icmp ne i8 %53, 0
  br i1 %54, label %55, label %62

55:                                               ; preds = %45
  %56 = load ptr, ptr @gH, align 8, !tbaa !10
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i32, ptr %56, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  call void @add_to_ehc_space(ptr noundef @expand_first_node.S_, i32 noundef %60, ptr noundef %61)
  br label %62

62:                                               ; preds = %55, %45
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !5
  br label %41, !llvm.loop !15

66:                                               ; preds = %41
  br label %94

67:                                               ; preds = %37
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %90, %67
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = load i32, ptr @gnum_A, align 4, !tbaa !5
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %72, label %93

72:                                               ; preds = %68
  %73 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %74 = getelementptr inbounds %struct._EhcNode, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr @gA, align 8, !tbaa !10
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %75, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = call zeroext i8 @result_to_dest(ptr noundef @expand_first_node.S_, ptr noundef %74, i32 noundef %79)
  %81 = icmp ne i8 %80, 0
  br i1 %81, label %82, label %89

82:                                               ; preds = %72
  %83 = load ptr, ptr @gA, align 8, !tbaa !10
  %84 = load i32, ptr %5, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %83, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  call void @add_to_ehc_space(ptr noundef @expand_first_node.S_, i32 noundef %87, ptr noundef %88)
  br label %89

89:                                               ; preds = %82, %72
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %5, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %5, align 4, !tbaa !5
  br label %68, !llvm.loop !17

93:                                               ; preds = %68
  br label %94

94:                                               ; preds = %93, %66
  %95 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %96 = getelementptr inbounds %struct._EhcNode, ptr %95, i32 0, i32 4
  %97 = load ptr, ptr %96, align 8, !tbaa !12
  store ptr %97, ptr @lehc_current_start, align 8, !tbaa !10
  %98 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %98, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %99

99:                                               ; preds = %94, %35, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %100 = load i32, ptr %2, align 4
  ret i32 %100
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !11, i64 48}
!13 = !{!"_EhcNode", !14, i64 0, !6, i64 32, !6, i64 36, !11, i64 40, !11, i64 48}
!14 = !{!"_State", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 24}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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._State = type { ptr, i32, ptr, ptr }

@gnum_ft_conn = external local_unnamed_addr global i32, align 4
@gnum_fl_conn = external local_unnamed_addr global i32, align 4
@lH = external dso_local local_unnamed_addr global i8, align 1
@gnum_H = external local_unnamed_addr global i32, align 4
@gH = external local_unnamed_addr global ptr, align 8
@gnum_A = external local_unnamed_addr global i32, align 4
@gA = external local_unnamed_addr global ptr, align 8
@lehc_current_start = external dso_local local_unnamed_addr global ptr, align 8
@expand_first_node.fc = external hidden local_unnamed_addr global i8, align 1
@expand_first_node.S_ = external hidden global %struct._State, align 8

declare void @make_state(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @get_1P_and_H(ptr noundef) local_unnamed_addr #0

declare i32 @get_1P_and_A(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @result_to_dest(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @add_to_ehc_space(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @expand_first_node(i32 noundef %0) local_unnamed_addr #1 {
  %2 = load i8, ptr @expand_first_node.fc, align 1, !tbaa !5
  %.not = icmp eq i8 %2, 0
  br i1 %.not, label %6, label %3

3:                                                ; preds = %1
  %4 = load i32, ptr @gnum_ft_conn, align 4, !tbaa !8
  %5 = load i32, ptr @gnum_fl_conn, align 4, !tbaa !8
  tail call void @make_state(ptr noundef nonnull @expand_first_node.S_, i32 noundef %4, i32 noundef %5) #2
  store i8 0, ptr @expand_first_node.fc, align 1, !tbaa !5
  br label %6

6:                                                ; preds = %3, %1
  %7 = load i8, ptr @lH, align 1, !tbaa !5
  %.not17 = icmp eq i8 %7, 0
  %8 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  br i1 %.not17, label %11, label %9

9:                                                ; preds = %6
  %10 = tail call i32 @get_1P_and_H(ptr noundef %8) #2
  br label %13

11:                                               ; preds = %6
  %12 = tail call i32 @get_1P_and_A(ptr noundef %8) #2
  br label %13

13:                                               ; preds = %11, %9
  %.015 = phi i32 [ %10, %9 ], [ %12, %11 ]
  %14 = icmp eq i32 %.015, -1
  br i1 %14, label %.sink.split, label %15

15:                                               ; preds = %13
  %16 = icmp slt i32 %.015, %0
  br i1 %16, label %54, label %17

17:                                               ; preds = %15
  %18 = load i8, ptr @lH, align 1, !tbaa !5
  %.not18 = icmp eq i8 %18, 0
  br i1 %.not18, label %.preheader, label %.preheader21

.preheader21:                                     ; preds = %17
  %19 = load i32, ptr @gnum_H, align 4, !tbaa !8
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %.sink.split

.preheader:                                       ; preds = %17
  %21 = load i32, ptr @gnum_A, align 4, !tbaa !8
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph25, label %.sink.split

.lr.ph:                                           ; preds = %.preheader21, %33
  %indvars.iv = phi i64 [ %indvars.iv.next, %33 ], [ 0, %.preheader21 ]
  %23 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %24 = load ptr, ptr @gH, align 8, !tbaa !10
  %25 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv
  %26 = load i32, ptr %25, align 4, !tbaa !8
  %27 = tail call zeroext i8 @result_to_dest(ptr noundef nonnull @expand_first_node.S_, ptr noundef %23, i32 noundef %26)
  %.not20 = icmp eq i8 %27, 0
  br i1 %.not20, label %33, label %28

28:                                               ; preds = %.lr.ph
  %29 = load ptr, ptr @gH, align 8, !tbaa !10
  %30 = getelementptr inbounds i32, ptr %29, i64 %indvars.iv
  %31 = load i32, ptr %30, align 4, !tbaa !8
  %32 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  tail call void @add_to_ehc_space(ptr noundef nonnull @expand_first_node.S_, i32 noundef %31, ptr noundef %32)
  br label %33

33:                                               ; preds = %.lr.ph, %28
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i32, ptr @gnum_H, align 4, !tbaa !8
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %.lr.ph, label %.sink.split, !llvm.loop !12

.lr.ph25:                                         ; preds = %.preheader, %47
  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %47 ], [ 0, %.preheader ]
  %37 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %38 = load ptr, ptr @gA, align 8, !tbaa !10
  %39 = getelementptr inbounds i32, ptr %38, i64 %indvars.iv28
  %40 = load i32, ptr %39, align 4, !tbaa !8
  %41 = tail call zeroext i8 @result_to_dest(ptr noundef nonnull @expand_first_node.S_, ptr noundef %37, i32 noundef %40)
  %.not19 = icmp eq i8 %41, 0
  br i1 %.not19, label %47, label %42

42:                                               ; preds = %.lr.ph25
  %43 = load ptr, ptr @gA, align 8, !tbaa !10
  %44 = getelementptr inbounds i32, ptr %43, i64 %indvars.iv28
  %45 = load i32, ptr %44, align 4, !tbaa !8
  %46 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  tail call void @add_to_ehc_space(ptr noundef nonnull @expand_first_node.S_, i32 noundef %45, ptr noundef %46)
  br label %47

47:                                               ; preds = %.lr.ph25, %42
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %48 = load i32, ptr @gnum_A, align 4, !tbaa !8
  %49 = sext i32 %48 to i64
  %50 = icmp slt i64 %indvars.iv.next29, %49
  br i1 %50, label %.lr.ph25, label %.sink.split, !llvm.loop !14

.sink.split:                                      ; preds = %33, %47, %.preheader, %.preheader21, %13
  %51 = load ptr, ptr @lehc_current_start, align 8, !tbaa !10
  %52 = getelementptr inbounds i8, ptr %51, i64 48
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  store ptr %53, ptr @lehc_current_start, align 8, !tbaa !10
  br label %54

54:                                               ; preds = %.sink.split, %15
  ret i32 %.015
}

attributes #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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !11, i64 48}
!16 = !{!"_EhcNode", !17, i64 0, !9, i64 32, !9, i64 36, !11, i64 40, !11, i64 48}
!17 = !{!"_State", !11, i64 0, !9, i64 8, !11, i64 16, !11, i64 24}


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