; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_time)

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

@__const.CHNNum.dic = external hidden unnamed_addr constant [11 x i32], 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @CHNNum(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca [11 x i32], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 3, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 44, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.CHNNum.dic, i64 44, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %81, %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i8, ptr %10, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !11
  %15 = sext i8 %14 to i32
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %85

18:                                               ; preds = %9
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  %23 = getelementptr inbounds [11 x i32], ptr %4, i64 0, i64 0
  %24 = getelementptr inbounds i32, ptr %23, i64 10
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call i32 @memcmp(ptr noundef %22, ptr noundef %24, i64 noundef %26) #5
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %36

29:                                               ; preds = %18
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %32, %29
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = mul nsw i32 %34, 10
  store i32 %35, ptr %5, align 4, !tbaa !9
  br label %81

36:                                               ; preds = %18
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  %41 = getelementptr inbounds [11 x i32], ptr %4, i64 0, i64 0
  %42 = getelementptr inbounds i32, ptr %41, i64 0
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = call i32 @memcmp(ptr noundef %40, ptr noundef %42, i64 noundef %44) #5
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %36
  br label %81

48:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %70, %48
  %50 = load i32, ptr %8, align 4, !tbaa !9
  %51 = icmp slt i32 %50, 10
  br i1 %51, label %52, label %73

52:                                               ; preds = %49
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %53, i64 %55
  %57 = getelementptr inbounds [11 x i32], ptr %4, i64 0, i64 0
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %57, i64 %59
  %61 = load i32, ptr %3, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = call i32 @memcmp(ptr noundef %56, ptr noundef %60, i64 noundef %62) #5
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %69

65:                                               ; preds = %52
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = load i32, ptr %5, align 4, !tbaa !9
  %68 = add nsw i32 %67, %66
  store i32 %68, ptr %5, align 4, !tbaa !9
  br label %73

69:                                               ; preds = %52
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %8, align 4, !tbaa !9
  br label %49, !llvm.loop !12

73:                                               ; preds = %65, %49
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = icmp eq i32 %74, 10
  br i1 %75, label %76, label %77

76:                                               ; preds = %73
  store i32 2, ptr %7, align 4
  br label %78

77:                                               ; preds = %73
  store i32 0, ptr %7, align 4
  br label %78

78:                                               ; preds = %77, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %79 = load i32, ptr %7, align 4
  switch i32 %79, label %85 [
    i32 0, label %80
  ]

80:                                               ; preds = %78
  br label %81

81:                                               ; preds = %80, %47, %33
  %82 = load i32, ptr %3, align 4, !tbaa !9
  %83 = load i32, ptr %6, align 4, !tbaa !9
  %84 = add nsw i32 %83, %82
  store i32 %84, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !14

85:                                               ; preds = %78, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %5, align 4, !tbaa !9
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 44, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %87
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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

@__const.CHNNum.dic = external hidden unnamed_addr constant [11 x i32], align 16

; Function Attrs: nofree nounwind memory(argmem: read) uwtable
define dso_local i32 @CHNNum(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %.not32 = icmp eq i8 %2, 0
  br i1 %.not32, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %19
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ 0, %1 ]
  %.02433 = phi i32 [ %.2, %19 ], [ 0, %1 ]
  %3 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 40), i64 3)
  %4 = icmp eq i32 %bcmp, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %.lr.ph
  %spec.store.select = tail call i32 @llvm.umax.i32(i32 %.02433, i32 1)
  %6 = mul nsw i32 %spec.store.select, 10
  br label %19

7:                                                ; preds = %.lr.ph
  %bcmp25 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) @__const.CHNNum.dic, i64 3)
  %8 = icmp eq i32 %bcmp25, 0
  br i1 %8, label %19, label %.preheader.preheader

.preheader.preheader:                             ; preds = %7
  %bcmp26 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 4), i64 3)
  %9 = icmp eq i32 %bcmp26, 0
  br i1 %9, label %.thread, label %.preheader.1

.thread:                                          ; preds = %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.031.lcssa.wide = phi i32 [ 1, %.preheader.preheader ], [ 2, %.preheader.1 ], [ 3, %.preheader.2 ], [ 4, %.preheader.3 ], [ 5, %.preheader.4 ], [ 6, %.preheader.5 ], [ 7, %.preheader.6 ], [ 8, %.preheader.7 ], [ 9, %.preheader.8 ]
  %10 = add nsw i32 %.031.lcssa.wide, %.02433
  br label %19

.preheader.1:                                     ; preds = %.preheader.preheader
  %bcmp26.1 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 8), i64 3)
  %11 = icmp eq i32 %bcmp26.1, 0
  br i1 %11, label %.thread, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %bcmp26.2 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 12), i64 3)
  %12 = icmp eq i32 %bcmp26.2, 0
  br i1 %12, label %.thread, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %bcmp26.3 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 16), i64 3)
  %13 = icmp eq i32 %bcmp26.3, 0
  br i1 %13, label %.thread, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %bcmp26.4 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 20), i64 3)
  %14 = icmp eq i32 %bcmp26.4, 0
  br i1 %14, label %.thread, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %bcmp26.5 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 24), i64 3)
  %15 = icmp eq i32 %bcmp26.5, 0
  br i1 %15, label %.thread, label %.preheader.6

.preheader.6:                                     ; preds = %.preheader.5
  %bcmp26.6 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 28), i64 3)
  %16 = icmp eq i32 %bcmp26.6, 0
  br i1 %16, label %.thread, label %.preheader.7

.preheader.7:                                     ; preds = %.preheader.6
  %bcmp26.7 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 32), i64 3)
  %17 = icmp eq i32 %bcmp26.7, 0
  br i1 %17, label %.thread, label %.preheader.8

.preheader.8:                                     ; preds = %.preheader.7
  %bcmp26.8 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %3, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const.CHNNum.dic, i64 36), i64 3)
  %18 = icmp eq i32 %bcmp26.8, 0
  br i1 %18, label %.thread, label %._crit_edge

19:                                               ; preds = %.thread, %7, %5
  %.2 = phi i32 [ %6, %5 ], [ %.02433, %7 ], [ %10, %.thread ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 3
  %20 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %.not = icmp eq i8 %21, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %19, %.preheader.8, %1
  %.024.lcssa = phi i32 [ 0, %1 ], [ %.02433, %.preheader.8 ], [ %.2, %19 ]
  ret i32 %.024.lcssa
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #2

attributes #0 = { nofree nounwind memory(argmem: read) 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 willreturn memory(argmem: read) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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