; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (5724)

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

@f = external dso_local global [1050000 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr @f, align 16, !tbaa !5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %19, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = icmp sle i32 %11, 1048576
  br i1 %12, label %13, label %22

13:                                               ; preds = %10
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = call noundef i32 @_Z3geti(i32 noundef %14)
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [1050000 x i32], ptr @f, i64 0, i64 %17
  store i32 %15, ptr %18, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %13
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !9

22:                                               ; preds = %10
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %7)
  br label %24

24:                                               ; preds = %67, %22
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr %7, align 4, !tbaa !5
  %27 = icmp ne i32 %25, 0
  br i1 %27, label %28, label %68

28:                                               ; preds = %24
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  store i32 0, ptr %9, align 4, !tbaa !5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %57, %28
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %34, label %60

34:                                               ; preds = %30
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %4)
  store i32 0, ptr %8, align 4, !tbaa !5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %36

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

40:                                               ; preds = %36
  %41 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sub nsw i32 20, %42
  %44 = shl i32 1, %43
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %47

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

50:                                               ; preds = %36
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1050000 x i32], ptr @f, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = xor i32 %55, %54
  store i32 %56, ptr %9, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %50
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %2, align 4, !tbaa !5
  br label %30, !llvm.loop !12

60:                                               ; preds = %30
  %61 = load i32, ptr %9, align 4, !tbaa !5
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %60
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %67

65:                                               ; preds = %60
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %67

67:                                               ; preds = %65, %63
  br label %24, !llvm.loop !13

68:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

declare i32 @printf(ptr noundef, ...) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

@f = external dso_local local_unnamed_addr global [1050000 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 0, ptr @f, align 16, !tbaa !5
  br label %5

5:                                                ; preds = %0, %5
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %5 ]
  %6 = trunc nuw nsw i64 %indvars.iv to i32
  %7 = tail call noundef i32 @_Z3geti(i32 noundef %6)
  %8 = getelementptr inbounds [1050000 x i32], ptr @f, i64 0, i64 %indvars.iv
  store i32 %7, ptr %8, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1048577
  br i1 %exitcond.not, label %9, label %5, !llvm.loop !9

9:                                                ; preds = %5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %4)
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr %4, align 4, !tbaa !5
  %.not29 = icmp eq i32 %11, 0
  br i1 %.not29, label %._crit_edge32, label %.lr.ph31

.lr.ph31:                                         ; preds = %9, %30
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %.not1522 = icmp slt i32 %14, 1
  br i1 %.not1522, label %._crit_edge27.thread, label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph31, %._crit_edge
  %.024 = phi i32 [ %27, %._crit_edge ], [ 0, %.lr.ph31 ]
  %.123 = phi i32 [ %28, %._crit_edge ], [ 1, %.lr.ph31 ]
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %.not1719 = icmp slt i32 %16, 1
  br i1 %.not1719, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph26, %.lr.ph
  %.01221 = phi i32 [ %21, %.lr.ph ], [ 0, %.lr.ph26 ]
  %.01320 = phi i32 [ %22, %.lr.ph ], [ 1, %.lr.ph26 ]
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2)
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sub nsw i32 20, %18
  %20 = shl nuw i32 1, %19
  %21 = add nsw i32 %20, %.01221
  %22 = add nuw nsw i32 %.01320, 1
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %.not17.not = icmp slt i32 %.01320, %23
  br i1 %.not17.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph26
  %.012.lcssa = phi i32 [ 0, %.lr.ph26 ], [ %21, %.lr.ph ]
  %24 = sext i32 %.012.lcssa to i64
  %25 = getelementptr inbounds [1050000 x i32], ptr @f, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = xor i32 %26, %.024
  %28 = add nuw nsw i32 %.123, 1
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %.not15.not = icmp slt i32 %.123, %29
  br i1 %.not15.not, label %.lr.ph26, label %._crit_edge27, !llvm.loop !12

._crit_edge27:                                    ; preds = %._crit_edge
  %.not16 = icmp eq i32 %26, %.024
  br i1 %.not16, label %._crit_edge27.thread, label %30

._crit_edge27.thread:                             ; preds = %.lr.ph31, %._crit_edge27
  br label %30

30:                                               ; preds = %._crit_edge27, %._crit_edge27.thread
  %.str.2.sink = phi ptr [ @.str.2, %._crit_edge27.thread ], [ @.str.1, %._crit_edge27 ]
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %32, 0
  br i1 %.not, label %._crit_edge32, label %.lr.ph31, !llvm.loop !13

._crit_edge32:                                    ; preds = %30, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #3 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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