; LLVM IR from tangjz/acm-icpc :: hdu/6351.ll (Z3dfsiii)

; 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
@pL = external dso_local global [11 x i32], align 16
@pR = external dso_local global [11 x i32], align 16
@qL = external dso_local global [9 x i32], align 16
@qR = external dso_local global [9 x i32], align 16
@low = external dso_local global i32, align 4
@upp = external dso_local global i32, align 4
@buf = external dso_local global [11 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %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
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp eq i32 %9, %10
  br i1 %11, label %12, label %17

12:                                               ; preds = %3
  %13 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @low, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %14 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %14, ptr @low, align 4, !tbaa !5
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @upp, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr @upp, align 4, !tbaa !5
  br label %129

17:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  store i32 %22, ptr %7, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %124, %17
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = icmp ne i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %129

28:                                               ; preds = %23
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %37
  store i32 %32, ptr %38, align 4, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %47
  store i32 %42, ptr %48, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = icmp ne i32 %53, %54
  %56 = zext i1 %55 to i32
  %57 = add nsw i32 %49, %56
  store i32 %57, ptr %8, align 4, !tbaa !5
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = load i32, ptr @m, align 4, !tbaa !5
  %60 = icmp sle i32 %58, %59
  br i1 %60, label %61, label %110

61:                                               ; preds = %28
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %70
  store i32 %65, ptr %71, align 4, !tbaa !5
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %80
  store i32 %75, ptr %81, align 4, !tbaa !5
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = shl i32 %85, 3
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = shl i32 %87, 1
  %89 = add nsw i32 %86, %88
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [11 x i8], ptr @buf, i64 0, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !9
  %94 = sext i8 %93 to i32
  %95 = add nsw i32 %89, %94
  call void @_Z3dfsiii(i32 noundef %83, i32 noundef %84, i32 noundef %95)
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %101
  store i32 %96, ptr %102, align 4, !tbaa !5
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = load i32, ptr %7, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %108
  store i32 %103, ptr %109, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %61, %28
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = load i32, ptr %7, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %116
  store i32 %111, ptr %117, align 4, !tbaa !5
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %122
  store i32 %111, ptr %123, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %124

124:                                              ; preds = %110
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  store i32 %128, ptr %7, align 4, !tbaa !5
  br label %23, !llvm.loop !10

129:                                              ; preds = %27, %12
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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)) #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

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 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@n = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@pL = external dso_local local_unnamed_addr global [11 x i32], align 16
@pR = external dso_local local_unnamed_addr global [11 x i32], align 16
@qL = external dso_local local_unnamed_addr global [9 x i32], align 16
@qR = external dso_local local_unnamed_addr global [9 x i32], align 16
@low = external dso_local global i32, align 4
@upp = external dso_local global i32, align 4
@buf = external dso_local local_unnamed_addr global [11 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  store i32 %2, ptr %4, align 4, !tbaa !5
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = icmp eq i32 %5, %0
  br i1 %6, label %7, label %12

7:                                                ; preds = %3
  %8 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @low, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %9 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %9, ptr @low, align 4, !tbaa !5
  %10 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @upp, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %11 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %11, ptr @upp, align 4, !tbaa !5
  br label %.loopexit

12:                                               ; preds = %3
  %13 = add nsw i32 %5, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %14
  %.029 = load i32, ptr %15, align 4, !tbaa !5
  %.not30 = icmp eq i32 %.029, %5
  br i1 %.not30, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %12
  %16 = sext i32 %0 to i64
  %17 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %16
  %18 = add nsw i32 %0, 1
  %19 = mul i32 %2, 10
  %.phi.trans.insert = sext i32 %.029 to i64
  %.phi.trans.insert32 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %.phi.trans.insert
  %.pre = load i32, ptr %.phi.trans.insert32, align 4, !tbaa !5
  %.pre34 = load i32, ptr @m, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %.lr.ph, %55
  %21 = phi i32 [ %5, %.lr.ph ], [ %56, %55 ]
  %22 = phi i32 [ %.pre34, %.lr.ph ], [ %57, %55 ]
  %23 = phi i32 [ %.pre, %.lr.ph ], [ %.031, %55 ]
  %.031 = phi i32 [ %.029, %.lr.ph ], [ %59, %55 ]
  %24 = sext i32 %.031 to i64
  %25 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %24
  %26 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %24
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %28
  store i32 %23, ptr %29, align 4, !tbaa !5
  %30 = load i32, ptr %25, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %31
  store i32 %27, ptr %32, align 4, !tbaa !5
  %33 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %24
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp ne i32 %34, %0
  %36 = zext i1 %35 to i32
  %37 = add nsw i32 %36, %1
  %.not28 = icmp sgt i32 %37, %22
  br i1 %.not28, label %55, label %38

38:                                               ; preds = %20
  %39 = load i32, ptr %17, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %40
  store i32 %34, ptr %41, align 4, !tbaa !5
  %42 = load i32, ptr %33, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %43
  store i32 %39, ptr %44, align 4, !tbaa !5
  %45 = getelementptr inbounds [11 x i8], ptr @buf, i64 0, i64 %24
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = add nsw i32 %19, %47
  tail call void @_Z3dfsiii(i32 noundef %18, i32 noundef %37, i32 noundef %48)
  %49 = load i32, ptr %17, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [9 x i32], ptr @qR, i64 0, i64 %50
  store i32 %0, ptr %51, align 4, !tbaa !5
  %52 = load i32, ptr %33, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [9 x i32], ptr @qL, i64 0, i64 %53
  store i32 %.031, ptr %54, align 4, !tbaa !5
  %.pre33 = load i32, ptr @m, align 4, !tbaa !5
  %.pre35 = load i32, ptr %25, align 4, !tbaa !5
  %.pre36 = load i32, ptr @n, align 4, !tbaa !5
  %.pre37 = sext i32 %.pre35 to i64
  br label %55

55:                                               ; preds = %38, %20
  %.pre-phi = phi i64 [ %.pre37, %38 ], [ %31, %20 ]
  %56 = phi i32 [ %.pre36, %38 ], [ %21, %20 ]
  %57 = phi i32 [ %.pre33, %38 ], [ %22, %20 ]
  %58 = getelementptr inbounds [11 x i32], ptr @pR, i64 0, i64 %.pre-phi
  store i32 %.031, ptr %58, align 4, !tbaa !5
  %59 = load i32, ptr %26, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [11 x i32], ptr @pL, i64 0, i64 %60
  store i32 %.031, ptr %61, align 4, !tbaa !5
  %.not = icmp eq i32 %59, %56
  br i1 %.not, label %.loopexit, label %20, !llvm.loop !10

.loopexit:                                        ; preds = %55, %12, %7
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #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 #1

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass