; LLVM IR from tangjz/acm-icpc :: lydsy/3083.ll (Z6modifyiiiiii)

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

%struct.Segment = type { i32, i32 }

@seg = external dso_local global [262144 x %struct.Segment], align 16

; 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 nounwind uwtable
declare dso_local void @_Z9push_downi(i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6modifyiiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %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
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !5
  %14 = load i32, ptr %10, align 4, !tbaa !5
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = icmp sle i32 %14, %15
  br i1 %16, label %17, label %31

17:                                               ; preds = %6
  %18 = load i32, ptr %9, align 4, !tbaa !5
  %19 = load i32, ptr %11, align 4, !tbaa !5
  %20 = icmp sle i32 %18, %19
  br i1 %20, label %21, label %31

21:                                               ; preds = %17
  %22 = load i32, ptr %12, align 4, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.Segment, ptr %25, i32 0, i32 1
  store i32 %22, ptr %26, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.Segment, ptr %29, i32 0, i32 0
  store i32 %22, ptr %30, align 8, !tbaa !11
  br label %84

31:                                               ; preds = %17, %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = add nsw i32 %32, %33
  %35 = ashr i32 %34, 1
  store i32 %35, ptr %13, align 4, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z9push_downi(i32 noundef %36)
  %37 = load i32, ptr %10, align 4, !tbaa !5
  %38 = load i32, ptr %13, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %40, label %49

40:                                               ; preds = %31
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = add nsw i32 %41, %42
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = load i32, ptr %13, align 4, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !5
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6modifyiiiiii(i32 noundef %43, i32 noundef %44, i32 noundef %45, i32 noundef %46, i32 noundef %47, i32 noundef %48)
  br label %49

49:                                               ; preds = %40, %31
  %50 = load i32, ptr %11, align 4, !tbaa !5
  %51 = load i32, ptr %13, align 4, !tbaa !5
  %52 = icmp sgt i32 %50, %51
  br i1 %52, label %53, label %64

53:                                               ; preds = %49
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = add nsw i32 %54, %55
  %57 = add nsw i32 %56, 1
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = load i32, ptr %10, align 4, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !5
  %63 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6modifyiiiiii(i32 noundef %57, i32 noundef %59, i32 noundef %60, i32 noundef %61, i32 noundef %62, i32 noundef %63)
  br label %64

64:                                               ; preds = %53, %49
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = add nsw i32 %65, %66
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.Segment, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = add nsw i32 %71, %72
  %74 = add nsw i32 %73, 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %75
  %77 = getelementptr inbounds %struct.Segment, ptr %76, i32 0, i32 0
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %70, ptr noundef nonnull align 4 dereferenceable(4) %77)
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %81
  %83 = getelementptr inbounds %struct.Segment, ptr %82, i32 0, i32 0
  store i32 %79, ptr %83, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %84

84:                                               ; preds = %64, %21
  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)) #3

attributes #0 = { 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 = { 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 #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" }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"_ZTS7Segment", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 0}


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

%struct.Segment = type { i32, i32 }

@seg = external dso_local global [262144 x %struct.Segment], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z9push_downi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6modifyiiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %.not = icmp sgt i32 %3, %1
  %.not35 = icmp sgt i32 %2, %4
  %or.cond = or i1 %.not, %.not35
  br i1 %or.cond, label %11, label %7

7:                                                ; preds = %6
  %8 = sext i32 %0 to i64
  %9 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %8
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  store i32 %5, ptr %10, align 4, !tbaa !5
  store i32 %5, ptr %9, align 8, !tbaa !10
  br label %30

11:                                               ; preds = %6
  %12 = add nsw i32 %2, %1
  %13 = ashr i32 %12, 1
  tail call void @_Z9push_downi(i32 noundef %0)
  %.not36 = icmp slt i32 %13, %3
  br i1 %.not36, label %16, label %14

14:                                               ; preds = %11
  %15 = shl nsw i32 %0, 1
  tail call void @_Z6modifyiiiiii(i32 noundef %15, i32 noundef %1, i32 noundef %13, i32 noundef %3, i32 noundef %4, i32 noundef %5)
  br label %16

16:                                               ; preds = %14, %11
  %17 = icmp slt i32 %13, %4
  %18 = shl nsw i32 %0, 1
  %19 = or disjoint i32 %18, 1
  br i1 %17, label %20, label %._crit_edge

20:                                               ; preds = %16
  %21 = add nsw i32 %13, 1
  tail call void @_Z6modifyiiiiii(i32 noundef %19, i32 noundef %21, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5)
  br label %._crit_edge

._crit_edge:                                      ; preds = %16, %20
  %22 = sext i32 %18 to i64
  %23 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %22
  %24 = sext i32 %19 to i64
  %25 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %24
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %23, ptr noundef nonnull align 4 dereferenceable(4) %25)
  %27 = load i32, ptr %26, align 4, !tbaa !11
  %28 = sext i32 %0 to i64
  %29 = getelementptr inbounds [262144 x %struct.Segment], ptr @seg, i64 0, i64 %28
  store i32 %27, ptr %29, align 8, !tbaa !10
  br label %30

30:                                               ; preds = %._crit_edge, %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

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, !7, i64 4}
!6 = !{!"_ZTS7Segment", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass