; LLVM IR from tangjz/acm-icpc :: hdu (5191)

; 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
@w = external dso_local global i32, align 4
@h = external dso_local global i32, align 4
@a = external dso_local global [50010 x i32], align 16
@d = external dso_local global [150030 x i32], align 16
@sum = external dso_local global i64, align 8
@sum1 = external dso_local global i64, align 8
@sum2 = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %8

8:                                                ; preds = %165, %39, %0
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @w, ptr noundef @h)
  %10 = icmp eq i32 %9, 3
  br i1 %10, label %11, label %168

11:                                               ; preds = %8
  store i64 0, ptr @sum2, align 8, !tbaa !5
  store i64 0, ptr @sum1, align 8, !tbaa !5
  store i64 0, ptr @sum, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %28, %11
  %13 = load i32, ptr %2, align 4, !tbaa !9
  %14 = load i32, ptr @n, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %31

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %19
  call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %20)
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = load i64, ptr @sum, align 8, !tbaa !5
  %27 = add nsw i64 %26, %25
  store i64 %27, ptr @sum, align 8, !tbaa !5
  br label %28

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

31:                                               ; preds = %16
  %32 = load i64, ptr @sum, align 8, !tbaa !5
  %33 = load i32, ptr @w, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = load i32, ptr @h, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = mul nsw i64 %34, %36
  %38 = icmp slt i64 %32, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %31
  %40 = call i32 @puts(ptr noundef @.str.1)
  br label %8, !llvm.loop !13

41:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %53, %41
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = load i32, ptr @w, align 4, !tbaa !9
  %45 = icmp slt i32 %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %56

47:                                               ; preds = %42
  %48 = load i32, ptr @h, align 4, !tbaa !9
  %49 = sub nsw i32 0, %48
  %50 = load i32, ptr %3, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %51
  store i32 %49, ptr %52, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %47
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !9
  br label %42, !llvm.loop !14

56:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %74, %56
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = load i32, ptr @n, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %77

62:                                               ; preds = %57
  %63 = load i32, ptr %4, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = load i32, ptr @h, align 4, !tbaa !9
  %68 = sub nsw i32 %66, %67
  %69 = load i32, ptr @w, align 4, !tbaa !9
  %70 = load i32, ptr %4, align 4, !tbaa !9
  %71 = add nsw i32 %69, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %72
  store i32 %68, ptr %73, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %62
  %75 = load i32, ptr %4, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %4, align 4, !tbaa !9
  br label %57, !llvm.loop !15

77:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %93, %77
  %79 = load i32, ptr %5, align 4, !tbaa !9
  %80 = load i32, ptr @w, align 4, !tbaa !9
  %81 = icmp slt i32 %79, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %96

83:                                               ; preds = %78
  %84 = load i32, ptr @h, align 4, !tbaa !9
  %85 = sub nsw i32 0, %84
  %86 = load i32, ptr @w, align 4, !tbaa !9
  %87 = load i32, ptr @n, align 4, !tbaa !9
  %88 = add nsw i32 %86, %87
  %89 = load i32, ptr %5, align 4, !tbaa !9
  %90 = add nsw i32 %88, %89
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %91
  store i32 %85, ptr %92, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %83
  %94 = load i32, ptr %5, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %5, align 4, !tbaa !9
  br label %78, !llvm.loop !16

96:                                               ; preds = %82
  store i64 1000000000000, ptr @ans, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %162, %96
  %98 = load i32, ptr %6, align 4, !tbaa !9
  %99 = load i32, ptr @w, align 4, !tbaa !9
  %100 = load i32, ptr @n, align 4, !tbaa !9
  %101 = add nsw i32 %99, %100
  %102 = icmp slt i32 %98, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %165

104:                                              ; preds = %97
  br label %105

105:                                              ; preds = %133, %104
  %106 = load i32, ptr %7, align 4, !tbaa !9
  %107 = load i32, ptr %6, align 4, !tbaa !9
  %108 = load i32, ptr @w, align 4, !tbaa !9
  %109 = add nsw i32 %107, %108
  %110 = icmp slt i32 %106, %109
  br i1 %110, label %111, label %136

111:                                              ; preds = %105
  %112 = load i32, ptr %7, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = icmp sgt i32 %115, 0
  br i1 %116, label %117, label %125

117:                                              ; preds = %111
  %118 = load i32, ptr %7, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !9
  %122 = sext i32 %121 to i64
  %123 = load i64, ptr @sum1, align 8, !tbaa !5
  %124 = add nsw i64 %123, %122
  store i64 %124, ptr @sum1, align 8, !tbaa !5
  br label %133

125:                                              ; preds = %111
  %126 = load i32, ptr %7, align 4, !tbaa !9
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %127
  %129 = load i32, ptr %128, align 4, !tbaa !9
  %130 = sext i32 %129 to i64
  %131 = load i64, ptr @sum2, align 8, !tbaa !5
  %132 = sub nsw i64 %131, %130
  store i64 %132, ptr @sum2, align 8, !tbaa !5
  br label %133

133:                                              ; preds = %125, %117
  %134 = load i32, ptr %7, align 4, !tbaa !9
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %7, align 4, !tbaa !9
  br label %105, !llvm.loop !17

136:                                              ; preds = %105
  %137 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @sum1, ptr noundef nonnull align 8 dereferenceable(8) @sum2)
  %138 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %137)
  %139 = load i64, ptr %138, align 8, !tbaa !5
  store i64 %139, ptr @ans, align 8, !tbaa !5
  %140 = load i32, ptr %6, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !9
  %144 = icmp sgt i32 %143, 0
  br i1 %144, label %145, label %153

145:                                              ; preds = %136
  %146 = load i32, ptr %6, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !9
  %150 = sext i32 %149 to i64
  %151 = load i64, ptr @sum1, align 8, !tbaa !5
  %152 = sub nsw i64 %151, %150
  store i64 %152, ptr @sum1, align 8, !tbaa !5
  br label %161

153:                                              ; preds = %136
  %154 = load i32, ptr %6, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !9
  %158 = sext i32 %157 to i64
  %159 = load i64, ptr @sum2, align 8, !tbaa !5
  %160 = add nsw i64 %159, %158
  store i64 %160, ptr @sum2, align 8, !tbaa !5
  br label %161

161:                                              ; preds = %153, %145
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %6, align 4, !tbaa !9
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %6, align 4, !tbaa !9
  br label %97, !llvm.loop !18

165:                                              ; preds = %103
  %166 = load i64, ptr @ans, align 8, !tbaa !5
  %167 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %166)
  br label %8, !llvm.loop !13

168:                                              ; preds = %8
  ret i32 0
}

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

declare i32 @puts(ptr noundef) #3

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

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

declare i32 @printf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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}
!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"

@n = external dso_local global i32, align 4
@w = external dso_local global i32, align 4
@h = external dso_local global i32, align 4
@a = external dso_local global [50010 x i32], align 16
@d = external dso_local local_unnamed_addr global [150030 x i32], align 16
@sum = external dso_local local_unnamed_addr global i64, align 8
@sum1 = external dso_local global i64, align 8
@sum2 = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @w, ptr noundef nonnull @h)
  %2 = icmp eq i32 %1, 3
  br i1 %2, label %.lr.ph54, label %._crit_edge55

.lr.ph54:                                         ; preds = %0, %.backedge
  store i64 0, ptr @sum2, align 8, !tbaa !5
  store i64 0, ptr @sum1, align 8, !tbaa !5
  store i64 0, ptr @sum, align 8, !tbaa !5
  %3 = load i32, ptr @n, align 4, !tbaa !9
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph54
  %5 = phi i64 [ 0, %.lr.ph54 ], [ %22, %.lr.ph ]
  %6 = phi i32 [ %3, %.lr.ph54 ], [ %23, %.lr.ph ]
  %7 = load i32, ptr @w, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = load i32, ptr @h, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = mul nsw i64 %10, %8
  %12 = icmp slt i64 %5, %11
  br i1 %12, label %26, label %.preheader37

.preheader37:                                     ; preds = %._crit_edge
  %13 = icmp sgt i32 %7, 0
  br i1 %13, label %.lr.ph40, label %.preheader36

.lr.ph40:                                         ; preds = %.preheader37
  %14 = sub nsw i32 0, %9
  %wide.trip.count = zext nneg i32 %7 to i64
  %min.iters.check98 = icmp ult i32 %7, 8
  br i1 %min.iters.check98, label %scalar.ph97.preheader, label %vector.ph99

scalar.ph97.preheader:                            ; preds = %middle.block96, %.lr.ph40
  %indvars.iv59.ph = phi i64 [ 0, %.lr.ph40 ], [ %n.vec101, %middle.block96 ]
  br label %scalar.ph97

vector.ph99:                                      ; preds = %.lr.ph40
  %n.vec101 = and i64 %wide.trip.count, 2147483640
  %broadcast.splatinsert105 = insertelement <4 x i32> poison, i32 %14, i64 0
  %broadcast.splat106 = shufflevector <4 x i32> %broadcast.splatinsert105, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body103

vector.body103:                                   ; preds = %vector.body103, %vector.ph99
  %index104 = phi i64 [ 0, %vector.ph99 ], [ %index.next107, %vector.body103 ]
  %15 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %index104
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  store <4 x i32> %broadcast.splat106, ptr %15, align 16, !tbaa !9
  store <4 x i32> %broadcast.splat106, ptr %16, align 16, !tbaa !9
  %index.next107 = add nuw i64 %index104, 8
  %17 = icmp eq i64 %index.next107, %n.vec101
  br i1 %17, label %middle.block96, label %vector.body103, !llvm.loop !11

middle.block96:                                   ; preds = %vector.body103
  %cmp.n108 = icmp eq i64 %n.vec101, %wide.trip.count
  br i1 %cmp.n108, label %.preheader36, label %scalar.ph97.preheader

.lr.ph:                                           ; preds = %.lr.ph54, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph54 ]
  %18 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %indvars.iv
  tail call void @_Z4scanRi(ptr noundef nonnull align 4 dereferenceable(4) %18)
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = load i64, ptr @sum, align 8, !tbaa !5
  %22 = add nsw i64 %21, %20
  store i64 %22, ptr @sum, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr @n, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !15

26:                                               ; preds = %._crit_edge
  %27 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.backedge

.backedge:                                        ; preds = %26, %._crit_edge52
  %28 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @w, ptr noundef nonnull @h)
  %29 = icmp eq i32 %28, 3
  br i1 %29, label %.lr.ph54, label %._crit_edge55, !llvm.loop !16

.preheader36:                                     ; preds = %scalar.ph97, %middle.block96, %.preheader37
  %30 = icmp sgt i32 %6, 0
  br i1 %30, label %.lr.ph42.preheader, label %.preheader35

.lr.ph42.preheader:                               ; preds = %.preheader36
  %wide.trip.count65 = zext nneg i32 %6 to i64
  %min.iters.check84 = icmp ult i32 %6, 8
  br i1 %min.iters.check84, label %.lr.ph42.preheader109, label %vector.ph85

.lr.ph42.preheader109:                            ; preds = %middle.block82, %.lr.ph42.preheader
  %indvars.iv62.ph = phi i64 [ 0, %.lr.ph42.preheader ], [ %n.vec87, %middle.block82 ]
  br label %.lr.ph42

vector.ph85:                                      ; preds = %.lr.ph42.preheader
  %n.vec87 = and i64 %wide.trip.count65, 2147483640
  %broadcast.splatinsert92 = insertelement <4 x i32> poison, i32 %9, i64 0
  %broadcast.splat93 = shufflevector <4 x i32> %broadcast.splatinsert92, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body89

vector.body89:                                    ; preds = %vector.body89, %vector.ph85
  %index90 = phi i64 [ 0, %vector.ph85 ], [ %index.next94, %vector.body89 ]
  %31 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %index90
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %wide.load = load <4 x i32>, ptr %31, align 16, !tbaa !9
  %wide.load91 = load <4 x i32>, ptr %32, align 16, !tbaa !9
  %33 = sub nsw <4 x i32> %wide.load, %broadcast.splat93
  %34 = sub nsw <4 x i32> %wide.load91, %broadcast.splat93
  %35 = add nsw i64 %index90, %8
  %36 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %35
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  store <4 x i32> %33, ptr %36, align 4, !tbaa !9
  store <4 x i32> %34, ptr %37, align 4, !tbaa !9
  %index.next94 = add nuw i64 %index90, 8
  %38 = icmp eq i64 %index.next94, %n.vec87
  br i1 %38, label %middle.block82, label %vector.body89, !llvm.loop !17

middle.block82:                                   ; preds = %vector.body89
  %cmp.n95 = icmp eq i64 %n.vec87, %wide.trip.count65
  br i1 %cmp.n95, label %.preheader35, label %.lr.ph42.preheader109

scalar.ph97:                                      ; preds = %scalar.ph97.preheader, %scalar.ph97
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %scalar.ph97 ], [ %indvars.iv59.ph, %scalar.ph97.preheader ]
  %39 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv59
  store i32 %14, ptr %39, align 4, !tbaa !9
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next60, %wide.trip.count
  br i1 %exitcond.not, label %.preheader36, label %scalar.ph97, !llvm.loop !18

.preheader35:                                     ; preds = %.lr.ph42, %middle.block82, %.preheader36
  br i1 %13, label %.lr.ph44, label %.preheader35.._crit_edge45_crit_edge

.preheader35.._crit_edge45_crit_edge:             ; preds = %.preheader35
  %.pre = add nsw i32 %6, %7
  br label %._crit_edge45

.lr.ph44:                                         ; preds = %.preheader35
  %40 = sub nsw i32 0, %9
  %41 = add nsw i32 %7, %6
  %42 = sext i32 %41 to i64
  %wide.trip.count70 = zext nneg i32 %7 to i64
  %min.iters.check = icmp ult i32 %7, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph44
  %indvars.iv67.ph = phi i64 [ 0, %.lr.ph44 ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph44
  %n.vec = and i64 %wide.trip.count70, 2147483640
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %40, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %43 = add nsw i64 %index, %42
  %44 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %43
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  store <4 x i32> %broadcast.splat, ptr %44, align 4, !tbaa !9
  store <4 x i32> %broadcast.splat, ptr %45, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 8
  %46 = icmp eq i64 %index.next, %n.vec
  br i1 %46, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count70
  br i1 %cmp.n, label %._crit_edge45, label %scalar.ph.preheader

.lr.ph42:                                         ; preds = %.lr.ph42.preheader109, %.lr.ph42
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %.lr.ph42 ], [ %indvars.iv62.ph, %.lr.ph42.preheader109 ]
  %47 = getelementptr inbounds [50010 x i32], ptr @a, i64 0, i64 %indvars.iv62
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = sub nsw i32 %48, %9
  %50 = add nsw i64 %indvars.iv62, %8
  %51 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %50
  store i32 %49, ptr %51, align 4, !tbaa !9
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %exitcond66.not = icmp eq i64 %indvars.iv.next63, %wide.trip.count65
  br i1 %exitcond66.not, label %.preheader35, label %.lr.ph42, !llvm.loop !20

._crit_edge45:                                    ; preds = %scalar.ph, %middle.block, %.preheader35.._crit_edge45_crit_edge
  %.pre-phi = phi i32 [ %.pre, %.preheader35.._crit_edge45_crit_edge ], [ %41, %middle.block ], [ %41, %scalar.ph ]
  store i64 1000000000000, ptr @ans, align 8, !tbaa !5
  %52 = icmp sgt i32 %.pre-phi, 0
  br i1 %52, label %.preheader, label %._crit_edge52

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %scalar.ph ], [ %indvars.iv67.ph, %scalar.ph.preheader ]
  %53 = add nsw i64 %indvars.iv67, %42
  %54 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %53
  store i32 %40, ptr %54, align 4, !tbaa !9
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond71.not = icmp eq i64 %indvars.iv.next68, %wide.trip.count70
  br i1 %exitcond71.not, label %._crit_edge45, label %scalar.ph, !llvm.loop !21

.preheader:                                       ; preds = %._crit_edge45, %93
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %93 ], [ 0, %._crit_edge45 ]
  %55 = phi i32 [ %94, %93 ], [ %7, %._crit_edge45 ]
  %.051 = phi i32 [ %.1.lcssa, %93 ], [ 0, %._crit_edge45 ]
  %56 = trunc nuw nsw i64 %indvars.iv75 to i32
  %57 = add nsw i32 %55, %56
  %58 = icmp slt i32 %.051, %57
  br i1 %58, label %.lr.ph47.preheader, label %._crit_edge48

.lr.ph47.preheader:                               ; preds = %.preheader
  %sum1.promoted = load i64, ptr @sum1, align 8, !tbaa !5
  %sum2.promoted = load i64, ptr @sum2, align 8, !tbaa !5
  %59 = sext i32 %.051 to i64
  %60 = sext i32 %57 to i64
  br label %.lr.ph47

._crit_edge52:                                    ; preds = %93, %._crit_edge45
  %61 = phi i64 [ 1000000000000, %._crit_edge45 ], [ %81, %93 ]
  %62 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %61)
  br label %.backedge

.lr.ph47:                                         ; preds = %.lr.ph47.preheader, %74
  %indvars.iv72 = phi i64 [ %59, %.lr.ph47.preheader ], [ %indvars.iv.next73, %74 ]
  %63 = phi i64 [ %sum2.promoted, %.lr.ph47.preheader ], [ %76, %74 ]
  %64 = phi i64 [ %sum1.promoted, %.lr.ph47.preheader ], [ %75, %74 ]
  %65 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv72
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %68, label %71

68:                                               ; preds = %.lr.ph47
  %69 = zext nneg i32 %66 to i64
  %70 = add nsw i64 %64, %69
  store i64 %70, ptr @sum1, align 8, !tbaa !5
  br label %74

71:                                               ; preds = %.lr.ph47
  %72 = sext i32 %66 to i64
  %73 = sub nsw i64 %63, %72
  store i64 %73, ptr @sum2, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %71, %68
  %75 = phi i64 [ %64, %71 ], [ %70, %68 ]
  %76 = phi i64 [ %73, %71 ], [ %63, %68 ]
  %indvars.iv.next73 = add nsw i64 %indvars.iv72, 1
  %77 = icmp slt i64 %indvars.iv.next73, %60
  br i1 %77, label %.lr.ph47, label %._crit_edge48.loopexit, !llvm.loop !22

._crit_edge48.loopexit:                           ; preds = %74
  %78 = trunc nsw i64 %indvars.iv.next73 to i32
  br label %._crit_edge48

._crit_edge48:                                    ; preds = %._crit_edge48.loopexit, %.preheader
  %.1.lcssa = phi i32 [ %.051, %.preheader ], [ %78, %._crit_edge48.loopexit ]
  %79 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @sum1, ptr noundef nonnull align 8 dereferenceable(8) @sum2)
  %80 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %79)
  %81 = load i64, ptr %80, align 8, !tbaa !5
  store i64 %81, ptr @ans, align 8, !tbaa !5
  %82 = getelementptr inbounds [150030 x i32], ptr @d, i64 0, i64 %indvars.iv75
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = icmp sgt i32 %83, 0
  br i1 %84, label %85, label %89

85:                                               ; preds = %._crit_edge48
  %86 = zext nneg i32 %83 to i64
  %87 = load i64, ptr @sum1, align 8, !tbaa !5
  %88 = sub nsw i64 %87, %86
  store i64 %88, ptr @sum1, align 8, !tbaa !5
  br label %93

89:                                               ; preds = %._crit_edge48
  %90 = sext i32 %83 to i64
  %91 = load i64, ptr @sum2, align 8, !tbaa !5
  %92 = add nsw i64 %91, %90
  store i64 %92, ptr @sum2, align 8, !tbaa !5
  br label %93

93:                                               ; preds = %85, %89
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %94 = load i32, ptr @w, align 4, !tbaa !9
  %95 = load i32, ptr @n, align 4, !tbaa !9
  %96 = add nsw i32 %95, %94
  %97 = sext i32 %96 to i64
  %98 = icmp slt i64 %indvars.iv.next76, %97
  br i1 %98, label %.preheader, label %._crit_edge52, !llvm.loop !23

._crit_edge55:                                    ; preds = %.backedge, %0
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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 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 #2 = { 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 #3 = { 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" }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12, !13, !14}
!18 = distinct !{!18, !12, !14, !13}
!19 = distinct !{!19, !12, !13, !14}
!20 = distinct !{!20, !12, !14, !13}
!21 = distinct !{!21, !12, !14, !13}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass