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

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

@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@main.Info = external hidden global ptr, align 8
@main.Info.5 = external hidden global ptr, align 8
@main.Info.6 = external hidden global ptr, align 8
@main.Info.7 = external hidden global ptr, align 8

; 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

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

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

declare ptr @m_CoroutineInfo(ptr noundef, ptr noundef, ptr noundef) #2

declare void @m_Coroutine(ptr noundef) #2

; 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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [2 x ptr], align 16
  %5 = alloca [2 x ptr], align 16
  %6 = alloca [2 x ptr], align 16
  %7 = alloca [2 x ptr], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %51, %0
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 8
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %54

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %13)
  br label %15

15:                                               ; preds = %12
  br label %16

16:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  store ptr @test1, ptr %4, align 8, !tbaa !9
  %17 = getelementptr inbounds ptr, ptr %4, i64 1
  store ptr %2, ptr %17, align 8, !tbaa !9
  %18 = load ptr, ptr @main.Info, align 8, !tbaa !9
  %19 = icmp eq ptr %18, null
  br i1 %19, label %25, label %20

20:                                               ; preds = %16
  %21 = getelementptr inbounds [2 x ptr], ptr %4, i64 0, i64 0
  %22 = load ptr, ptr @main.Info, align 8, !tbaa !9
  %23 = call i32 @memcmp(ptr noundef %21, ptr noundef %22, i64 noundef 16) #5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %20, %16
  %26 = call ptr @m_CoroutineInfo(ptr noundef @test1, ptr noundef %2, ptr noundef inttoptr (i64 -1 to ptr))
  store ptr %26, ptr @main.Info, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %25, %20
  %28 = load ptr, ptr @main.Info, align 8, !tbaa !9
  call void @m_Coroutine(ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  br label %29

29:                                               ; preds = %27
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  store ptr @test2, ptr %5, align 8, !tbaa !9
  %35 = getelementptr inbounds ptr, ptr %5, i64 1
  store ptr %2, ptr %35, align 8, !tbaa !9
  %36 = load ptr, ptr @main.Info.5, align 8, !tbaa !9
  %37 = icmp eq ptr %36, null
  br i1 %37, label %43, label %38

38:                                               ; preds = %34
  %39 = getelementptr inbounds [2 x ptr], ptr %5, i64 0, i64 0
  %40 = load ptr, ptr @main.Info.5, align 8, !tbaa !9
  %41 = call i32 @memcmp(ptr noundef %39, ptr noundef %40, i64 noundef 16) #5
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %45

43:                                               ; preds = %38, %34
  %44 = call ptr @m_CoroutineInfo(ptr noundef @test2, ptr noundef %2, ptr noundef inttoptr (i64 -1 to ptr))
  store ptr %44, ptr @main.Info.5, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %43, %38
  %46 = load ptr, ptr @main.Info.5, align 8, !tbaa !9
  call void @m_Coroutine(ptr noundef %46)
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  br label %47

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %3, align 4, !tbaa !5
  br label %8, !llvm.loop !11

54:                                               ; preds = %11
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  store ptr @test1, ptr %6, align 8, !tbaa !9
  %57 = getelementptr inbounds ptr, ptr %6, i64 1
  store ptr %2, ptr %57, align 8, !tbaa !9
  %58 = load ptr, ptr @main.Info.6, align 8, !tbaa !9
  %59 = icmp eq ptr %58, null
  br i1 %59, label %65, label %60

60:                                               ; preds = %56
  %61 = getelementptr inbounds [2 x ptr], ptr %6, i64 0, i64 0
  %62 = load ptr, ptr @main.Info.6, align 8, !tbaa !9
  %63 = call i32 @memcmp(ptr noundef %61, ptr noundef %62, i64 noundef 16) #5
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %67

65:                                               ; preds = %60, %56
  %66 = call ptr @m_CoroutineInfo(ptr noundef @test1, ptr noundef %2, ptr noundef inttoptr (i64 -1 to ptr))
  store ptr %66, ptr @main.Info.6, align 8, !tbaa !9
  br label %67

67:                                               ; preds = %65, %60
  %68 = load ptr, ptr @main.Info.6, align 8, !tbaa !9
  call void @m_Coroutine(ptr noundef %68)
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br label %69

69:                                               ; preds = %67
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  store ptr @test2, ptr %7, align 8, !tbaa !9
  %75 = getelementptr inbounds ptr, ptr %7, i64 1
  store ptr %2, ptr %75, align 8, !tbaa !9
  %76 = load ptr, ptr @main.Info.7, align 8, !tbaa !9
  %77 = icmp eq ptr %76, null
  br i1 %77, label %83, label %78

78:                                               ; preds = %74
  %79 = getelementptr inbounds [2 x ptr], ptr %7, i64 0, i64 0
  %80 = load ptr, ptr @main.Info.7, align 8, !tbaa !9
  %81 = call i32 @memcmp(ptr noundef %79, ptr noundef %80, i64 noundef 16) #5
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %85

83:                                               ; preds = %78, %74
  %84 = call ptr @m_CoroutineInfo(ptr noundef @test2, ptr noundef %2, ptr noundef inttoptr (i64 -1 to ptr))
  store ptr %84, ptr @main.Info.7, align 8, !tbaa !9
  br label %85

85:                                               ; preds = %83, %78
  %86 = load ptr, ptr @main.Info.7, align 8, !tbaa !9
  call void @m_Coroutine(ptr noundef %86)
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  br label %87

87:                                               ; preds = %85
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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 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 = !{!"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}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str.4 = external hidden unnamed_addr constant [23 x i8], align 1
@main.Info = external hidden local_unnamed_addr global ptr, align 8
@main.Info.5 = external hidden local_unnamed_addr global ptr, align 8
@main.Info.6 = external hidden local_unnamed_addr global ptr, align 8
@main.Info.7 = external hidden local_unnamed_addr global ptr, align 8

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare ptr @m_CoroutineInfo(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @m_Coroutine(ptr noundef) local_unnamed_addr #3

; 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 = alloca i32, align 4
  %2 = alloca [2 x ptr], align 16
  %3 = alloca [2 x ptr], align 16
  %4 = alloca [2 x ptr], align 16
  %5 = alloca [2 x ptr], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 1, ptr %1, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  br label %12

8:                                                ; preds = %26
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  store ptr @test1, ptr %4, align 16, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %1, ptr %9, align 8, !tbaa !9
  %10 = load ptr, ptr @main.Info.6, align 8, !tbaa !9
  %11 = icmp eq ptr %10, null
  br i1 %11, label %30, label %29

12:                                               ; preds = %0, %26
  %.013 = phi i32 [ 0, %0 ], [ %28, %26 ]
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %.013)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  store ptr @test1, ptr %2, align 16, !tbaa !9
  store ptr %1, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr @main.Info, align 8, !tbaa !9
  %15 = icmp eq ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  %bcmp9 = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %2, ptr noundef nonnull dereferenceable(16) %14, i64 16)
  %.not10 = icmp eq i32 %bcmp9, 0
  br i1 %.not10, label %19, label %17

17:                                               ; preds = %16, %12
  %18 = call ptr @m_CoroutineInfo(ptr noundef nonnull @test1, ptr noundef nonnull %1, ptr noundef nonnull inttoptr (i64 -1 to ptr)) #5
  store ptr %18, ptr @main.Info, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %17, %16
  %20 = phi ptr [ %18, %17 ], [ %14, %16 ]
  call void @m_Coroutine(ptr noundef %20) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #5
  store ptr @test2, ptr %3, align 16, !tbaa !9
  store ptr %1, ptr %7, align 8, !tbaa !9
  %21 = load ptr, ptr @main.Info.5, align 8, !tbaa !9
  %22 = icmp eq ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  %bcmp11 = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %3, ptr noundef nonnull dereferenceable(16) %21, i64 16)
  %.not12 = icmp eq i32 %bcmp11, 0
  br i1 %.not12, label %26, label %24

24:                                               ; preds = %23, %19
  %25 = call ptr @m_CoroutineInfo(ptr noundef nonnull @test2, ptr noundef nonnull %1, ptr noundef nonnull inttoptr (i64 -1 to ptr)) #5
  store ptr %25, ptr @main.Info.5, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %24, %23
  %27 = phi ptr [ %25, %24 ], [ %21, %23 ]
  call void @m_Coroutine(ptr noundef %27) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #5
  %28 = add nuw nsw i32 %.013, 1
  %exitcond.not = icmp eq i32 %28, 8
  br i1 %exitcond.not, label %8, label %12, !llvm.loop !11

29:                                               ; preds = %8
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %4, ptr noundef nonnull dereferenceable(16) %10, i64 16)
  %.not = icmp eq i32 %bcmp, 0
  br i1 %.not, label %32, label %30

30:                                               ; preds = %29, %8
  %31 = call ptr @m_CoroutineInfo(ptr noundef nonnull @test1, ptr noundef nonnull %1, ptr noundef nonnull inttoptr (i64 -1 to ptr)) #5
  store ptr %31, ptr @main.Info.6, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %30, %29
  %33 = phi ptr [ %31, %30 ], [ %10, %29 ]
  call void @m_Coroutine(ptr noundef %33) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  store ptr @test2, ptr %5, align 16, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %1, ptr %34, align 8, !tbaa !9
  %35 = load ptr, ptr @main.Info.7, align 8, !tbaa !9
  %36 = icmp eq ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  %bcmp7 = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %5, ptr noundef nonnull dereferenceable(16) %35, i64 16)
  %.not8 = icmp eq i32 %bcmp7, 0
  br i1 %.not8, label %40, label %38

38:                                               ; preds = %37, %32
  %39 = call ptr @m_CoroutineInfo(ptr noundef nonnull @test2, ptr noundef nonnull %1, ptr noundef nonnull inttoptr (i64 -1 to ptr)) #5
  store ptr %39, ptr @main.Info.7, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %38, %37
  %41 = phi ptr [ %39, %38 ], [ %35, %37 ]
  call void @m_Coroutine(ptr noundef %41) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { nofree nounwind willreturn memory(argmem: read) }
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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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