; LLVM IR from jingweizhanghuai/Morn :: example (thread3)

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

; Function Attrs: nounwind uwtable
declare dso_local void @test1(ptr 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: nounwind uwtable
declare dso_local void @test2(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %5 = call ptr @m_Malloc(i32 noundef 26)
  store ptr %5, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %6 = call ptr @m_Malloc(i32 noundef 26)
  store ptr %6, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %26, %0
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 26
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %29

11:                                               ; preds = %7
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = add nsw i32 65, %12
  %14 = trunc i32 %13 to i8
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds i8, ptr %15, i64 %17
  store i8 %14, ptr %18, align 1, !tbaa !11
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = add nsw i32 97, %19
  %21 = trunc i32 %20 to i8
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  store i8 %21, ptr %25, align 1, !tbaa !11
  br label %26

26:                                               ; preds = %11
  %27 = load i32, ptr %4, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %4, align 4, !tbaa !9
  br label %7, !llvm.loop !12

29:                                               ; preds = %10
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_Thread(ptr noundef @test1, ptr noundef %30, ptr noundef inttoptr (i64 -1 to ptr))
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  call void @m_Thread(ptr noundef @test2, ptr noundef %31, ptr noundef inttoptr (i64 -1 to ptr))
  call void (...) @mThreadJoin()
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_Free(ptr noundef %32)
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  call void @m_Free(ptr noundef %33)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

declare ptr @m_Malloc(i32 noundef) #2

declare void @m_Thread(ptr noundef, ptr noundef, ptr noundef) #2

declare void @mThreadJoin(...) #2

declare void @m_Free(ptr noundef) #2

attributes #0 = { 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 = { "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 = !{!"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"}


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

; Function Attrs: nounwind uwtable
declare dso_local void @test1(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @test2(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @m_Malloc(i32 noundef 26) #2
  %2 = tail call ptr @m_Malloc(i32 noundef 26) #2
  store i8 65, ptr %1, align 1, !tbaa !5
  store i8 97, ptr %2, align 1, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 66, ptr %3, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 1
  store i8 98, ptr %4, align 1, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 67, ptr %5, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 2
  store i8 99, ptr %6, align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 68, ptr %7, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 3
  store i8 100, ptr %8, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 69, ptr %9, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 4
  store i8 101, ptr %10, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 70, ptr %11, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %2, i64 5
  store i8 102, ptr %12, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 71, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %2, i64 6
  store i8 103, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 72, ptr %15, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %2, i64 7
  store i8 104, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 73, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %2, i64 8
  store i8 105, ptr %18, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 74, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %2, i64 9
  store i8 106, ptr %20, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 75, ptr %21, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %2, i64 10
  store i8 107, ptr %22, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 76, ptr %23, align 1, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %2, i64 11
  store i8 108, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 77, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %2, i64 12
  store i8 109, ptr %26, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 78, ptr %27, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %2, i64 13
  store i8 110, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 79, ptr %29, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %2, i64 14
  store i8 111, ptr %30, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 80, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %2, i64 15
  store i8 112, ptr %32, align 1, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %1, i64 16
  store i8 81, ptr %33, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %2, i64 16
  store i8 113, ptr %34, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %1, i64 17
  store i8 82, ptr %35, align 1, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %2, i64 17
  store i8 114, ptr %36, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 18
  store i8 83, ptr %37, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %2, i64 18
  store i8 115, ptr %38, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %1, i64 19
  store i8 84, ptr %39, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %2, i64 19
  store i8 116, ptr %40, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %1, i64 20
  store i8 85, ptr %41, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %2, i64 20
  store i8 117, ptr %42, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 21
  store i8 86, ptr %43, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %2, i64 21
  store i8 118, ptr %44, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %1, i64 22
  store i8 87, ptr %45, align 1, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %2, i64 22
  store i8 119, ptr %46, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %1, i64 23
  store i8 88, ptr %47, align 1, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %2, i64 23
  store i8 120, ptr %48, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %1, i64 24
  store i8 89, ptr %49, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %2, i64 24
  store i8 121, ptr %50, align 1, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %1, i64 25
  store i8 90, ptr %51, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %2, i64 25
  store i8 122, ptr %52, align 1, !tbaa !5
  tail call void @m_Thread(ptr noundef nonnull @test1, ptr noundef nonnull %1, ptr noundef nonnull inttoptr (i64 -1 to ptr)) #2
  tail call void @m_Thread(ptr noundef nonnull @test2, ptr noundef nonnull %2, ptr noundef nonnull inttoptr (i64 -1 to ptr)) #2
  tail call void (...) @mThreadJoin() #2
  tail call void @m_Free(ptr noundef nonnull %1) #2
  tail call void @m_Free(ptr noundef nonnull %2) #2
  ret i32 0
}

declare ptr @m_Malloc(i32 noundef) local_unnamed_addr #1

declare void @m_Thread(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mThreadJoin(...) local_unnamed_addr #1

declare void @m_Free(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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 }

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass