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

; 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.node = type { [10 x i8], i32, i32 }

@p = external dso_local global [11 x %struct.node], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmp4nodeS_(ptr noundef byval(%struct.node) align 8, ptr noundef byval(%struct.node) align 8) #0

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

9:                                                ; preds = %97, %0
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  %11 = xor i32 %10, -1
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %98

14:                                               ; preds = %9
  %15 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %19

19:                                               ; preds = %17, %14
  store i8 1, ptr %2, align 1, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %39, %19
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %42

24:                                               ; preds = %20
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.node, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds [10 x i8], ptr %28, i64 0, i64 0
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.node, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.node, ptr %36, i32 0, i32 2
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %29, ptr noundef %33, ptr noundef %37)
  br label %39

39:                                               ; preds = %24
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %3, align 4, !tbaa !9
  br label %20, !llvm.loop !13

42:                                               ; preds = %20
  store i32 1, ptr %7, align 4, !tbaa !9
  store i32 1, ptr %8, align 4, !tbaa !9
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.node, ptr @p, i64 %44
  call void @_ZSt4sortIP4nodePFbS0_S0_EEvT_S4_T0_(ptr noundef @p, ptr noundef %45, ptr noundef @_Z3cmp4nodeS_)
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %6, align 4, !tbaa !9
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %46)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %94, %42
  %50 = load i32, ptr %3, align 4, !tbaa !9
  %51 = load i32, ptr %5, align 4, !tbaa !9
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %53, label %97

53:                                               ; preds = %49
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %84

56:                                               ; preds = %53
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.node, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !15
  %62 = load i32, ptr %3, align 4, !tbaa !9
  %63 = sub nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %64
  %66 = getelementptr inbounds %struct.node, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %66, align 4, !tbaa !15
  %68 = icmp ne i32 %61, %67
  br i1 %68, label %82, label %69

69:                                               ; preds = %56
  %70 = load i32, ptr %3, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.node, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 4, !tbaa !17
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = sub nsw i32 %75, 1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.node, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 4, !tbaa !17
  %81 = icmp ne i32 %74, %80
  br i1 %81, label %82, label %84

82:                                               ; preds = %69, %56
  %83 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %83, ptr %7, align 4, !tbaa !9
  br label %84

84:                                               ; preds = %82, %69, %53
  %85 = load i32, ptr %3, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %86
  %88 = getelementptr inbounds %struct.node, ptr %87, i32 0, i32 0
  %89 = getelementptr inbounds [10 x i8], ptr %88, i64 0, i64 0
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %89, i32 noundef %90)
  %92 = load i32, ptr %8, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %8, align 4, !tbaa !9
  br label %94

94:                                               ; preds = %84
  %95 = load i32, ptr %3, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %3, align 4, !tbaa !9
  br label %49, !llvm.loop !18

97:                                               ; preds = %49
  br label %9, !llvm.loop !19

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

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

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

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

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

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

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 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 12}
!16 = !{!"_ZTS4node", !7, i64 0, !10, i64 12, !10, i64 16}
!17 = !{!16, !10, i64 16}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


; 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.node = type { [10 x i8], i32, i32 }

@p = external dso_local global [11 x %struct.node], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmp4nodeS_(ptr noundef byval(%struct.node) align 8, ptr noundef byval(%struct.node) align 8) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %.not33 = icmp eq i32 %3, 0
  br i1 %.not33, label %._crit_edge38, label %.lr.ph37

.loopexit:                                        ; preds = %40, %.lr.ph32.preheader, %._crit_edge
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge38, label %.lr.ph37, !llvm.loop !9

.lr.ph37:                                         ; preds = %0, %.loopexit
  %6 = phi i32 [ %5, %.loopexit ], [ %3, %0 ]
  %.01935 = phi i32 [ %20, %.loopexit ], [ 1, %0 ]
  %.02034 = phi i1 [ true, %.loopexit ], [ false, %0 ]
  br i1 %.02034, label %7, label %9

7:                                                ; preds = %.lr.ph37
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %7, %.lr.ph37
  %10 = phi i32 [ %.pre, %7 ], [ %6, %.lr.ph37 ]
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %9
  %.pre46 = sext i32 %10 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %9, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %9 ]
  %12 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %indvars.iv
  %13 = getelementptr inbounds i8, ptr %12, i64 12
  %14 = getelementptr inbounds i8, ptr %12, i64 16
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %14)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre46, %.._crit_edge_crit_edge ], [ %17, %.lr.ph ]
  %19 = getelementptr inbounds %struct.node, ptr @p, i64 %.pre-phi
  call void @_ZSt4sortIP4nodePFbS0_S0_EEvT_S4_T0_(ptr noundef nonnull @p, ptr noundef nonnull %19, ptr noundef nonnull @_Z3cmp4nodeS_)
  %20 = add nuw nsw i32 %.01935, 1
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.01935)
  %22 = load i32, ptr %1, align 4, !tbaa !5
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph32.preheader, label %.loopexit

.lr.ph32.preheader:                               ; preds = %._crit_edge
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull @p, i32 noundef 1)
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 1
  br i1 %26, label %.lr.ph32.peel.next, label %.loopexit

.lr.ph32.peel.next:                               ; preds = %.lr.ph32.preheader, %40
  %indvars.iv41 = phi i64 [ %indvars.iv.next42, %40 ], [ 1, %.lr.ph32.preheader ]
  %.030 = phi i32 [ %43, %40 ], [ 2, %.lr.ph32.preheader ]
  %.01829 = phi i32 [ %.1, %40 ], [ 1, %.lr.ph32.preheader ]
  %27 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %indvars.iv41
  %28 = getelementptr inbounds i8, ptr %27, i64 12
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %30 = add nsw i64 %indvars.iv41, -1
  %31 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %30
  %32 = getelementptr inbounds i8, ptr %31, i64 12
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %.not25 = icmp eq i32 %29, %33
  br i1 %.not25, label %34, label %39

34:                                               ; preds = %.lr.ph32.peel.next
  %35 = getelementptr inbounds i8, ptr %27, i64 16
  %36 = load i32, ptr %35, align 4, !tbaa !14
  %37 = getelementptr inbounds i8, ptr %31, i64 16
  %38 = load i32, ptr %37, align 4, !tbaa !14
  %.not26 = icmp eq i32 %36, %38
  br i1 %.not26, label %40, label %39

39:                                               ; preds = %34, %.lr.ph32.peel.next
  br label %40

40:                                               ; preds = %39, %34
  %.1 = phi i32 [ %.030, %39 ], [ %.01829, %34 ]
  %41 = getelementptr inbounds [11 x %struct.node], ptr @p, i64 0, i64 %indvars.iv41
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %41, i32 noundef %.1)
  %43 = add nuw nsw i32 %.030, 1
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %44 = load i32, ptr %1, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = icmp slt i64 %indvars.iv.next42, %45
  br i1 %46, label %.lr.ph32.peel.next, label %.loopexit, !llvm.loop !15

._crit_edge38:                                    ; preds = %.loopexit, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

; 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

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

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

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 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { 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 = !{!13, !6, i64 12}
!13 = !{!"_ZTS4node", !7, i64 0, !6, i64 12, !6, i64 16}
!14 = !{!13, !6, i64 16}
!15 = distinct !{!15, !10, !16}
!16 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass