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

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

%struct.MImagePoint = type { float, float }
%struct.MList = type { i32, ptr }

@.str = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @CurvePoint(ptr noundef, 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
define dso_local i32 @main1() #0 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.MImagePoint, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.MImagePoint, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store float 2.000000e+00, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %11 = call ptr @ListCreate(i32 noundef -1, ptr noundef null)
  store ptr %11, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 10, ptr %4, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %27, %0
  %13 = load i32, ptr %4, align 4, !tbaa !11
  %14 = icmp sle i32 %13, 40
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %30

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %17 = getelementptr inbounds %struct.MImagePoint, ptr %5, i32 0, i32 0
  %18 = load i32, ptr %4, align 4, !tbaa !11
  %19 = sitofp i32 %18 to float
  store float %19, ptr %17, align 4, !tbaa !13
  %20 = getelementptr inbounds %struct.MImagePoint, ptr %5, i32 0, i32 1
  %21 = load float, ptr %2, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !11
  %23 = sitofp i32 %22 to float
  %24 = fmul float %21, %23
  store float %24, ptr %20, align 4, !tbaa !15
  %25 = load ptr, ptr %3, align 8, !tbaa !9
  %26 = call ptr @mListWrite(ptr noundef %25, i32 noundef -1, ptr noundef %5, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %27

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

30:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %31 = call ptr @ListCreate(i32 noundef -1, ptr noundef null)
  store ptr %31, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %32 = call ptr @ListCreate(i32 noundef -1, ptr noundef null)
  store ptr %32, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %33 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 0
  store float 1.000000e+01, ptr %33, align 4, !tbaa !13
  %34 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 1
  store float 2.000000e+01, ptr %34, align 4, !tbaa !15
  %35 = load ptr, ptr %7, align 8, !tbaa !9
  %36 = call ptr @mListWrite(ptr noundef %35, i32 noundef -1, ptr noundef %8, i32 noundef 8)
  %37 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 0
  store float 2.000000e+01, ptr %37, align 4, !tbaa !13
  %38 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 1
  store float 5.000000e+01, ptr %38, align 4, !tbaa !15
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = call ptr @mListWrite(ptr noundef %39, i32 noundef -1, ptr noundef %8, i32 noundef 8)
  %41 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 0
  store float 3.000000e+01, ptr %41, align 4, !tbaa !13
  %42 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 1
  store float 6.800000e+01, ptr %42, align 4, !tbaa !15
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = call ptr @mListWrite(ptr noundef %43, i32 noundef -1, ptr noundef %8, i32 noundef 8)
  %45 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 0
  store float 4.000000e+01, ptr %45, align 4, !tbaa !13
  %46 = getelementptr inbounds %struct.MImagePoint, ptr %8, i32 0, i32 1
  store float 8.000000e+01, ptr %46, align 4, !tbaa !15
  %47 = load ptr, ptr %7, align 8, !tbaa !9
  %48 = call ptr @mListWrite(ptr noundef %47, i32 noundef -1, ptr noundef %8, i32 noundef 8)
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = load ptr, ptr %7, align 8, !tbaa !9
  %51 = load float, ptr %2, align 4, !tbaa !5
  %52 = load float, ptr %2, align 4, !tbaa !5
  call void @mPointInterpolation(ptr noundef %49, ptr noundef %50, float noundef %51, float noundef %52)
  %53 = load ptr, ptr %3, align 8, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  call void @CurvePoint(ptr noundef %53, ptr noundef %54)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %55

55:                                               ; preds = %79, %30
  %56 = load i32, ptr %9, align 4, !tbaa !11
  %57 = load ptr, ptr %3, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.MList, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !18
  %60 = icmp slt i32 %56, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %82

62:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %63 = load ptr, ptr %3, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.MList, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !20
  %66 = load i32, ptr %9, align 4, !tbaa !11
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  store ptr %69, ptr %10, align 8, !tbaa !9
  %70 = load ptr, ptr %10, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.MImagePoint, ptr %70, i32 0, i32 0
  %72 = load float, ptr %71, align 4, !tbaa !13
  %73 = fpext float %72 to double
  %74 = load ptr, ptr %10, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.MImagePoint, ptr %74, i32 0, i32 1
  %76 = load float, ptr %75, align 4, !tbaa !15
  %77 = fpext float %76 to double
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %73, double noundef %77)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %79

79:                                               ; preds = %62
  %80 = load i32, ptr %9, align 4, !tbaa !11
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %9, align 4, !tbaa !11
  br label %55, !llvm.loop !21

82:                                               ; preds = %61
  %83 = load ptr, ptr %7, align 8, !tbaa !9
  call void @mListRelease(ptr noundef %83)
  %84 = load ptr, ptr %6, align 8, !tbaa !9
  call void @mListRelease(ptr noundef %84)
  %85 = load ptr, ptr %3, align 8, !tbaa !9
  call void @mListRelease(ptr noundef %85)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %86 = load i32, ptr %1, align 4
  ret i32 %86
}

declare ptr @ListCreate(i32 noundef, ptr noundef) #2

declare ptr @mListWrite(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

declare void @mPointInterpolation(ptr noundef, ptr noundef, float noundef, float noundef) #2

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

declare void @mListRelease(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 = !{!"float", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"MImagePoint", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !12, i64 0}
!19 = !{!"MList", !12, i64 0, !10, i64 8}
!20 = !{!19, !10, i64 8}
!21 = distinct !{!21, !17}


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

%struct.MImagePoint = type { float, float }

@.str = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @CurvePoint(ptr noundef, ptr noundef) local_unnamed_addr #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: nounwind uwtable
define dso_local i32 @main1() local_unnamed_addr #0 {
  %1 = alloca %struct.MImagePoint, align 4
  %2 = alloca %struct.MImagePoint, align 8
  %3 = tail call ptr @ListCreate(i32 noundef -1, ptr noundef null) #4
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  br label %15

5:                                                ; preds = %15
  %6 = call ptr @ListCreate(i32 noundef -1, ptr noundef null) #4
  %7 = call ptr @ListCreate(i32 noundef -1, ptr noundef null) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store <2 x float> <float 1.000000e+01, float 2.000000e+01>, ptr %2, align 8, !tbaa !5
  %8 = call ptr @mListWrite(ptr noundef %7, i32 noundef -1, ptr noundef nonnull %2, i32 noundef 8) #4
  store <2 x float> <float 2.000000e+01, float 5.000000e+01>, ptr %2, align 8, !tbaa !5
  %9 = call ptr @mListWrite(ptr noundef %7, i32 noundef -1, ptr noundef nonnull %2, i32 noundef 8) #4
  store <2 x float> <float 3.000000e+01, float 6.800000e+01>, ptr %2, align 8, !tbaa !5
  %10 = call ptr @mListWrite(ptr noundef %7, i32 noundef -1, ptr noundef nonnull %2, i32 noundef 8) #4
  store <2 x float> <float 4.000000e+01, float 8.000000e+01>, ptr %2, align 8, !tbaa !5
  %11 = call ptr @mListWrite(ptr noundef %7, i32 noundef -1, ptr noundef nonnull %2, i32 noundef 8) #4
  call void @mPointInterpolation(ptr noundef %6, ptr noundef %7, float noundef 2.000000e+00, float noundef 2.000000e+00) #4
  call void @CurvePoint(ptr noundef %3, ptr noundef %6)
  %12 = load i32, ptr %3, align 8, !tbaa !9
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  br label %20

15:                                               ; preds = %0, %15
  %.027 = phi i32 [ 10, %0 ], [ %19, %15 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %16 = uitofp nneg i32 %.027 to float
  store float %16, ptr %1, align 4, !tbaa !13
  %17 = fmul float %16, 2.000000e+00
  store float %17, ptr %4, align 4, !tbaa !15
  %18 = call ptr @mListWrite(ptr noundef %3, i32 noundef -1, ptr noundef nonnull %1, i32 noundef 8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  %19 = add nuw nsw i32 %.027, 1
  %exitcond.not = icmp eq i32 %19, 41
  br i1 %exitcond.not, label %5, label %15, !llvm.loop !16

._crit_edge:                                      ; preds = %20, %5
  call void @mListRelease(ptr noundef %7) #4
  call void @mListRelease(ptr noundef %6) #4
  call void @mListRelease(ptr noundef nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret i32 undef

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = load ptr, ptr %14, align 8, !tbaa !18
  %22 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv
  %23 = load ptr, ptr %22, align 8, !tbaa !19
  %24 = load float, ptr %23, align 4, !tbaa !13
  %25 = fpext float %24 to double
  %26 = getelementptr inbounds i8, ptr %23, i64 4
  %27 = load float, ptr %26, align 4, !tbaa !15
  %28 = fpext float %27 to double
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %25, double noundef %28)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr %3, align 8, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next, %31
  br i1 %32, label %20, label %._crit_edge, !llvm.loop !20
}

declare ptr @ListCreate(i32 noundef, ptr noundef) local_unnamed_addr #2

declare ptr @mListWrite(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @mPointInterpolation(ptr noundef, ptr noundef, float noundef, float noundef) local_unnamed_addr #2

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

declare void @mListRelease(ptr noundef) local_unnamed_addr #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 = { mustprogress 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 = { 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 #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"MList", !11, i64 0, !12, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"MImagePoint", !6, i64 0, !6, i64 4}
!15 = !{!14, !6, i64 4}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !12, i64 8}
!19 = !{!12, !12, i64 0}
!20 = distinct !{!20, !17}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass