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

; 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.1 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.test_Morn = external hidden unnamed_addr constant [10 x i8], align 1

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

declare void @_mTimerBegin(ptr noundef) #1

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

declare float @_mTimerEnd(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

10:                                               ; preds = %49, %2
  %11 = load i32, ptr %6, align 4, !tbaa !5
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sdiv i32 1000000, %12
  %14 = icmp slt i32 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %52

16:                                               ; preds = %10
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  call void @mIntToLInt(ptr noundef %17, i64 noundef 1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %45, %16
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = icmp sle i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %48

23:                                               ; preds = %18
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  %26 = sext i32 %25 to i64
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = add nsw i64 %28, 1
  %30 = icmp eq i64 %26, %29
  br i1 %30, label %31, label %38

31:                                               ; preds = %23
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = trunc i64 %34 to i32
  %36 = sext i32 %35 to i64
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  call void @m_LIntMulInt(ptr noundef %32, i64 noundef %36, ptr noundef %37)
  br label %44

38:                                               ; preds = %23
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = inttoptr i64 %41 to ptr
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  call void @m_LIntMul(ptr noundef %39, ptr noundef %42, ptr noundef %43)
  br label %44

44:                                               ; preds = %38, %31
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %8, align 4, !tbaa !5
  br label %18, !llvm.loop !11

48:                                               ; preds = %22
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %6, align 4, !tbaa !5
  br label %10, !llvm.loop !13

52:                                               ; preds = %15
  %53 = call float @_mTimerEnd(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 53, ptr noundef @__FUNCTION__.test_Morn)
  %54 = load ptr, ptr %5, align 8, !tbaa !9
  %55 = load ptr, ptr %4, align 8, !tbaa !9
  call void @mLIntToString(ptr noundef %54, ptr noundef %55)
  %56 = load ptr, ptr %5, align 8, !tbaa !9
  call void @mArrayRelease(ptr noundef %56)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

declare ptr @ArrayCreate(i32 noundef, i32 noundef, ptr noundef) #1

declare void @mIntToLInt(ptr noundef, i64 noundef) #1

declare void @m_LIntMulInt(ptr noundef, i64 noundef, ptr noundef) #1

declare void @m_LIntMul(ptr noundef, ptr noundef, ptr noundef) #1

declare void @mLIntToString(ptr noundef, ptr noundef) #1

declare void @mArrayRelease(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.1 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@__FUNCTION__.test_Morn = external hidden unnamed_addr constant [10 x i8], align 1

declare void @_mTimerBegin(ptr noundef) local_unnamed_addr #0

declare float @_mTimerEnd(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @test_Morn(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call ptr @ArrayCreate(i32 noundef -1, i32 noundef 0, ptr noundef null) #2
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.4) #2
  %4 = sdiv i32 1000000, %0
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph22, label %._crit_edge23

.lr.ph22:                                         ; preds = %2
  %.not18 = icmp slt i32 %0, 1
  br i1 %.not18, label %.lr.ph22.split.us, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph22
  %6 = add nuw i32 %0, 1
  %wide.trip.count = zext i32 %6 to i64
  br label %.lr.ph

.lr.ph22.split.us:                                ; preds = %.lr.ph22, %.lr.ph22.split.us
  %.01720.us = phi i32 [ %7, %.lr.ph22.split.us ], [ 0, %.lr.ph22 ]
  tail call void @mIntToLInt(ptr noundef %3, i64 noundef 1) #2
  %7 = add nuw nsw i32 %.01720.us, 1
  %exitcond27.not = icmp eq i32 %7, %4
  br i1 %exitcond27.not, label %._crit_edge23, label %.lr.ph22.split.us, !llvm.loop !5

._crit_edge23:                                    ; preds = %._crit_edge, %.lr.ph22.split.us, %2
  %8 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 53, ptr noundef nonnull @__FUNCTION__.test_Morn) #2
  tail call void @mLIntToString(ptr noundef %3, ptr noundef %1) #2
  tail call void @mArrayRelease(ptr noundef %3) #2
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %.01720 = phi i32 [ %9, %._crit_edge ], [ 0, %.lr.ph.preheader ]
  tail call void @mIntToLInt(ptr noundef %3, i64 noundef 1) #2
  br label %10

._crit_edge:                                      ; preds = %10
  %9 = add nuw nsw i32 %.01720, 1
  %exitcond26.not = icmp eq i32 %9, %4
  br i1 %exitcond26.not, label %._crit_edge23, label %.lr.ph, !llvm.loop !5

10:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  tail call void @m_LIntMulInt(ptr noundef %3, i64 noundef %indvars.iv, ptr noundef %3) #2
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !7
}

declare ptr @ArrayCreate(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @mIntToLInt(ptr noundef, i64 noundef) local_unnamed_addr #0

declare void @m_LIntMulInt(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare void @mLIntToString(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @mArrayRelease(ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass