; 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.10 = external hidden unnamed_addr constant [6 x i8], align 1
@__FUNCTION__.main3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [6 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

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 @mArrayRelease(ptr noundef) #1

declare void @mFactorial(ptr noundef, i32 noundef) #1

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

7:                                                ; preds = %33, %0
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = icmp sle i32 %8, 100000
  br i1 %9, label %11, label %10

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

11:                                               ; preds = %7
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = add nsw i32 %12, 1
  %14 = sext i32 %13 to i64
  %15 = load i32, ptr %3, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = add nsw i64 %16, 1
  %18 = icmp eq i64 %14, %17
  br i1 %18, label %19, label %26

19:                                               ; preds = %11
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = trunc i64 %22 to i32
  %24 = sext i32 %23 to i64
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_LIntMulInt(ptr noundef %20, i64 noundef %24, ptr noundef %25)
  br label %32

26:                                               ; preds = %11
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = inttoptr i64 %29 to ptr
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  call void @m_LIntMul(ptr noundef %27, ptr noundef %30, ptr noundef %31)
  br label %32

32:                                               ; preds = %26, %19
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !11

36:                                               ; preds = %10
  %37 = call float @_mTimerEnd(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 172, ptr noundef @__FUNCTION__.main3)
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  call void @mArrayRelease(ptr noundef %38)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %39 = call ptr @ArrayCreate(i32 noundef -1, i32 noundef 0, ptr noundef null)
  store ptr %39, ptr %4, align 8, !tbaa !5
  call void @_mTimerBegin(ptr noundef @.str.11)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mFactorial(ptr noundef %40, i32 noundef 100000)
  %41 = call float @_mTimerEnd(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 178, ptr noundef @__FUNCTION__.main3)
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mArrayRelease(ptr noundef %42)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %43 = load i32, ptr %1, align 4
  ret i32 %43
}

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 = !{!"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 = 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.1 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 x i8], align 1
@__FUNCTION__.main3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [6 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

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 @mArrayRelease(ptr noundef) local_unnamed_addr #0

declare void @mFactorial(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main3() local_unnamed_addr #1 {
  %1 = tail call ptr @ArrayCreate(i32 noundef -1, i32 noundef 0, ptr noundef null) #2
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.10) #2
  tail call void @mIntToLInt(ptr noundef %1, i64 noundef 1) #2
  br label %6

2:                                                ; preds = %6
  %3 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 172, ptr noundef nonnull @__FUNCTION__.main3) #2
  tail call void @mArrayRelease(ptr noundef %1) #2
  %4 = tail call ptr @ArrayCreate(i32 noundef -1, i32 noundef 0, ptr noundef null) #2
  tail call void @_mTimerBegin(ptr noundef nonnull @.str.11) #2
  tail call void @mFactorial(ptr noundef %4, i32 noundef 100000) #2
  %5 = tail call float @_mTimerEnd(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 178, ptr noundef nonnull @__FUNCTION__.main3) #2
  tail call void @mArrayRelease(ptr noundef %4) #2
  ret i32 undef

6:                                                ; preds = %0, %6
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %6 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  tail call void @m_LIntMulInt(ptr noundef %1, i64 noundef %indvars.iv, ptr noundef %1) #2
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100001
  br i1 %exitcond.not, label %2, label %6, !llvm.loop !5
}

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


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