; LLVM IR from int32bit/leetcode :: algorithms/HouseRobberII (src)

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @get(i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @robWithoutCircle(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [2 x i32], align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 -1, ptr %8, align 4, !tbaa !9
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp sle i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %77

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %20

16:                                               ; preds = %13
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds i32, ptr %17, i64 0
  %19 = load i32, ptr %18, align 4, !tbaa !9
  store i32 %19, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %77

20:                                               ; preds = %13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds i32, ptr %21, i64 0
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 0
  store i32 %23, ptr %24, align 4, !tbaa !9
  %25 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 0
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds i32, ptr %27, i64 1
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = call i32 @max(i32 noundef %26, i32 noundef %29)
  %31 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 1
  store i32 %30, ptr %31, align 4, !tbaa !9
  %32 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 0
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 1
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = call i32 @max(i32 noundef %33, i32 noundef %35)
  store i32 %36, ptr %8, align 4, !tbaa !9
  store i32 2, ptr %7, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %72, %20
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %75

41:                                               ; preds = %37
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = sub nsw i32 %42, 2
  %44 = call i32 @get(i32 noundef %43)
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr %48, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = add nsw i32 %47, %52
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = sub nsw i32 %54, 1
  %56 = call i32 @get(i32 noundef %55)
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = call i32 @max(i32 noundef %53, i32 noundef %59)
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = call i32 @get(i32 noundef %61)
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %63
  store i32 %60, ptr %64, align 4, !tbaa !9
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = call i32 @get(i32 noundef %66)
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = call i32 @max(i32 noundef %65, i32 noundef %70)
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %41
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %7, align 4, !tbaa !9
  br label %37, !llvm.loop !11

75:                                               ; preds = %37
  %76 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %76, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %77

77:                                               ; preds = %75, %16, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %78 = load i32, ptr %3, align 4
  ret i32 %78
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @max(i32 noundef, i32 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 = { inlinehint 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 = distinct !{!11, !12}
!12 = !{!"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"

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

; Function Attrs: nounwind uwtable
define dso_local i32 @robWithoutCircle(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca [2 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = icmp slt i32 %1, 1
  br i1 %4, label %.loopexit, label %5

5:                                                ; preds = %2
  %6 = icmp eq i32 %1, 1
  %7 = load i32, ptr %0, align 4, !tbaa !5
  br i1 %6, label %.loopexit, label %8

8:                                                ; preds = %5
  store i32 %7, ptr %3, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = tail call i32 @max(i32 noundef %7, i32 noundef %10)
  %12 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %11, ptr %12, align 4, !tbaa !5
  %13 = tail call i32 @max(i32 noundef %7, i32 noundef %11)
  %14 = icmp ugt i32 %1, 2
  br i1 %14, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %8
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.020 = phi i32 [ %13, %.lr.ph.preheader ], [ %39, %.lr.ph ]
  %15 = trunc i64 %indvars.iv to i32
  %16 = add i32 %15, -2
  %17 = tail call i32 @get(i32 noundef %16)
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = add nsw i32 %22, %20
  %24 = trunc i64 %indvars.iv to i32
  %25 = add i32 %24, -1
  %26 = tail call i32 @get(i32 noundef %25)
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = tail call i32 @max(i32 noundef %23, i32 noundef %29)
  %31 = trunc nuw nsw i64 %indvars.iv to i32
  %32 = tail call i32 @get(i32 noundef %31)
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %33
  store i32 %30, ptr %34, align 4, !tbaa !5
  %35 = tail call i32 @get(i32 noundef %31)
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [2 x i32], ptr %3, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = tail call i32 @max(i32 noundef %.020, i32 noundef %38)
  %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 %.lr.ph, !llvm.loop !9

.loopexit:                                        ; preds = %.lr.ph, %5, %8, %2
  %.017 = phi i32 [ 0, %2 ], [ %13, %8 ], [ %7, %5 ], [ %39, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret i32 %.017
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @max(i32 noundef, i32 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

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 = { inlinehint 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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