; LLVM IR from tangjz/acm-icpc :: 51nod (1482)

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

@n = external dso_local global i32, align 4
@h = external dso_local global [1000010 x i32], align 16
@l = external dso_local global [1000010 x i32], align 16
@r = external dso_local global [1000010 x i32], align 16
@c = external dso_local global [1000010 x i64], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %17, %0
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp sle i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %20

12:                                               ; preds = %7
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i32, ptr @h, i64 %14
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %15)
  br label %17

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %2, align 4, !tbaa !5
  br label %7, !llvm.loop !9

20:                                               ; preds = %11
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr @h, i64 %22
  %24 = getelementptr inbounds i32, ptr %23, i64 1
  %25 = call noundef ptr @_ZSt11max_elementIPiET_S1_S1_(ptr noundef getelementptr inbounds (i32, ptr @h, i64 1), ptr noundef %24)
  %26 = load i32, ptr @n, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr @h, i64 %27
  %29 = getelementptr inbounds i32, ptr %28, i64 1
  %30 = call noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef getelementptr inbounds (i32, ptr @h, i64 1), ptr noundef %25, ptr noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %116, %20
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %119

36:                                               ; preds = %31
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %40
  store i32 %38, ptr %41, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %63, %36
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %61

48:                                               ; preds = %42
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp sgt i32 %52, %59
  br label %61

61:                                               ; preds = %48, %42
  %62 = phi i1 [ false, %42 ], [ %60, %48 ]
  br i1 %62, label %63, label %74

63:                                               ; preds = %61
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %72
  store i32 %70, ptr %73, align 4, !tbaa !5
  br label %42, !llvm.loop !11

74:                                               ; preds = %61
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = icmp eq i32 %78, %85
  br i1 %86, label %87, label %109

87:                                               ; preds = %74
  %88 = load i32, ptr %3, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1000010 x i64], ptr @c, i64 0, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !12
  %95 = add nsw i64 %94, 1
  %96 = load i32, ptr %3, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1000010 x i64], ptr @c, i64 0, i64 %97
  store i64 %95, ptr %98, align 8, !tbaa !12
  %99 = load i32, ptr %3, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = load i32, ptr %3, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %107
  store i32 %105, ptr %108, align 4, !tbaa !5
  br label %109

109:                                              ; preds = %87, %74
  %110 = load i32, ptr %3, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1000010 x i64], ptr @c, i64 0, i64 %111
  %113 = load i64, ptr %112, align 8, !tbaa !12
  %114 = load i64, ptr @ans, align 8, !tbaa !12
  %115 = add nsw i64 %114, %113
  store i64 %115, ptr @ans, align 8, !tbaa !12
  br label %116

116:                                              ; preds = %109
  %117 = load i32, ptr %3, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %3, align 4, !tbaa !5
  br label %31, !llvm.loop !14

119:                                              ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %120 = load i32, ptr @n, align 4, !tbaa !5
  %121 = sub nsw i32 %120, 1
  store i32 %121, ptr %4, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %165, %119
  %123 = load i32, ptr %4, align 4, !tbaa !5
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %126, label %125

125:                                              ; preds = %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %168

126:                                              ; preds = %122
  %127 = load i32, ptr %4, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  %129 = load i32, ptr %4, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %130
  store i32 %128, ptr %131, align 4, !tbaa !5
  br label %132

132:                                              ; preds = %153, %126
  %133 = load i32, ptr %4, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %151

138:                                              ; preds = %132
  %139 = load i32, ptr %4, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = load i32, ptr %4, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = icmp sge i32 %142, %149
  br label %151

151:                                              ; preds = %138, %132
  %152 = phi i1 [ false, %132 ], [ %150, %138 ]
  br i1 %152, label %153, label %164

153:                                              ; preds = %151
  %154 = load i32, ptr %4, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %158
  %160 = load i32, ptr %159, align 4, !tbaa !5
  %161 = load i32, ptr %4, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %162
  store i32 %160, ptr %163, align 4, !tbaa !5
  br label %132, !llvm.loop !15

164:                                              ; preds = %151
  br label %165

165:                                              ; preds = %164
  %166 = load i32, ptr %4, align 4, !tbaa !5
  %167 = add nsw i32 %166, -1
  store i32 %167, ptr %4, align 4, !tbaa !5
  br label %122, !llvm.loop !16

168:                                              ; preds = %125
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %169

169:                                              ; preds = %200, %168
  %170 = load i32, ptr %5, align 4, !tbaa !5
  %171 = load i32, ptr @n, align 4, !tbaa !5
  %172 = icmp sle i32 %170, %171
  br i1 %172, label %174, label %173

173:                                              ; preds = %169
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %203

174:                                              ; preds = %169
  %175 = load i32, ptr %5, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !5
  %179 = load i32, ptr getelementptr inbounds ([1000010 x i32], ptr @h, i64 0, i64 1), align 4, !tbaa !5
  %180 = icmp ne i32 %178, %179
  br i1 %180, label %181, label %199

