; LLVM IR from jingweizhanghuai/Morn :: test (test_log)

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

@author = external dso_local global ptr, align 8
@morn_log_levelset = external global i32, align 4
@morn_log_level = external thread_local global i32, align 4
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [71 x i8], align 1
@__FUNCTION__.test2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

declare void @m_Log(i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @test2() #2 {
  br label %1

1:                                                ; preds = %0
  %2 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %3 = icmp sge i32 32, %2
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %5, align 4, !tbaa !5
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.1, i32 noundef 1)
  br label %6

6:                                                ; preds = %4, %1
  br label %7

7:                                                ; preds = %6
  br label %8

8:                                                ; preds = %7
  %9 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %10 = icmp sge i32 32, %9
  br i1 %10, label %11, label %14

11:                                               ; preds = %8
  %12 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %12, align 4, !tbaa !5
  %13 = call ptr (...) @mLogLevel()
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.2, ptr noundef @.str.3, i32 noundef 23, ptr noundef @__FUNCTION__.test2, ptr noundef %13, i32 noundef 1)
  br label %14

14:                                               ; preds = %11, %8
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  %17 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %18 = icmp sge i32 32, %17
  br i1 %18, label %19, label %23

19:                                               ; preds = %16
  %20 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %20, align 4, !tbaa !5
  %21 = call ptr (...) @mTimeNowString()
  %22 = call ptr (...) @mLogLevel()
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.4, ptr noundef %21, ptr noundef %22, i32 noundef 2)
  br label %23

23:                                               ; preds = %19, %16
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %27 = icmp sge i32 32, %26
  br i1 %27, label %28, label %32

28:                                               ; preds = %25
  %29 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %29, align 4, !tbaa !5
  %30 = call i32 (...) @mThreadID()
  %31 = call ptr (...) @mLogLevel()
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.5, i32 noundef %30, ptr noundef %31, i32 noundef 3)
  br label %32

32:                                               ; preds = %28, %25
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %36 = icmp sge i32 32, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %38, align 4, !tbaa !5
  %39 = call ptr (...) @mTimeNowString()
  %40 = call i32 (...) @mThreadID()
  %41 = call ptr (...) @mLogLevel()
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.6, ptr noundef %39, i32 noundef %40, ptr noundef %41, i32 noundef 4)
  br label %42

42:                                               ; preds = %37, %34
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %46 = icmp sge i32 32, %45
  br i1 %46, label %47, label %52

47:                                               ; preds = %44
  %48 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %48, align 4, !tbaa !5
  %49 = call ptr (...) @mTimeNowString()
  %50 = call i32 (...) @mThreadID()
  %51 = call ptr (...) @mLogLevel()
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.7, ptr noundef %49, i32 noundef %50, ptr noundef @.str.3, i32 noundef 27, ptr noundef @__FUNCTION__.test2, ptr noundef %51, i32 noundef 5)
  br label %52

52:                                               ; preds = %47, %44
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %56 = icmp sge i32 32, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %54
  %58 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %58, align 4, !tbaa !5
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.8, ptr noundef @.str.3, i32 noundef 28, ptr noundef @__FUNCTION__.test2, i32 noundef 6)
  br label %59

59:                                               ; preds = %57, %54
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %63 = icmp sge i32 32, %62
  br i1 %63, label %64, label %68

64:                                               ; preds = %61
  %65 = call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %65, align 4, !tbaa !5
  %66 = call ptr (...) @mTimeNowString()
  %67 = load ptr, ptr @author, align 8, !tbaa !9
  call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef @.str.9, ptr noundef %66, ptr noundef %67, i32 noundef 7)
  br label %68

68:                                               ; preds = %64, %61
  br label %69

69:                                               ; preds = %68
  ret void
}

declare ptr @mLogLevel(...) #1

declare ptr @mTimeNowString(...) #1

declare i32 @mThreadID(...) #1

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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

@author = external dso_local local_unnamed_addr global ptr, align 8
@morn_log_levelset = external local_unnamed_addr global i32, align 4
@morn_log_level = external thread_local local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [71 x i8], align 1
@__FUNCTION__.test2 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #0

declare void @m_Log(i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test2() local_unnamed_addr #2 {
  %1 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %2 = icmp slt i32 %1, 33
  br i1 %2, label %3, label %.thread16

3:                                                ; preds = %0
  %4 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @morn_log_level)
  store i32 32, ptr %4, align 4, !tbaa !5
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.1, i32 noundef 1) #3
  %.pr = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %5 = icmp slt i32 %.pr, 33
  br i1 %5, label %6, label %.thread16

6:                                                ; preds = %3
  store i32 32, ptr %4, align 4, !tbaa !5
  %7 = tail call ptr (...) @mLogLevel() #3
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, i32 noundef 23, ptr noundef nonnull @__FUNCTION__.test2, ptr noundef %7, i32 noundef 1) #3
  %.pr1 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %8 = icmp slt i32 %.pr1, 33
  br i1 %8, label %.thread2, label %.thread16

.thread2:                                         ; preds = %6
  store i32 32, ptr %4, align 4, !tbaa !5
  %9 = tail call ptr (...) @mTimeNowString() #3
  %10 = tail call ptr (...) @mLogLevel() #3
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.4, ptr noundef %9, ptr noundef %10, i32 noundef 2) #3
  %.pr3.pr = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %11 = icmp slt i32 %.pr3.pr, 33
  br i1 %11, label %12, label %.thread16

12:                                               ; preds = %.thread2
  store i32 32, ptr %4, align 4, !tbaa !5
  %13 = tail call i32 (...) @mThreadID() #3
  %14 = tail call ptr (...) @mLogLevel() #3
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.5, i32 noundef %13, ptr noundef %14, i32 noundef 3) #3
  %.pr5 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %15 = icmp slt i32 %.pr5, 33
  br i1 %15, label %.thread7, label %.thread16

.thread7:                                         ; preds = %12
  store i32 32, ptr %4, align 4, !tbaa !5
  %16 = tail call ptr (...) @mTimeNowString() #3
  %17 = tail call i32 (...) @mThreadID() #3
  %18 = tail call ptr (...) @mLogLevel() #3
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.6, ptr noundef %16, i32 noundef %17, ptr noundef %18, i32 noundef 4) #3
  %.pr9.pr.pr = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %19 = icmp slt i32 %.pr9.pr.pr, 33
  br i1 %19, label %20, label %.thread16

20:                                               ; preds = %.thread7
  store i32 32, ptr %4, align 4, !tbaa !5
  %21 = tail call ptr (...) @mTimeNowString() #3
  %22 = tail call i32 (...) @mThreadID() #3
  %23 = tail call ptr (...) @mLogLevel() #3
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.7, ptr noundef %21, i32 noundef %22, ptr noundef nonnull @.str.3, i32 noundef 27, ptr noundef nonnull @__FUNCTION__.test2, ptr noundef %23, i32 noundef 5) #3
  %.pr11 = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %24 = icmp slt i32 %.pr11, 33
  br i1 %24, label %.thread13, label %.thread16

.thread13:                                        ; preds = %20
  store i32 32, ptr %4, align 4, !tbaa !5
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.3, i32 noundef 28, ptr noundef nonnull @__FUNCTION__.test2, i32 noundef 6) #3
  %.pr15.pr.pr = load i32, ptr @morn_log_levelset, align 4, !tbaa !5
  %25 = icmp slt i32 %.pr15.pr.pr, 33
  br i1 %25, label %26, label %.thread16

26:                                               ; preds = %.thread13
  store i32 32, ptr %4, align 4, !tbaa !5
  %27 = tail call ptr (...) @mTimeNowString() #3
  %28 = load ptr, ptr @author, align 8, !tbaa !9
  tail call void (i32, ptr, ...) @m_Log(i32 noundef 32, ptr noundef nonnull @.str.9, ptr noundef %27, ptr noundef %28, i32 noundef 7) #3
  br label %.thread16

.thread16:                                        ; preds = %6, %.thread2, %0, %3, %.thread7, %12, %20, %.thread13, %26
  ret void
}

declare ptr @mLogLevel(...) local_unnamed_addr #1

declare ptr @mTimeNowString(...) local_unnamed_addr #1

declare i32 @mThreadID(...) local_unnamed_addr #1

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SimplifyCFGPass,TailCallElimPass