; 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._command_line = type { [256 x i8], [256 x i8], [256 x i8], i32, i32, i32, i8, i32, float }

@gnum_ft_conn = external global i32, align 4
@gnum_fl_conn = external global i32, align 4
@lplan_hash_entry = external dso_local global [1024 x ptr], align 16
@ginitial_state = external global %struct._State, align 8
@lehc_space_head = external dso_local global ptr, align 8
@lehc_space_end = external dso_local global ptr, align 8
@lehc_hash_entry = external dso_local global [8192 x ptr], align 16
@lnum_ehc_hash_entry = external dso_local global [8192 x i32], align 16
@lchanged_ehc_entry = external dso_local global [8192 x i8], align 16
@lnum_changed_ehc_entrys = external dso_local global i32, align 4
@lH = external dso_local global i8, align 1
@gcmd_line = external global %struct._command_line, align 4
@.str = external hidden unnamed_addr constant [50 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @do_enforced_hill_climbing() #0 {
  %1 = alloca i8, align 1
  %2 = alloca %struct._State, align 8
  %3 = alloca %struct._State, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %8 = load i32, ptr @gnum_ft_conn, align 4, !tbaa !5
  %9 = load i32, ptr @gnum_fl_conn, align 4, !tbaa !5
  call void @make_state(ptr noundef %2, i32 noundef %8, i32 noundef %9)
  %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 %3, i32 noundef %10, i32 noundef %11)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %19, %0
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 1024
  br i1 %14, label %15, label %22

15:                                               ; preds = %12
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1024 x ptr], ptr @lplan_hash_entry, i64 0, i64 %17
  store ptr null, ptr %18, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %15
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %4, align 4, !tbaa !5
  br label %12, !llvm.loop !11

22:                                               ; preds = %12
  %23 = call ptr @hash_plan_state(ptr noundef @ginitial_state, i32 noundef 0)
  %24 = call ptr @new_EhcNode()
  store ptr %24, ptr @lehc_space_head, align 8, !tbaa !9
  %25 = load ptr, ptr @lehc_space_head, align 8, !tbaa !9
  store ptr %25, ptr @lehc_space_end, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %39, %22
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 8192
  br i1 %28, label %29, label %42

29:                                               ; preds = %26
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [8192 x ptr], ptr @lehc_hash_entry, i64 0, i64 %31
  store ptr null, ptr %32, align 8, !tbaa !9
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [8192 x i32], ptr @lnum_ehc_hash_entry, i64 0, i64 %34
  store i32 0, ptr %35, align 4, !tbaa !5
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [8192 x i8], ptr @lchanged_ehc_entry, i64 0, i64 %37
  store i8 0, ptr %38, align 1, !tbaa !13
  br label %39

39:                                               ; preds = %29
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %4, align 4, !tbaa !5
  br label %26, !llvm.loop !14

42:                                               ; preds = %26
  store i32 0, ptr @lnum_changed_ehc_entrys, align 4, !tbaa !5
  store i8 1, ptr @lH, align 1, !tbaa !13
  call void @source_to_dest(ptr noundef %2, ptr noundef @ginitial_state)
  %43 = call i32 @get_1P_and_H(ptr noundef %2)
  store i32 %43, ptr %5, align 4, !tbaa !5
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = icmp eq i32 %44, -1
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  store i8 0, ptr %1, align 1
  store i32 1, ptr %7, align 4
  br label %83

47:                                               ; preds = %42
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  store i8 1, ptr %1, align 1
  store i32 1, ptr %7, align 4
  br label %83

51:                                               ; preds = %47
  %52 = load i32, ptr getelementptr inbounds (%struct._command_line, ptr @gcmd_line, i32 0, i32 3), align 4, !tbaa !15
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %57

54:                                               ; preds = %51
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %55)
  br label %57

57:                                               ; preds = %54, %51
  br label %58

58:                                               ; preds = %81, %57
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %82

61:                                               ; preds = %58
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = call zeroext i8 @search_for_better_state(ptr noundef %2, i32 noundef %62, ptr noundef %3, ptr noundef %6)
  %64 = icmp ne i8 %63, 0
  br i1 %64, label %74, label %65

65:                                               ; preds = %61
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %67 = call i32 @get_1P_and_A(ptr noundef %2)
  store i8 0, ptr @lH, align 1, !tbaa !13
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = call zeroext i8 @search_for_better_state(ptr noundef %2, i32 noundef %68, ptr noundef %3, ptr noundef %6)
  %70 = icmp ne i8 %69, 0
  br i1 %70, label %72, label %71

71:                                               ; preds = %65
  store i8 0, ptr %1, align 1
  store i32 1, ptr %7, align 4
  br label %83

72:                                               ; preds = %65
  store i8 1, ptr @lH, align 1, !tbaa !13
  %73 = call i32 @get_1P_and_H(ptr noundef %3)
  br label %74

74:                                               ; preds = %72, %61
  call void @source_to_dest(ptr noundef %2, ptr noundef %3)
  %75 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %75, ptr %5, align 4, !tbaa !5
  %76 = load i32, ptr getelementptr inbounds (%struct._command_line, ptr @gcmd_line, i32 0, i32 3), align 4, !tbaa !15
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %81

78:                                               ; preds = %74
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %79)
  br label %81

81:                                               ; preds = %78, %74
  br label %58, !llvm.loop !18

82:                                               ; preds = %58
  store i8 1, ptr %1, align 1
  store i32 1, ptr %7, align 4
  br label %83

83:                                               ; preds = %82, %71, %50, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #3
  %84 = load i8, ptr %1, align 1
  ret i8 %84
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @hash_plan_state(ptr noundef, i32 noundef) #0

declare ptr @new_EhcNode() #2

; Function Attrs: nounwind uwtable
declare dso_local void @source_to_dest(ptr noundef, ptr noundef) #0

declare i32 @get_1P_and_H(ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @search_for_better_state(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

declare i32 @get_1P_and_A(ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}
!15 = !{!16, !6, i64 768}
!16 = !{!"_command_line", !7, i64 0, !7, i64 256, !7, i64 512, !6, i64 768, !6, i64 772, !6, i64 776, !7, i64 780, !6, i64 784, !17, i64 788}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !12}


; 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 }
%struct._command_line = type { [256 x i8], [256 x i8], [256 x i8], i32, i32, i32, i8, i32, float }

@gnum_ft_conn = external local_unnamed_addr global i32, align 4
@gnum_fl_conn = external local_unnamed_addr global i32, align 4
@lplan_hash_entry = external dso_local local_unnamed_addr global [1024 x ptr], align 16
@ginitial_state = external global %struct._State, align 8
@lehc_space_head = external dso_local local_unnamed_addr global ptr, align 8
@lehc_space_end = external dso_local local_unnamed_addr global ptr, align 8
@lehc_hash_entry = external dso_local local_unnamed_addr global [8192 x ptr], align 16
@lnum_ehc_hash_entry = external dso_local local_unnamed_addr global [8192 x i32], align 16
@lchanged_ehc_entry = external dso_local local_unnamed_addr global [8192 x i8], align 16
@lnum_changed_ehc_entrys = external dso_local local_unnamed_addr global i32, align 4
@lH = external dso_local local_unnamed_addr global i8, align 1
@gcmd_line = external local_unnamed_addr global %struct._command_line, align 4
@.str = external hidden unnamed_addr constant [50 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @do_enforced_hill_climbing() local_unnamed_addr #0 {
  %1 = alloca %struct._State, align 8
  %2 = alloca %struct._State, align 8
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %4 = load i32, ptr @gnum_ft_conn, align 4, !tbaa !5
  %5 = load i32, ptr @gnum_fl_conn, align 4, !tbaa !5
  call void @make_state(ptr noundef nonnull %1, i32 noundef %4, i32 noundef %5) #5
  %6 = load i32, ptr @gnum_ft_conn, align 4, !tbaa !5
  %7 = load i32, ptr @gnum_fl_conn, align 4, !tbaa !5
  call void @make_state(ptr noundef nonnull %2, i32 noundef %6, i32 noundef %7) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8192) @lplan_hash_entry, i8 0, i64 8192, i1 false), !tbaa !9
  %8 = call ptr @hash_plan_state(ptr noundef nonnull @ginitial_state, i32 noundef 0)
  %9 = call ptr @new_EhcNode() #5
  store ptr %9, ptr @lehc_space_head, align 8, !tbaa !9
  store ptr %9, ptr @lehc_space_end, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(65536) @lehc_hash_entry, i8 0, i64 65536, i1 false), !tbaa !9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32768) @lnum_ehc_hash_entry, i8 0, i64 32768, i1 false), !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8192) @lchanged_ehc_entry, i8 0, i64 8192, i1 false), !tbaa !11
  store i32 0, ptr @lnum_changed_ehc_entrys, align 4, !tbaa !5
  store i8 1, ptr @lH, align 1, !tbaa !11
  call void @source_to_dest(ptr noundef nonnull %1, ptr noundef nonnull @ginitial_state)
  %10 = call i32 @get_1P_and_H(ptr noundef nonnull %1) #5
  switch i32 %10, label %12 [
    i32 -1, label %.loopexit
    i32 0, label %11
  ]

11:                                               ; preds = %0
  br label %.loopexit

12:                                               ; preds = %0
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @gcmd_line, i64 768), align 4, !tbaa !12
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %.lr.ph.preheader, label %14

14:                                               ; preds = %12
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %10)
  br label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %12, %14
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %28
  %.026 = phi i32 [ %24, %28 ], [ %10, %.lr.ph.preheader ]
  %16 = call zeroext i8 @search_for_better_state(ptr noundef nonnull %1, i32 noundef %.026, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %.not20 = icmp eq i8 %16, 0
  br i1 %.not20, label %17, label %23

17:                                               ; preds = %.lr.ph
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %19 = call i32 @get_1P_and_A(ptr noundef nonnull %1) #5
  store i8 0, ptr @lH, align 1, !tbaa !11
  %20 = call zeroext i8 @search_for_better_state(ptr noundef nonnull %1, i32 noundef %.026, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %.not21 = icmp eq i8 %20, 0
  br i1 %.not21, label %.loopexit, label %21

21:                                               ; preds = %17
  store i8 1, ptr @lH, align 1, !tbaa !11
  %22 = call i32 @get_1P_and_H(ptr noundef nonnull %2) #5
  br label %23

23:                                               ; preds = %21, %.lr.ph
  call void @source_to_dest(ptr noundef nonnull %1, ptr noundef nonnull %2)
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @gcmd_line, i64 768), align 4, !tbaa !12
  %.not22 = icmp eq i32 %25, 0
  br i1 %.not22, label %28, label %26

26:                                               ; preds = %23
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %24)
  br label %28

28:                                               ; preds = %26, %23
  %.not19 = icmp eq i32 %24, 0
  br i1 %.not19, label %.loopexit, label %.lr.ph, !llvm.loop !15

.loopexit:                                        ; preds = %17, %28, %0, %11
  %.017 = phi i8 [ 1, %11 ], [ 0, %0 ], [ 0, %17 ], [ 1, %28 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #5
  ret i8 %.017
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @hash_plan_state(ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @new_EhcNode() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @source_to_dest(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @get_1P_and_H(ptr noundef) local_unnamed_addr #2

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

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

declare i32 @get_1P_and_A(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !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 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 768}
!13 = !{!"_command_line", !7, i64 0, !7, i64 256, !7, i64 512, !6, i64 768, !6, i64 772, !6, i64 776, !7, i64 780, !6, i64 784, !14, i64 788}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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