181:                                              ; preds = %174
  %182 = load i64, ptr @ans, align 8, !tbaa !12
  %183 = add nsw i64 %182, 2
  store i64 %183, ptr @ans, align 8, !tbaa !12
  %184 = load i32, ptr %5, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = icmp eq i32 %187, 1
  br i1 %188, label %189, label %198

189:                                              ; preds = %181
  %190 = load i32, ptr %5, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %191
  %193 = load i32, ptr %192, align 4, !tbaa !5
  %194 = icmp eq i32 %193, 0
  br i1 %194, label %195, label %198

195:                                              ; preds = %189
  %196 = load i64, ptr @ans, align 8, !tbaa !12
  %197 = add nsw i64 %196, -1
  store i64 %197, ptr @ans, align 8, !tbaa !12
  br label %198

198:                                              ; preds = %195, %189, %181
  br label %199

199:                                              ; preds = %198, %174
  br label %200

200:                                              ; preds = %199
  %201 = load i32, ptr %5, align 4, !tbaa !5
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %5, align 4, !tbaa !5
  br label %169, !llvm.loop !17

203:                                              ; preds = %173
  %204 = load i64, ptr @ans, align 8, !tbaa !12
  %205 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %204)
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11max_elementIPiET_S1_S1_(ptr noundef, ptr noundef) #3

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

attributes #0 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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

@n = external dso_local global i32, align 4
@h = external dso_local global [1000010 x i32], align 16
@l = external dso_local local_unnamed_addr global [1000010 x i32], align 16
@r = external dso_local local_unnamed_addr global [1000010 x i32], align 16
@c = external dso_local local_unnamed_addr global [1000010 x i64], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %.not52 = icmp slt i32 %2, 1
  br i1 %.not52, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre98 = sext i32 %2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre98, %.._crit_edge_crit_edge ], [ %16, %.lr.ph ]
  %3 = getelementptr inbounds i32, ptr @h, i64 %.pre-phi
  %4 = getelementptr inbounds i8, ptr %3, i64 4
  %5 = tail call noundef ptr @_ZSt11max_elementIPiET_S1_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @h, i64 4), ptr noundef nonnull %4)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds i32, ptr @h, i64 %7
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  %10 = tail call noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @h, i64 4), ptr noundef %5, ptr noundef nonnull %9)
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !9
  %.not4261 = icmp slt i32 %11, 2
  br i1 %.not4261, label %.preheader50, label %.lr.ph64.preheader

.lr.ph64.preheader:                               ; preds = %._crit_edge
  %12 = add nuw i32 %11, 1
  %wide.trip.count = zext i32 %12 to i64
  br label %.lr.ph57

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %13 = getelementptr inbounds i32, ptr @h, i64 %indvars.iv
  %14 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %.not.not = icmp slt i64 %indvars.iv, %16
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

..preheader50_crit_edge:                          ; preds = %43
  store i64 %45, ptr @ans, align 8, !tbaa !9
  br label %.preheader50

.preheader50:                                     ; preds = %..preheader50_crit_edge, %._crit_edge
  %ans.promoted77 = phi i64 [ %45, %..preheader50_crit_edge ], [ %ans.promoted, %._crit_edge ]
  %.03572 = add nsw i32 %11, -1
  %.not4373 = icmp eq i32 %.03572, 0
  br i1 %.not4373, label %.lr.ph80, label %.lr.ph76.preheader

.lr.ph76.preheader:                               ; preds = %.preheader50
  %17 = sext i32 %.03572 to i64
  br label %.lr.ph76

.lr.ph57:                                         ; preds = %43, %.lr.ph64.preheader
  %indvars.iv84 = phi i64 [ 2, %.lr.ph64.preheader ], [ %indvars.iv.next85, %43 ]
  %18 = phi i64 [ %ans.promoted, %.lr.ph64.preheader ], [ %45, %43 ]
  %19 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %indvars.iv84
  %20 = trunc i64 %indvars.iv84 to i32
  %21 = add i32 %20, -1
  store i32 %21, ptr %19, align 4, !tbaa !5
  %22 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %indvars.iv84
  %23 = load i32, ptr %22, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %.lr.ph57, %29
  %storemerge4855 = phi i32 [ %21, %.lr.ph57 ], [ %31, %29 ]
  %25 = sext i32 %storemerge4855 to i64
  %26 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp sgt i32 %23, %27
  br i1 %28, label %29, label %.critedge

29:                                               ; preds = %24
  %30 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %25
  %31 = load i32, ptr %30, align 4, !tbaa !5
  store i32 %31, ptr %19, align 4, !tbaa !5
  %.not49 = icmp eq i32 %31, 0
  br i1 %.not49, label %.critedge, label %24, !llvm.loop !13

.critedge:                                        ; preds = %24, %29
  %storemerge48.lcssa.ph = phi i32 [ %storemerge4855, %24 ], [ 0, %29 ]
  %32 = sext i32 %storemerge48.lcssa.ph to i64
  %33 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp eq i32 %23, %34
  br i1 %35, label %36, label %.critedge._crit_edge

