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

; 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._CString.dic = external hidden unnamed_addr constant [13 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 willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #2

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

11:                                               ; preds = %76, %2
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %79

16:                                               ; preds = %11
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 0
  %19 = load i8, ptr %18, align 1, !tbaa !11
  %20 = sext i8 %19 to i32
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %22, label %66

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %53, %22
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = icmp slt i32 %24, 13
  br i1 %25, label %26, label %56

26:                                               ; preds = %23
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds [13 x i32], ptr %6, i64 0, i64 0
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i32, ptr %28, i64 %30
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = call i32 @memcmp(ptr noundef %27, ptr noundef %31, i64 noundef %33) #5
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %52

36:                                               ; preds = %26
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %40, ptr align 1 %41, i64 %43, i1 false)
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %8, align 4, !tbaa !9
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sub nsw i32 %47, 1
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = sext i32 %48 to i64
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  store ptr %51, ptr %7, align 8, !tbaa !5
  br label %56

52:                                               ; preds = %26
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %9, align 4, !tbaa !9
  br label %23, !llvm.loop !12

56:                                               ; preds = %36, %23
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = icmp eq i32 %57, 13
  br i1 %58, label %59, label %65

59:                                               ; preds = %56
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %8, align 4, !tbaa !9
  %63 = sext i32 %61 to i64
  %64 = getelementptr inbounds i8, ptr %60, i64 %63
  store i8 32, ptr %64, align 1, !tbaa !11
  br label %65

65:                                               ; preds = %59, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %75

66:                                               ; preds = %16
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 0
  %69 = load i8, ptr %68, align 1, !tbaa !11
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %8, align 4, !tbaa !9
  %73 = sext i32 %71 to i64
  %74 = getelementptr inbounds i8, ptr %70, i64 %73
  store i8 %69, ptr %74, align 1, !tbaa !11
  br label %75

75:                                               ; preds = %66, %65
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i32 1
  store ptr %78, ptr %7, align 8, !tbaa !5
  br label %11, !llvm.loop !14

79:                                               ; preds = %11
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = load i32, ptr %8, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !9
  %83 = sext i32 %81 to i64
  %84 = getelementptr inbounds i8, ptr %80, i64 %83
  store i8 32, ptr %84, align 1, !tbaa !11
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load i32, ptr %8, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %8, align 4, !tbaa !9
  %88 = sext i32 %86 to i64
  %89 = getelementptr inbounds i8, ptr %85, i64 %88
  store i8 0, ptr %89, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 52, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 }
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._CString.dic = external hidden unnamed_addr constant [13 x i32], align 16

; Function Attrs: mustprogress 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) #0

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_CString(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = load i8, ptr %0, align 1, !tbaa !5
  %.not35 = icmp eq i8 %3, 0
  br i1 %.not35, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %31
  %4 = phi i8 [ %33, %31 ], [ %3, %2 ]
  %.02637 = phi i32 [ %.3, %31 ], [ 0, %2 ]
  %.02736 = phi ptr [ %32, %31 ], [ %0, %2 ]
  %5 = icmp slt i8 %4, 0
  br i1 %5, label %.preheader.preheader, label %27

.preheader.preheader:                             ; preds = %.lr.ph
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %.02736, ptr noundef nonnull dereferenceable(3) @__const._CString.dic, i64 3)
  %6 = icmp eq i32 %bcmp, 0
  br i1 %6, label %.thread, label %.preheader.1

.thread:                                          ; preds = %.preheader.12, %.preheader.11, %.preheader.10, %.preheader.9, %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %7 = sext i32 %.02637 to i64
  %8 = getelementptr inbounds i8, ptr %1, i64 %7
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(3) %8, ptr noundef nonnull align 1 dereferenceable(3) %.02736, i64 3, i1 false)
  %9 = add nsw i32 %.02637, 3
  %10 = getelementptr inbounds i8, ptr %.02736, i64 2
  br label %31

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

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

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

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

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

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

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

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

.preheader.9:                                     ; preds = %.preheader.8
  %bcmp.9 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %.02736, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const._CString.dic, i64 36), i64 3)
  %19 = icmp eq i32 %bcmp.9, 0
  br i1 %19, label %.thread, label %.preheader.10

.preheader.10:                                    ; preds = %.preheader.9
  %bcmp.10 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %.02736, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const._CString.dic, i64 40), i64 3)
  %20 = icmp eq i32 %bcmp.10, 0
  br i1 %20, label %.thread, label %.preheader.11

.preheader.11:                                    ; preds = %.preheader.10
  %bcmp.11 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %.02736, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const._CString.dic, i64 44), i64 3)
  %21 = icmp eq i32 %bcmp.11, 0
  br i1 %21, label %.thread, label %.preheader.12

.preheader.12:                                    ; preds = %.preheader.11
  %bcmp.12 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %.02736, ptr noundef nonnull dereferenceable(3) getelementptr inbounds (i8, ptr @__const._CString.dic, i64 48), i64 3)
  %22 = icmp eq i32 %bcmp.12, 0
  br i1 %22, label %.thread, label %23

23:                                               ; preds = %.preheader.12
  %24 = add nsw i32 %.02637, 1
  %25 = sext i32 %.02637 to i64
  %26 = getelementptr inbounds i8, ptr %1, i64 %25
  store i8 32, ptr %26, align 1, !tbaa !5
  br label %31

27:                                               ; preds = %.lr.ph
  %28 = add nsw i32 %.02637, 1
  %29 = sext i32 %.02637 to i64
  %30 = getelementptr inbounds i8, ptr %1, i64 %29
  store i8 %4, ptr %30, align 1, !tbaa !5
  br label %31

31:                                               ; preds = %.thread, %23, %27
  %.229 = phi ptr [ %.02736, %27 ], [ %.02736, %23 ], [ %10, %.thread ]
  %.3 = phi i32 [ %28, %27 ], [ %24, %23 ], [ %9, %.thread ]
  %32 = getelementptr inbounds i8, ptr %.229, i64 1
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %.not = icmp eq i8 %33, 0
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !8

._crit_edge.loopexit:                             ; preds = %31
  %34 = sext i32 %.3 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %.026.lcssa = phi i64 [ 0, %2 ], [ %34, %._crit_edge.loopexit ]
  %35 = getelementptr inbounds i8, ptr %1, i64 %.026.lcssa
  store i8 32, ptr %35, align 1, !tbaa !5
  %36 = getelementptr i8, ptr %35, i64 1
  store i8 0, ptr %36, align 1, !tbaa !5
  ret void
}

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind memory(readwrite, inaccessiblemem: none) 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 = { nofree nounwind willreturn memory(argmem: 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 = !{!"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,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass