; LLVM IR from tangjz/acm-icpc :: usaco/Training/Chapter 6 Contest Practice/packrec.ll (Z4workv)

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

@rp = external dso_local global [4 x %struct.node], align 16
@tmp = external dso_local global %struct.node, align 4

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4copyv() #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4workv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  store i32 0, ptr @tmp, align 4, !tbaa !10
  store i32 0, ptr %1, align 4, !tbaa !11
  br label %4

4:                                                ; preds = %29, %0
  %5 = load i32, ptr %1, align 4, !tbaa !11
  %6 = icmp slt i32 %5, 4
  br i1 %6, label %7, label %32

7:                                                ; preds = %4
  %8 = load i32, ptr %1, align 4, !tbaa !11
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [4 x %struct.node], ptr @rp, i64 0, i64 %9
  %11 = getelementptr inbounds %struct.node, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !10
  %13 = load i32, ptr @tmp, align 4, !tbaa !10
  %14 = add nsw i32 %13, %12
  store i32 %14, ptr @tmp, align 4, !tbaa !10
  %15 = load i32, ptr %1, align 4, !tbaa !11
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [4 x %struct.node], ptr @rp, i64 0, i64 %16
  %18 = getelementptr inbounds %struct.node, ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = load i32, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %21 = icmp sgt i32 %19, %20
  br i1 %21, label %22, label %28

22:                                               ; preds = %7
  %23 = load i32, ptr %1, align 4, !tbaa !11
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [4 x %struct.node], ptr @rp, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.node, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !5
  store i32 %27, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  br label %28

28:                                               ; preds = %22, %7
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %1, align 4, !tbaa !11
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %1, align 4, !tbaa !11
  br label %4, !llvm.loop !12

32:                                               ; preds = %4
  call void @_Z4copyv()
  store i32 0, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  store i32 0, ptr @tmp, align 4, !tbaa !10
  store i32 0, ptr %1, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %58, %32
  %34 = load i32, ptr %1, align 4, !tbaa !11
  %35 = icmp slt i32 %34, 3
  br i1 %35, label %36, label %61

36:                                               ; preds = %33
  %37 = load i32, ptr %1, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [4 x %struct.node], ptr @rp, i64 0, i64 %38
  %40 = getelementptr inbounds %struct.node, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !10
  %42 = load i32, ptr @tmp, align 4, !tbaa !10
  %43 = add nsw i32 %42, %41
  store i32 %43, ptr @tmp, align 4, !tbaa !10
  %44 = load i32, ptr %1, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [4 x %struct.node], ptr @rp, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.node, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %50 = icmp sgt i32 %48, %49
  br i1 %50, label %51, label %57

51:                                               ; preds = %36
  %52 = load i32, ptr %1, align 4, !tbaa !11
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [4 x %struct.node], ptr @rp, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.node, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !5
  store i32 %56, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  br label %57

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

58:                                               ; preds = %57
  %59 = load i32, ptr %1, align 4, !tbaa !11
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %1, align 4, !tbaa !11
  br label %33, !llvm.loop !14

61:                                               ; preds = %33
  %62 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), i32 0, i32 1), align 4, !tbaa !5
  %63 = load i32, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %64 = add nsw i32 %63, %62
  store i32 %64, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %65 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %66 = load i32, ptr @tmp, align 4, !tbaa !10
  %67 = icmp sgt i32 %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %61
  %69 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  store i32 %69, ptr @tmp, align 4, !tbaa !10
  br label %70

70:                                               ; preds = %68, %61
  call void @_Z4copyv()
  %71 = load i32, ptr @rp, align 16, !tbaa !10
  %72 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), align 8, !tbaa !10
  %73 = add nsw i32 %71, %72
  store i32 %73, ptr @tmp, align 4, !tbaa !10
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (%struct.node, ptr @rp, i32 0, i32 1), ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), i32 0, i32 1))
  %75 = load i32, ptr %74, align 4, !tbaa !11
  store i32 %75, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %76 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), i32 0, i32 1), align 4, !tbaa !5
  %77 = load i32, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %78 = add nsw i32 %77, %76
  store i32 %78, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %79 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  %80 = load i32, ptr @tmp, align 4, !tbaa !10
  %81 = icmp sgt i32 %79, %80
  br i1 %81, label %82, label %84

82:                                               ; preds = %70
  %83 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  store i32 %83, ptr @tmp, align 4, !tbaa !10
  br label %84

84:                                               ; preds = %82, %70
  %85 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %86 = load i32, ptr @tmp, align 4, !tbaa !10
  %87 = add nsw i32 %86, %85
  store i32 %87, ptr @tmp, align 4, !tbaa !10
  %88 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), i32 0, i32 1), align 4, !tbaa !5
  %89 = load i32, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %90 = icmp sgt i32 %88, %89
  br i1 %90, label %91, label %93

91:                                               ; preds = %84
  %92 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), i32 0, i32 1), align 4, !tbaa !5
  store i32 %92, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  br label %93

93:                                               ; preds = %91, %84
  call void @_Z4copyv()
  %94 = load i32, ptr @rp, align 16, !tbaa !10
  %95 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), align 8, !tbaa !10
  %96 = add nsw i32 %94, %95
  store i32 %96, ptr @tmp, align 4, !tbaa !10
  %97 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (%struct.node, ptr @rp, i32 0, i32 1), ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), i32 0, i32 1))
  %98 = load i32, ptr %97, align 4, !tbaa !11
  store i32 %98, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %99 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3))
  %100 = load i32, ptr %99, align 4, !tbaa !11
  %101 = load i32, ptr @tmp, align 4, !tbaa !10
  %102 = add nsw i32 %101, %100
  store i32 %102, ptr @tmp, align 4, !tbaa !10
  %103 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), i32 0, i32 1), align 4, !tbaa !5
  %104 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), i32 0, i32 1), align 4, !tbaa !5
  %105 = add nsw i32 %103, %104
  %106 = load i32, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  %107 = icmp sgt i32 %105, %106
  br i1 %107, label %108, label %112

108:                                              ; preds = %93
  %109 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), i32 0, i32 1), align 4, !tbaa !5
  %110 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), i32 0, i32 1), align 4, !tbaa !5
  %111 = add nsw i32 %109, %110
  store i32 %111, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  br label %112

112:                                              ; preds = %108, %93
  call void @_Z4copyv()
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  %113 = load i32, ptr getelementptr inbounds (%struct.node, ptr @rp, i32 0, i32 1), align 4, !tbaa !5
  %114 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), i32 0, i32 1), align 4, !tbaa !5
  %115 = add nsw i32 %113, %114
  store i32 %115, ptr %2, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %116 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !5
  %117 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), i32 0, i32 1), align 4, !tbaa !5
  %118 = add nsw i32 %116, %117
  store i32 %118, ptr %3, align 4, !tbaa !11
  %119 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %120 = load i32, ptr %119, align 4, !tbaa !11
  store i32 %120, ptr getelementptr inbounds (%struct.node, ptr @tmp, i32 0, i32 1), align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %121 = load i32, ptr @rp, align 16, !tbaa !10
  %122 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), align 8, !tbaa !10
  %123 = add nsw i32 %121, %122
  store i32 %123, ptr @tmp, align 4, !tbaa !10
  %124 = load i32, ptr getelementptr inbounds (%struct.node, ptr @rp, i32 0, i32 1), align 4, !tbaa !5
  %125 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !5
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %127, label %138

127:                                              ; preds = %112
  %128 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), align 8, !tbaa !10
  %129 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  %130 = add nsw i32 %128, %129
  %131 = load i32, ptr @tmp, align 4, !tbaa !10
  %132 = icmp sgt i32 %130, %131
  br i1 %132, label %133, label %137

133:                                              ; preds = %127
  %134 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), align 8, !tbaa !10
  %135 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  %136 = add nsw i32 %134, %135
  store i32 %136, ptr @tmp, align 4, !tbaa !10
  br label %137

137:                                              ; preds = %133, %127
  br label %138

138:                                              ; preds = %137, %112
  %139 = load i32, ptr getelementptr inbounds (%struct.node, ptr @rp, i32 0, i32 1), align 4, !tbaa !5
  %140 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), i32 0, i32 1), align 4, !tbaa !5
  %141 = add nsw i32 %139, %140
  %142 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !5
  %143 = icmp sgt i32 %141, %142
  br i1 %143, label %144, label %155

144:                                              ; preds = %138
  %145 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  %146 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %147 = add nsw i32 %145, %146
  %148 = load i32, ptr @tmp, align 4, !tbaa !10
  %149 = icmp sgt i32 %147, %148
  br i1 %149, label %150, label %154

150:                                              ; preds = %144
  %151 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  %152 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %153 = add nsw i32 %151, %152
  store i32 %153, ptr @tmp, align 4, !tbaa !10
  br label %154

154:                                              ; preds = %150, %144
  br label %155

155:                                              ; preds = %154, %138
  %156 = load i32, ptr getelementptr inbounds (%struct.node, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !5
  %157 = load i32, ptr getelementptr inbounds (%struct.node, ptr @rp, i32 0, i32 1), align 4, !tbaa !5
  %158 = icmp slt i32 %156, %157
  br i1 %158, label %159, label %170

159:                                              ; preds = %155
  %160 = load i32, ptr @rp, align 16, !tbaa !10
  %161 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %162 = add nsw i32 %160, %161
  %163 = load i32, ptr @tmp, align 4, !tbaa !10
  %164 = icmp sgt i32 %162, %163
  br i1 %164, label %165, label %169

165:                                              ; preds = %159
  %166 = load i32, ptr @rp, align 16, !tbaa !10
  %167 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %168 = add nsw i32 %166, %167
  store i32 %168, ptr @tmp, align 4, !tbaa !10
  br label %169

169:                                              ; preds = %165, %159
  br label %170

170:                                              ; preds = %169, %155
  %171 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  %172 = load i32, ptr @tmp, align 4, !tbaa !10
  %173 = icmp sgt i32 %171, %172
  br i1 %173, label %174, label %176

174:                                              ; preds = %170
  %175 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 2), align 16, !tbaa !10
  store i32 %175, ptr @tmp, align 4, !tbaa !10
  br label %176

176:                                              ; preds = %174, %170
  %177 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  %178 = load i32, ptr @tmp, align 4, !tbaa !10
  %179 = icmp sgt i32 %177, %178
  br i1 %179, label %180, label %182

180:                                              ; preds = %176
  %181 = load i32, ptr getelementptr inbounds ([4 x %struct.node], ptr @rp, i64 0, i64 3), align 8, !tbaa !10
  store i32 %181, ptr @tmp, align 4, !tbaa !10
  br label %182

182:                                              ; preds = %180, %176
  call void @_Z4copyv()
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

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

attributes #0 = { mustprogress 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 mustprogress 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, !7, i64 4}
!6 = !{!"_ZTS4node", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

@rp = external dso_local global [4 x %struct.node], align 16
@tmp = external dso_local local_unnamed_addr global %struct.node, align 4

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4copyv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4workv() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  %3 = load i32, ptr @rp, align 16, !tbaa !10
  %4 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 4), align 4, !tbaa !5
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %4, i32 0)
  store i32 %spec.store.select, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4
  %spec.select = tail call i32 @llvm.smax.i32(i32 %4, i32 0)
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 8), align 8, !tbaa !10
  %6 = add nsw i32 %3, %5
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 12), align 4, !tbaa !5
  %8 = icmp sgt i32 %7, %spec.select
  %spec.store.select31 = select i1 %8, i32 %7, i32 %spec.store.select
  store i32 %spec.store.select31, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4
  %spec.select32 = tail call i32 @llvm.smax.i32(i32 %7, i32 %spec.select)
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 16), align 16, !tbaa !10
  %10 = add nsw i32 %6, %9
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 20), align 4, !tbaa !5
  %12 = icmp sgt i32 %11, %spec.select32
  %spec.store.select33 = select i1 %12, i32 %11, i32 %spec.store.select31
  store i32 %spec.store.select33, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4
  %spec.select34 = tail call i32 @llvm.smax.i32(i32 %11, i32 %spec.select32)
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 24), align 8, !tbaa !10
  %14 = add nsw i32 %10, %13
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 28), align 4, !tbaa !5
  %16 = icmp sgt i32 %15, %spec.select34
  %spec.store.select35 = select i1 %16, i32 %15, i32 %spec.store.select33
  store i32 %spec.store.select35, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4
  store i32 %14, ptr @tmp, align 4, !tbaa !10
  tail call void @_Z4copyv()
  %17 = load i32, ptr @rp, align 16, !tbaa !10
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 4), align 4, !tbaa !5
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 8), align 8, !tbaa !10
  %20 = add nsw i32 %17, %19
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 12), align 4, !tbaa !5
  %spec.select29 = tail call i32 @llvm.smax.i32(i32 %18, i32 %21)
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 16), align 16, !tbaa !10
  %23 = add nsw i32 %20, %22
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 20), align 4, !tbaa !5
  %25 = tail call i32 @llvm.smax.i32(i32 %spec.select29, i32 %24)
  %26 = tail call i32 @llvm.smax.i32(i32 %25, i32 0)
  store i32 %23, ptr @tmp, align 4, !tbaa !10
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 28), align 4, !tbaa !5
  %28 = add nsw i32 %26, %27
  store i32 %28, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 24), align 8, !tbaa !10
  %30 = icmp sgt i32 %29, %23
  br i1 %30, label %31, label %32

31:                                               ; preds = %0
  store i32 %29, ptr @tmp, align 4, !tbaa !10
  br label %32

32:                                               ; preds = %31, %0
  tail call void @_Z4copyv()
  %33 = load i32, ptr @rp, align 16, !tbaa !10
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 8), align 8, !tbaa !10
  %35 = add nsw i32 %34, %33
  store i32 %35, ptr @tmp, align 4, !tbaa !10
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @rp, i64 4), ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @rp, i64 12))
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 20), align 4, !tbaa !5
  %39 = add nsw i32 %38, %37
  store i32 %39, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  %40 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 16), align 16, !tbaa !10
  %41 = load i32, ptr @tmp, align 4, !tbaa !10
  %spec.select30 = tail call i32 @llvm.smax.i32(i32 %40, i32 %41)
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 24), align 8, !tbaa !10
  %43 = add nsw i32 %spec.select30, %42
  store i32 %43, ptr @tmp, align 4, !tbaa !10
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 28), align 4, !tbaa !5
  %45 = icmp sgt i32 %44, %39
  br i1 %45, label %46, label %47

46:                                               ; preds = %32
  store i32 %44, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  br label %47

47:                                               ; preds = %46, %32
  tail call void @_Z4copyv()
  %48 = load i32, ptr @rp, align 16, !tbaa !10
  %49 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 8), align 8, !tbaa !10
  %50 = add nsw i32 %49, %48
  store i32 %50, ptr @tmp, align 4, !tbaa !10
  %51 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @rp, i64 4), ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @rp, i64 12))
  %52 = load i32, ptr %51, align 4, !tbaa !11
  store i32 %52, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  %53 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @rp, i64 16), ptr noundef nonnull align 4 dereferenceable(4) getelementptr inbounds (i8, ptr @rp, i64 24))
  %54 = load i32, ptr %53, align 4, !tbaa !11
  %55 = load i32, ptr @tmp, align 4, !tbaa !10
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr @tmp, align 4, !tbaa !10
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 20), align 4, !tbaa !5
  %58 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 28), align 4, !tbaa !5
  %59 = add nsw i32 %58, %57
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  %61 = icmp sgt i32 %59, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %47
  store i32 %59, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  br label %63

63:                                               ; preds = %62, %47
  tail call void @_Z4copyv()
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %64 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 4), align 4, !tbaa !5
  %65 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 20), align 4, !tbaa !5
  %66 = add nsw i32 %65, %64
  store i32 %66, ptr %1, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %67 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 12), align 4, !tbaa !5
  %68 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 28), align 4, !tbaa !5
  %69 = add nsw i32 %68, %67
  store i32 %69, ptr %2, align 4, !tbaa !11
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %71 = load i32, ptr %70, align 4, !tbaa !11
  store i32 %71, ptr getelementptr inbounds (i8, ptr @tmp, i64 4), align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %72 = load i32, ptr @rp, align 16, !tbaa !10
  %73 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 8), align 8, !tbaa !10
  %74 = add nsw i32 %73, %72
  store i32 %74, ptr @tmp, align 4, !tbaa !10
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 4), align 4, !tbaa !5
  %76 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 12), align 4, !tbaa !5
  %77 = icmp slt i32 %75, %76
  br i1 %77, label %78, label %83

78:                                               ; preds = %63
  %79 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 16), align 16, !tbaa !10
  %80 = icmp sgt i32 %79, %72
  br i1 %80, label %81, label %83

81:                                               ; preds = %78
  %82 = add nsw i32 %79, %73
  store i32 %82, ptr @tmp, align 4, !tbaa !10
  br label %83

83:                                               ; preds = %78, %81, %63
  %84 = phi i32 [ %74, %78 ], [ %82, %81 ], [ %74, %63 ]
  %85 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 20), align 4, !tbaa !5
  %86 = add nsw i32 %85, %75
  %87 = icmp sgt i32 %86, %76
  br i1 %87, label %88, label %94

88:                                               ; preds = %83
  %89 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 16), align 16, !tbaa !10
  %90 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 24), align 8, !tbaa !10
  %91 = add nsw i32 %90, %89
  %92 = icmp sgt i32 %91, %84
  br i1 %92, label %93, label %94

93:                                               ; preds = %88
  store i32 %91, ptr @tmp, align 4, !tbaa !10
  br label %94

94:                                               ; preds = %88, %93, %83
  %95 = phi i32 [ %84, %88 ], [ %91, %93 ], [ %84, %83 ]
  %96 = icmp slt i32 %76, %75
  br i1 %96, label %97, label %102

97:                                               ; preds = %94
  %98 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 24), align 8, !tbaa !10
  %99 = add nsw i32 %98, %72
  %100 = icmp sgt i32 %99, %95
  br i1 %100, label %101, label %102

101:                                              ; preds = %97
  store i32 %99, ptr @tmp, align 4, !tbaa !10
  br label %102

102:                                              ; preds = %97, %101, %94
  %103 = phi i32 [ %95, %97 ], [ %99, %101 ], [ %95, %94 ]
  %104 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 16), align 16, !tbaa !10
  %105 = icmp sgt i32 %104, %103
  br i1 %105, label %106, label %107

106:                                              ; preds = %102
  store i32 %104, ptr @tmp, align 4, !tbaa !10
  br label %107

107:                                              ; preds = %106, %102
  %108 = phi i32 [ %104, %106 ], [ %103, %102 ]
  %109 = load i32, ptr getelementptr inbounds (i8, ptr @rp, i64 24), align 8, !tbaa !10
  %110 = icmp sgt i32 %109, %108
  br i1 %110, label %111, label %112

111:                                              ; preds = %107
  store i32 %109, ptr @tmp, align 4, !tbaa !10
  br label %112

112:                                              ; preds = %111, %107
  call void @_Z4copyv()
  ret void
}

; 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 mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) 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 nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

attributes #0 = { mustprogress 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 mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !7, i64 4}
!6 = !{!"_ZTS4node", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass