; LLVM IR from upupming/algorithm :: acwing/算法竞赛进阶指南/0x52-背包/281. 硬币 (main)

; 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
@m = external dso_local global i32, align 4
@a = external dso_local global [110 x i32], align 16
@c = external dso_local global [110 x i32], align 16
@f = external dso_local global [100010 x i32], align 16
@used = external dso_local global [100010 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 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
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %11

11:                                               ; preds = %163, %0
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %18, label %15

15:                                               ; preds = %11
  %16 = load i32, ptr @m, align 4, !tbaa !5
  %17 = icmp ne i32 %16, 0
  br label %18

18:                                               ; preds = %15, %11
  %19 = phi i1 [ true, %11 ], [ %17, %15 ]
  br i1 %19, label %20, label %166

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %31, %20
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @n, align 4, !tbaa !5
  %24 = icmp sle i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %34

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %28
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %29)
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !9

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

35:                                               ; preds = %45, %34
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = icmp sle i32 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [110 x i32], ptr @c, i64 0, i64 %42
  %44 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %43)
  br label %45

45:                                               ; preds = %40
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %35, !llvm.loop !11

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

49:                                               ; preds = %58, %48
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = load i32, ptr @m, align 4, !tbaa !5
  %52 = icmp sle i32 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %61

54:                                               ; preds = %49
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %56
  store i32 0, ptr %57, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %54
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %4, align 4, !tbaa !5
  br label %49, !llvm.loop !12

61:                                               ; preds = %53
  store i32 1, ptr @f, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %144, %61
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = load i32, ptr @n, align 4, !tbaa !5
  %65 = icmp sle i32 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %147

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %77, %67
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = load i32, ptr @m, align 4, !tbaa !5
  %71 = icmp sle i32 %69, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %68
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %80

73:                                               ; preds = %68
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100010 x i32], ptr @used, i64 0, i64 %75
  store i32 0, ptr %76, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %73
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %7, align 4, !tbaa !5
  br label %68, !llvm.loop !13

80:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  store i32 %84, ptr %8, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %140, %80
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr @m, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 19, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %143

90:                                               ; preds = %85
  %91 = load i32, ptr %8, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %139, label %96

96:                                               ; preds = %90
  %97 = load i32, ptr %8, align 4, !tbaa !5
  %98 = load i32, ptr %5, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = sub nsw i32 %97, %101
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %139

107:                                              ; preds = %96
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = load i32, ptr %5, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = sub nsw i32 %108, %112
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [100010 x i32], ptr @used, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = load i32, ptr %5, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [110 x i32], ptr @c, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = icmp slt i32 %116, %120
  br i1 %121, label %122, label %139

122:                                              ; preds = %107
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %124
  store i32 1, ptr %125, align 4, !tbaa !5
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = load i32, ptr %5, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = sub nsw i32 %126, %130
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [100010 x i32], ptr @used, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [100010 x i32], ptr @used, i64 0, i64 %137
  store i32 %135, ptr %138, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %122, %107, %96, %90
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %8, align 4, !tbaa !5
  br label %85, !llvm.loop !14

143:                                              ; preds = %89
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %5, align 4, !tbaa !5
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %5, align 4, !tbaa !5
  br label %62, !llvm.loop !15

147:                                              ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %160, %147
  %149 = load i32, ptr %10, align 4, !tbaa !5
  %150 = load i32, ptr @m, align 4, !tbaa !5
  %151 = icmp sle i32 %149, %150
  br i1 %151, label %153, label %152

152:                                              ; preds = %148
  store i32 22, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %163

153:                                              ; preds = %148
  %154 = load i32, ptr %10, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %155
  %157 = load i32, ptr %156, align 4, !tbaa !5
  %158 = load i32, ptr %9, align 4, !tbaa !5
  %159 = add nsw i32 %158, %157
  store i32 %159, ptr %9, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %153
  %161 = load i32, ptr %10, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %10, align 4, !tbaa !5
  br label %148, !llvm.loop !16

163:                                              ; preds = %152
  %164 = load i32, ptr %9, align 4, !tbaa !5
  %165 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %164)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %11, !llvm.loop !17

166:                                              ; preds = %18
  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

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 = { 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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!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
@m = external dso_local global i32, align 4
@a = external dso_local global [110 x i32], align 16
@c = external dso_local global [110 x i32], align 16
@f = external dso_local local_unnamed_addr global [100010 x i32], align 16
@used = external dso_local local_unnamed_addr global [100010 x i32], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind 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, ptr noundef nonnull @m)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp ne i32 %2, 0
  %4 = load i32, ptr @m, align 4
  %5 = icmp ne i32 %4, 0
  %6 = select i1 %3, i1 true, i1 %5
  br i1 %6, label %.preheader50, label %._crit_edge78

.preheader50:                                     ; preds = %0, %._crit_edge76
  %7 = phi i32 [ %53, %._crit_edge76 ], [ %2, %0 ]
  %.not52 = icmp slt i32 %7, 1
  br i1 %.not52, label %.preheader48, label %.lr.ph

.preheader49:                                     ; preds = %.lr.ph
  %.not3954 = icmp slt i32 %10, 1
  br i1 %.not3954, label %.preheader48, label %.lr.ph56

.lr.ph:                                           ; preds = %.preheader50, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.preheader50 ]
  %8 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %indvars.iv
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %8)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %.not.not = icmp slt i64 %indvars.iv, %11
  br i1 %.not.not, label %.lr.ph, label %.preheader49, !llvm.loop !9

.preheader48:                                     ; preds = %.lr.ph56, %.preheader50, %.preheader49
  %.lcssa = phi i32 [ %10, %.preheader49 ], [ %7, %.preheader50 ], [ %17, %.lr.ph56 ]
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %.not4057 = icmp slt i32 %12, 1
  br i1 %.not4057, label %._crit_edge, label %.lr.ph59.preheader

.lr.ph59.preheader:                               ; preds = %.preheader48
  %13 = zext nneg i32 %12 to i64
  %14 = shl nuw nsw i64 %13, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 getelementptr inbounds (i8, ptr @f, i64 4), i8 0, i64 %14, i1 false), !tbaa !5
  br label %._crit_edge

.lr.ph56:                                         ; preds = %.preheader49, %.lr.ph56
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %.lr.ph56 ], [ 1, %.preheader49 ]
  %15 = getelementptr inbounds [110 x i32], ptr @c, i64 0, i64 %indvars.iv82
  %16 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %15)
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %.not39.not = icmp slt i64 %indvars.iv82, %18
  br i1 %.not39.not, label %.lr.ph56, label %.preheader48, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph59.preheader, %.preheader48
  store i32 1, ptr @f, align 16, !tbaa !5
  %.not4170 = icmp slt i32 %.lcssa, 1
  br i1 %.not4170, label %.preheader47, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %._crit_edge
  %.not4361 = icmp slt i32 %12, 0
  %19 = add i32 %12, 1
  %20 = zext i32 %19 to i64
  %21 = shl nuw nsw i64 %20, 2
  %22 = add nuw i32 %.lcssa, 1
  %wide.trip.count = zext i32 %22 to i64
  br label %.preheader

.preheader47:                                     ; preds = %._crit_edge69, %._crit_edge
  br i1 %.not4057, label %._crit_edge76, label %.lr.ph75.preheader

.lr.ph75.preheader:                               ; preds = %.preheader47
  %23 = add nuw i32 %12, 1
  %wide.trip.count101 = zext i32 %23 to i64
  %24 = zext nneg i32 %12 to i64
  %min.iters.check = icmp ult i32 %12, 8
  br i1 %min.iters.check, label %.lr.ph75.preheader112, label %vector.ph

.lr.ph75.preheader112:                            ; preds = %middle.block, %.lr.ph75.preheader
  %indvars.iv98.ph = phi i64 [ 1, %.lr.ph75.preheader ], [ %ind.end, %middle.block ]
  %.03273.ph = phi i32 [ 0, %.lr.ph75.preheader ], [ %30, %middle.block ]
  br label %.lr.ph75

vector.ph:                                        ; preds = %.lr.ph75.preheader
  %n.vec = and i64 %24, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %27, %vector.body ]
  %vec.phi110 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %28, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %25 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %offset.idx
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %wide.load = load <4 x i32>, ptr %25, align 4, !tbaa !5
  %wide.load111 = load <4 x i32>, ptr %26, align 4, !tbaa !5
  %27 = add <4 x i32> %wide.load, %vec.phi
  %28 = add <4 x i32> %wide.load111, %vec.phi110
  %index.next = add nuw i64 %index, 8
  %29 = icmp eq i64 %index.next, %n.vec
  br i1 %29, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %28, %27
  %30 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %24
  br i1 %cmp.n, label %._crit_edge76, label %.lr.ph75.preheader112

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge69
  %indvars.iv94 = phi i64 [ 1, %.preheader.lr.ph ], [ %indvars.iv.next95, %._crit_edge69 ]
  br i1 %.not4361, label %._crit_edge64, label %.lr.ph63.preheader

.lr.ph63.preheader:                               ; preds = %.preheader
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @used, i8 0, i64 %21, i1 false), !tbaa !5
  br label %._crit_edge64

._crit_edge64:                                    ; preds = %.lr.ph63.preheader, %.preheader
  %31 = getelementptr inbounds [110 x i32], ptr @a, i64 0, i64 %indvars.iv94
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not4465 = icmp sgt i32 %32, %12
  br i1 %.not4465, label %._crit_edge69, label %.lr.ph68

.lr.ph68:                                         ; preds = %._crit_edge64
  %33 = getelementptr inbounds [110 x i32], ptr @c, i64 0, i64 %indvars.iv94
  %34 = sext i32 %32 to i64
  br label %35

._crit_edge69:                                    ; preds = %50, %._crit_edge64
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %exitcond97.not = icmp eq i64 %indvars.iv.next95, %wide.trip.count
  br i1 %exitcond97.not, label %.preheader47, label %.preheader, !llvm.loop !15

35:                                               ; preds = %.lr.ph68, %50
  %indvars.iv91 = phi i64 [ %34, %.lr.ph68 ], [ %indvars.iv.next92, %50 ]
  %36 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %indvars.iv91
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %.not45 = icmp eq i32 %37, 0
  br i1 %.not45, label %38, label %50

38:                                               ; preds = %35
  %39 = sub nsw i64 %indvars.iv91, %34
  %40 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %.not46 = icmp eq i32 %41, 0
  br i1 %.not46, label %50, label %42

42:                                               ; preds = %38
  %43 = getelementptr inbounds [100010 x i32], ptr @used, i64 0, i64 %39
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = load i32, ptr %33, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %42
  store i32 1, ptr %36, align 4, !tbaa !5
  %48 = add nsw i32 %44, 1
  %49 = getelementptr inbounds [100010 x i32], ptr @used, i64 0, i64 %indvars.iv91
  store i32 %48, ptr %49, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %35, %38, %42, %47
  %indvars.iv.next92 = add nsw i64 %indvars.iv91, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next92 to i32
  %exitcond.not = icmp eq i32 %19, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge69, label %35, !llvm.loop !16

._crit_edge76:                                    ; preds = %.lr.ph75, %middle.block, %.preheader47
  %.032.lcssa = phi i32 [ 0, %.preheader47 ], [ %30, %middle.block ], [ %60, %.lr.ph75 ]
  %51 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.032.lcssa)
  %52 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 0
  %55 = load i32, ptr @m, align 4
  %56 = icmp ne i32 %55, 0
  %57 = select i1 %54, i1 true, i1 %56
  br i1 %57, label %.preheader50, label %._crit_edge78, !llvm.loop !17

.lr.ph75:                                         ; preds = %.lr.ph75.preheader112, %.lr.ph75
  %indvars.iv98 = phi i64 [ %indvars.iv.next99, %.lr.ph75 ], [ %indvars.iv98.ph, %.lr.ph75.preheader112 ]
  %.03273 = phi i32 [ %60, %.lr.ph75 ], [ %.03273.ph, %.lr.ph75.preheader112 ]
  %58 = getelementptr inbounds [100010 x i32], ptr @f, i64 0, i64 %indvars.iv98
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, %.03273
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %exitcond102.not = icmp eq i64 %indvars.iv.next99, %wide.trip.count101
  br i1 %exitcond102.not, label %._crit_edge76, label %.lr.ph75, !llvm.loop !18

._crit_edge78:                                    ; preds = %._crit_edge76, %0
  ret i32 0
}

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3

attributes #0 = { mustprogress nofree norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = distinct !{!12, !10, !13, !14}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !14, !13}


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