; LLVM IR from lzyrapx/Competitive-Programming :: LibreOJ (6086（数学题）)

; 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
@l = external dso_local global [5000010 x i64], align 16
@j = external dso_local global [5000010 x i64], align 16
@k = external dso_local global [5000010 x i64], align 16
@x = external dso_local global [5000010 x i64], align 16
@y = external dso_local global [5000010 x i64], align 16
@z = external dso_local global [5000010 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 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 i64, align 8
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %58, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = icmp sle i32 %7, %8
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %61

11:                                               ; preds = %6
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [5000010 x i64], ptr @l, i64 0, i64 %13
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [5000010 x i64], ptr @j, i64 0, i64 %16
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [5000010 x i64], ptr @k, i64 0, i64 %19
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %14, ptr noundef %17, ptr noundef %20)
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [5000010 x i64], ptr @l, i64 0, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [5000010 x i64], ptr @j, i64 0, i64 %27
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = sub nsw i64 %25, %29
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [5000010 x i64], ptr @x, i64 0, i64 %32
  store i64 %30, ptr %33, align 8, !tbaa !9
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [5000010 x i64], ptr @j, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [5000010 x i64], ptr @k, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = sub nsw i64 %37, %41
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [5000010 x i64], ptr @y, i64 0, i64 %44
  store i64 %42, ptr %45, align 8, !tbaa !9
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [5000010 x i64], ptr @k, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [5000010 x i64], ptr @l, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = sub nsw i64 %49, %53
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [5000010 x i64], ptr @z, i64 0, i64 %56
  store i64 %54, ptr %57, align 8, !tbaa !9
  br label %58

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

61:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds i64, ptr @x, i64 %63
  %65 = getelementptr inbounds i64, ptr %64, i64 1
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef getelementptr inbounds (i64, ptr @x, i64 1), ptr noundef %65)
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds i64, ptr @y, i64 %67
  %69 = getelementptr inbounds i64, ptr %68, i64 1
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef getelementptr inbounds (i64, ptr @y, i64 1), ptr noundef %69)
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i64, ptr @z, i64 %71
  %73 = getelementptr inbounds i64, ptr %72, i64 1
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef getelementptr inbounds (i64, ptr @z, i64 1), ptr noundef %73)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %105, %61
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = load i32, ptr @n, align 4, !tbaa !5
  %77 = icmp sle i32 %75, %76
  br i1 %77, label %79, label %78

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

79:                                               ; preds = %74
  %80 = load i64, ptr %3, align 8, !tbaa !9
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = mul nsw i32 2, %81
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = sub nsw i32 %82, %83
  %85 = sub nsw i32 %84, 1
  %86 = sext i32 %85 to i64
  %87 = mul nsw i64 1, %86
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [5000010 x i64], ptr @x, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !9
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [5000010 x i64], ptr @y, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !9
  %96 = add nsw i64 %91, %95
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [5000010 x i64], ptr @z, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !9
  %101 = add nsw i64 %96, %100
  %102 = mul nsw i64 %87, %101
  %103 = add nsw i64 %80, %102
  %104 = srem i64 %103, 1000000007
  store i64 %104, ptr %3, align 8, !tbaa !9
  br label %105

105:                                              ; preds = %79
  %106 = load i32, ptr %4, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %4, align 4, !tbaa !5
  br label %74, !llvm.loop !13

108:                                              ; preds = %78
  %109 = load i64, ptr %3, align 8, !tbaa !9
  %110 = mul nsw i64 %109, 500000004
  %111 = srem i64 %110, 1000000007
  %112 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %111)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) #3

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 = { inlinehint 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 #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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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
@l = external dso_local global [5000010 x i64], align 16
@j = external dso_local global [5000010 x i64], align 16
@k = external dso_local global [5000010 x i64], align 16
@x = external dso_local global [5000010 x i64], align 16
@y = external dso_local global [5000010 x i64], align 16
@z = external dso_local global [5000010 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse 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)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %.not27 = icmp slt i32 %2, 1
  br i1 %.not27, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = sext i32 %2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %31, %.lr.ph ]
  %3 = getelementptr inbounds i64, ptr @x, i64 %.pre-phi
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @x, i64 8), ptr noundef nonnull %4)
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds i64, ptr @y, i64 %6
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @y, i64 8), ptr noundef nonnull %8)
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i64, ptr @z, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @z, i64 8), ptr noundef nonnull %12)
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %.not2629 = icmp slt i32 %13, 1
  br i1 %.not2629, label %._crit_edge34, label %.lr.ph33

.lr.ph33:                                         ; preds = %._crit_edge
  %14 = xor i32 %13, -1
  %15 = sext i32 %14 to i64
  %16 = add nuw i32 %13, 1
  %wide.trip.count = zext i32 %16 to i64
  br label %35

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %17 = getelementptr inbounds [5000010 x i64], ptr @l, i64 0, i64 %indvars.iv
  %18 = getelementptr inbounds [5000010 x i64], ptr @j, i64 0, i64 %indvars.iv
  %19 = getelementptr inbounds [5000010 x i64], ptr @k, i64 0, i64 %indvars.iv
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %17, ptr noundef nonnull %18, ptr noundef nonnull %19)
  %21 = load i64, ptr %17, align 8, !tbaa !9
  %22 = load i64, ptr %18, align 8, !tbaa !9
  %23 = sub nsw i64 %21, %22
  %24 = getelementptr inbounds [5000010 x i64], ptr @x, i64 0, i64 %indvars.iv
  store i64 %23, ptr %24, align 8, !tbaa !9
  %25 = load i64, ptr %19, align 8, !tbaa !9
  %26 = sub nsw i64 %22, %25
  %27 = getelementptr inbounds [5000010 x i64], ptr @y, i64 0, i64 %indvars.iv
  store i64 %26, ptr %27, align 8, !tbaa !9
  %28 = sub nsw i64 %25, %21
  %29 = getelementptr inbounds [5000010 x i64], ptr @z, i64 0, i64 %indvars.iv
  store i64 %28, ptr %29, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %.not.not = icmp slt i64 %indvars.iv, %31
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge34.loopexit:                           ; preds = %35
  %32 = mul nsw i64 %48, 500000004
  %33 = srem i64 %32, 1000000007
  br label %._crit_edge34

._crit_edge34:                                    ; preds = %._crit_edge34.loopexit, %._crit_edge
  %.022.lcssa = phi i64 [ 0, %._crit_edge ], [ %33, %._crit_edge34.loopexit ]
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.022.lcssa)
  ret i32 0

35:                                               ; preds = %.lr.ph33, %35
  %indvars.iv39 = phi i64 [ 1, %.lr.ph33 ], [ %indvars.iv.next40, %35 ]
  %.02230 = phi i64 [ 0, %.lr.ph33 ], [ %48, %35 ]
  %36 = shl nuw nsw i64 %indvars.iv39, 1
  %37 = add nsw i64 %36, %15
  %38 = getelementptr inbounds [5000010 x i64], ptr @x, i64 0, i64 %indvars.iv39
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds [5000010 x i64], ptr @y, i64 0, i64 %indvars.iv39
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = add nsw i64 %41, %39
  %43 = getelementptr inbounds [5000010 x i64], ptr @z, i64 0, i64 %indvars.iv39
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = add nsw i64 %42, %44
  %46 = mul nsw i64 %45, %37
  %47 = add nsw i64 %46, %.02230
  %48 = srem i64 %47, 1000000007
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge34.loopexit, label %35, !llvm.loop !13
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 = { inlinehint 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" }

!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"}
!13 = distinct !{!13, !12}


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