.critedge._crit_edge:                             ; preds = %.critedge
  %.phi.trans.insert95 = getelementptr inbounds [1000010 x i64], ptr @c, i64 0, i64 %indvars.iv84
  %.pre96 = load i64, ptr %.phi.trans.insert95, align 8, !tbaa !9
  br label %43

36:                                               ; preds = %.critedge
  %37 = getelementptr inbounds [1000010 x i64], ptr @c, i64 0, i64 %32
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = add nsw i64 %38, 1
  %40 = getelementptr inbounds [1000010 x i64], ptr @c, i64 0, i64 %indvars.iv84
  store i64 %39, ptr %40, align 8, !tbaa !9
  %41 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %32
  %42 = load i32, ptr %41, align 4, !tbaa !5
  store i32 %42, ptr %19, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %.critedge._crit_edge, %36
  %44 = phi i64 [ %.pre96, %.critedge._crit_edge ], [ %39, %36 ]
  %45 = add nsw i64 %18, %44
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next85, %wide.trip.count
  br i1 %exitcond.not, label %..preheader50_crit_edge, label %.lr.ph57, !llvm.loop !14

.preheader:                                       ; preds = %.critedge2
  %.not4478 = icmp slt i32 %11, 1
  br i1 %.not4478, label %._crit_edge81, label %.lr.ph80

.lr.ph80:                                         ; preds = %.preheader50, %.preheader
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @h, i64 4), align 4, !tbaa !5
  %47 = add nuw i32 %11, 1
  %wide.trip.count93 = zext i32 %47 to i64
  br label %61

.lr.ph76:                                         ; preds = %.lr.ph76.preheader, %.critedge2
  %indvars.iv87 = phi i64 [ %17, %.lr.ph76.preheader ], [ %indvars.iv.next88, %.critedge2 ]
  %.035.in74 = phi i32 [ %11, %.lr.ph76.preheader ], [ %58, %.critedge2 ]
  %48 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %indvars.iv87
  store i32 %.035.in74, ptr %48, align 4, !tbaa !5
  %.not4667 = icmp eq i32 %.035.in74, 0
  br i1 %.not4667, label %.critedge2, label %.lr.ph70

.lr.ph70:                                         ; preds = %.lr.ph76
  %49 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %indvars.iv87
  %50 = load i32, ptr %49, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %.lr.ph70, %55
  %storemerge68 = phi i32 [ %.035.in74, %.lr.ph70 ], [ %57, %55 ]
  %52 = sext i32 %storemerge68 to i64
  %53 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %.not47 = icmp slt i32 %50, %54
  br i1 %.not47, label %.critedge2, label %55

55:                                               ; preds = %51
  %56 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %52
  %57 = load i32, ptr %56, align 4, !tbaa !5
  store i32 %57, ptr %48, align 4, !tbaa !5
  %.not46 = icmp eq i32 %57, 0
  br i1 %.not46, label %.critedge2, label %51, !llvm.loop !15

.critedge2:                                       ; preds = %55, %51, %.lr.ph76
  %indvars.iv.next88 = add nsw i64 %indvars.iv87, -1
  %.not43 = icmp eq i64 %indvars.iv.next88, 0
  %58 = trunc nsw i64 %indvars.iv87 to i32
  br i1 %.not43, label %.preheader, label %.lr.ph76, !llvm.loop !16

._crit_edge81:                                    ; preds = %76, %.preheader
  %59 = phi i64 [ %ans.promoted77, %.preheader ], [ %77, %76 ]
  %60 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %59)
  ret i32 0

61:                                               ; preds = %.lr.ph80, %76
  %indvars.iv90 = phi i64 [ 1, %.lr.ph80 ], [ %indvars.iv.next91, %76 ]
  %62 = phi i64 [ %ans.promoted77, %.lr.ph80 ], [ %77, %76 ]
  %63 = getelementptr inbounds [1000010 x i32], ptr @h, i64 0, i64 %indvars.iv90
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %.not45 = icmp eq i32 %64, %46
  br i1 %.not45, label %76, label %65

65:                                               ; preds = %61
  %66 = add nsw i64 %62, 2
  store i64 %66, ptr @ans, align 8, !tbaa !9
  %67 = getelementptr inbounds [1000010 x i32], ptr @l, i64 0, i64 %indvars.iv90
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp eq i32 %68, 1
  br i1 %69, label %70, label %76

70:                                               ; preds = %65
  %71 = getelementptr inbounds [1000010 x i32], ptr @r, i64 0, i64 %indvars.iv90
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = add nsw i64 %62, 1
  store i64 %75, ptr @ans, align 8, !tbaa !9
  br label %76

76:                                               ; preds = %61, %74, %70, %65
  %77 = phi i64 [ %62, %61 ], [ %75, %74 ], [ %66, %70 ], [ %66, %65 ]
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %exitcond94.not = icmp eq i64 %indvars.iv.next91, %wide.trip.count93
  br i1 %exitcond94.not, label %._crit_edge81, label %61, !llvm.loop !17
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZNSt3_V26rotateIPiEET_S2_S2_S2_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11max_elementIPiET_S1_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress norecurse 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 = { 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 #2 = { inlinehint 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" }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass