; LLVM IR from tangjz/acm-icpc :: lydsy/2671.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"

@T = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@d = external dso_local global [11 x i32], align 16
@qL = external dso_local global i32, align 4
@qR = external dso_local global i32, align 4
@tmp = external dso_local global i64, align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %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
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = 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
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = load i32, ptr @cnt, align 4, !tbaa !5
  %17 = icmp sgt i32 %15, %16
  br i1 %17, label %18, label %67

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %19 = load i32, ptr @qL, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = sdiv i32 %20, %21
  store i32 %22, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %23 = load i32, ptr @qR, align 4, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sdiv i32 %23, %24
  store i32 %25, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %26 = load i32, ptr @T, align 4, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = sdiv i32 %26, %27
  store i32 %28, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = sdiv i32 %29, %30
  store i32 %31, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 1, ptr %12, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %33 = load i32, ptr %32, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  store i32 %33, ptr %10, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %63, %18
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sdiv i32 %36, %37
  %39 = icmp sle i32 %35, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %34
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = load i32, ptr %10, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul nsw i64 %43, %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = sdiv i32 %47, %48
  store i32 %49, ptr %13, align 4, !tbaa !5
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %51 = load i32, ptr %50, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %52 = load i32, ptr %9, align 4, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  %55 = sdiv i32 %52, %54
  store i32 %55, ptr %14, align 4, !tbaa !5
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = sub nsw i32 %51, %57
  %59 = sext i32 %58 to i64
  %60 = mul nsw i64 %46, %59
  %61 = load i64, ptr @tmp, align 8, !tbaa !9
  %62 = add nsw i64 %61, %60
  store i64 %62, ptr @tmp, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %63

63:                                               ; preds = %41
  %64 = load i32, ptr %10, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %10, align 4, !tbaa !5
  br label %34, !llvm.loop !11

66:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %82

67:                                               ; preds = %3
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3dfsiii(i32 noundef %69, i32 noundef %70, i32 noundef %71)
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [11 x i32], ptr @d, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = mul nsw i32 %74, %78
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sub nsw i32 0, %80
  call void @_Z3dfsiii(i32 noundef %73, i32 noundef %79, i32 noundef %81)
  br label %82

82:                                               ; preds = %67, %66
  ret void
}

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

; Function Attrs: 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)) #2

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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"}


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

@T = external dso_local local_unnamed_addr global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@d = external dso_local local_unnamed_addr global [11 x i32], align 16
@qL = external dso_local local_unnamed_addr global i32, align 4
@qR = external dso_local local_unnamed_addr global i32, align 4
@tmp = external dso_local local_unnamed_addr global i64, align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %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 = load i32, ptr @cnt, align 4, !tbaa !5
  %11 = icmp slt i32 %10, %0
  br i1 %11, label %tailrecurse._crit_edge, label %tailrecurse.preheader

tailrecurse.preheader:                            ; preds = %3
  %12 = sext i32 %0 to i64
  br label %tailrecurse

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %3
  %.tr22.lcssa = phi i32 [ %1, %3 ], [ %47, %tailrecurse ]
  %.tr23.lcssa = phi i32 [ %2, %3 ], [ %48, %tailrecurse ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %13 = load i32, ptr @qL, align 4, !tbaa !5
  %14 = add nsw i32 %13, -1
  %15 = sdiv i32 %14, %.tr22.lcssa
  store i32 %15, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %16 = load i32, ptr @qR, align 4, !tbaa !5
  %17 = sdiv i32 %16, %.tr22.lcssa
  store i32 %17, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr @T, align 4, !tbaa !5
  %19 = sdiv i32 %18, %.tr22.lcssa
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %20 = sdiv i32 %19, %17
  store i32 %20, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  store i32 1, ptr %7, align 4, !tbaa !5
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %22 = load i32, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  %23 = sdiv i32 %19, %15
  %.not28 = icmp sgt i32 %22, %23
  br i1 %.not28, label %._crit_edge, label %.lr.ph30

.lr.ph30:                                         ; preds = %tailrecurse._crit_edge
  %24 = sext i32 %.tr23.lcssa to i64
  %25 = sext i32 %22 to i64
  br label %26

._crit_edge:                                      ; preds = %26, %tailrecurse._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  ret void

26:                                               ; preds = %.lr.ph30, %26
  %indvars.iv34 = phi i64 [ %25, %.lr.ph30 ], [ %indvars.iv.next35, %26 ]
  %27 = mul nsw i64 %indvars.iv34, %24
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %28 = trunc nsw i64 %indvars.iv34 to i32
  %29 = sdiv i32 %19, %28
  store i32 %29, ptr %8, align 4, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %31 = load i32, ptr %30, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %indvars.iv.next35 = add nsw i64 %indvars.iv34, 1
  %32 = trunc nsw i64 %indvars.iv.next35 to i32
  %33 = sdiv i32 %19, %32
  store i32 %33, ptr %9, align 4, !tbaa !5
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sub nsw i32 %31, %35
  %37 = sext i32 %36 to i64
  %38 = mul nsw i64 %27, %37
  %39 = load i64, ptr @tmp, align 8, !tbaa !9
  %40 = add nsw i64 %38, %39
  store i64 %40, ptr @tmp, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sdiv i32 %19, %41
  %43 = sext i32 %42 to i64
  %.not.not = icmp slt i64 %indvars.iv34, %43
  br i1 %.not.not, label %26, label %._crit_edge, !llvm.loop !11

tailrecurse:                                      ; preds = %tailrecurse.preheader, %tailrecurse
  %indvars.iv = phi i64 [ %12, %tailrecurse.preheader ], [ %indvars.iv.next, %tailrecurse ]
  %.tr2326 = phi i32 [ %2, %tailrecurse.preheader ], [ %48, %tailrecurse ]
  %.tr2225 = phi i32 [ %1, %tailrecurse.preheader ], [ %47, %tailrecurse ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %44 = trunc nsw i64 %indvars.iv.next to i32
  tail call void @_Z3dfsiii(i32 noundef %44, i32 noundef %.tr2225, i32 noundef %.tr2326)
  %45 = getelementptr inbounds [11 x i32], ptr @d, i64 0, i64 %indvars.iv
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = mul nsw i32 %46, %.tr2225
  %48 = sub nsw i32 0, %.tr2326
  %49 = load i32, ptr @cnt, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %.not31 = icmp slt i64 %indvars.iv, %50
  br i1 %.not31, label %tailrecurse, label %tailrecurse._crit_edge
}

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

; Function Attrs: 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 #2

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !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"}


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