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

; 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.6 = external hidden unnamed_addr constant [60 x i8], align 1

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

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

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

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

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

declare ptr @m_Permutation(ptr noundef, i32 noundef) #0

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

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

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

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %12 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100)
  %13 = sitofp i32 %12 to float
  %14 = getelementptr inbounds %struct.MImagePoint, ptr %3, i32 0, i32 0
  store float %13, ptr %14, align 4, !tbaa !11
  %15 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100)
  %16 = sitofp i32 %15 to float
  %17 = getelementptr inbounds %struct.MImagePoint, ptr %3, i32 0, i32 1
  store float %16, ptr %17, align 4, !tbaa !14
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  %19 = call ptr @mListWrite(ptr noundef %18, i32 noundef -1, ptr noundef %3, i32 noundef 8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %20

20:                                               ; preds = %11
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %2, align 4, !tbaa !9
  br label %7, !llvm.loop !15

23:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  br label %24

24:                                               ; preds = %97, %23
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MList, ptr %25, i64 0
  %27 = call ptr @m_Permutation(ptr noundef %26, i32 noundef 4)
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %98

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.MList, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  store ptr %32, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds ptr, ptr %33, i64 0
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %36, i64 2
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %39, i64 1
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds ptr, ptr %42, i64 3
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = call i32 @mLineCross(ptr noundef %35, ptr noundef %38, ptr noundef %41, ptr noundef %44, ptr noundef null)
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %97

47:                                               ; preds = %29
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds ptr, ptr %48, i64 0
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MImagePoint, ptr %50, i32 0, i32 0
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = fpext float %52 to double
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds ptr, ptr %54, i64 0
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.MImagePoint, ptr %56, i32 0, i32 1
  %58 = load float, ptr %57, align 4, !tbaa !14
  %59 = fpext float %58 to double
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds ptr, ptr %60, i64 1
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.MImagePoint, ptr %62, i32 0, i32 0
  %64 = load float, ptr %63, align 4, !tbaa !11
  %65 = fpext float %64 to double
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds ptr, ptr %66, i64 1
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.MImagePoint, ptr %68, i32 0, i32 1
  %70 = load float, ptr %69, align 4, !tbaa !14
  %71 = fpext float %70 to double
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds ptr, ptr %72, i64 2
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MImagePoint, ptr %74, i32 0, i32 0
  %76 = load float, ptr %75, align 4, !tbaa !11
  %77 = fpext float %76 to double
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds ptr, ptr %78, i64 2
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.MImagePoint, ptr %80, i32 0, i32 1
  %82 = load float, ptr %81, align 4, !tbaa !14
  %83 = fpext float %82 to double
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds ptr, ptr %84, i64 3
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.MImagePoint, ptr %86, i32 0, i32 0
  %88 = load float, ptr %87, align 4, !tbaa !11
  %89 = fpext float %88 to double
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds ptr, ptr %90, i64 3
  %92 = load ptr, ptr %91, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.MImagePoint, ptr %92, i32 0, i32 1
  %94 = load float, ptr %93, align 4, !tbaa !14
  %95 = fpext float %94 to double
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, double noundef %53, double noundef %59, double noundef %65, double noundef %71, double noundef %77, double noundef %83, double noundef %89, double noundef %95)
  br label %97

97:                                               ; preds = %47, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %24, !llvm.loop !19

98:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

declare i32 @m_Rand(i32 noundef, i32 noundef) #0

declare i32 @mLineCross(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !13, i64 0}
!12 = !{!"MImagePoint", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !6, i64 8}
!18 = !{!"MList", !10, i64 0, !6, i64 8}
!19 = distinct !{!19, !16}


; 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.6 = external hidden unnamed_addr constant [60 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) 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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test2() local_unnamed_addr #3 {
.preheader:
  %0 = alloca %struct.MImagePoint, align 4
  %1 = tail call ptr @ListCreate(i32 noundef -1, ptr noundef null) #4
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %3 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %4 = sitofp i32 %3 to float
  store float %4, ptr %0, align 4, !tbaa !5
  %5 = tail call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %6 = sitofp i32 %5 to float
  store float %6, ptr %2, align 4, !tbaa !10
  %7 = call ptr @mListWrite(ptr noundef %1, i32 noundef -1, ptr noundef nonnull %0, i32 noundef 8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %8 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %9 = sitofp i32 %8 to float
  store float %9, ptr %0, align 4, !tbaa !5
  %10 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %11 = sitofp i32 %10 to float
  store float %11, ptr %2, align 4, !tbaa !10
  %12 = call ptr @mListWrite(ptr noundef %1, i32 noundef -1, ptr noundef nonnull %0, i32 noundef 8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %13 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %14 = sitofp i32 %13 to float
  store float %14, ptr %0, align 4, !tbaa !5
  %15 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %16 = sitofp i32 %15 to float
  store float %16, ptr %2, align 4, !tbaa !10
  %17 = call ptr @mListWrite(ptr noundef %1, i32 noundef -1, ptr noundef nonnull %0, i32 noundef 8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %18 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %19 = sitofp i32 %18 to float
  store float %19, ptr %0, align 4, !tbaa !5
  %20 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %21 = sitofp i32 %20 to float
  store float %21, ptr %2, align 4, !tbaa !10
  %22 = call ptr @mListWrite(ptr noundef %1, i32 noundef -1, ptr noundef nonnull %0, i32 noundef 8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #4
  %23 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %24 = sitofp i32 %23 to float
  store float %24, ptr %0, align 4, !tbaa !5
  %25 = call i32 @m_Rand(i32 noundef 0, i32 noundef 100) #4
  %26 = sitofp i32 %25 to float
  store float %26, ptr %2, align 4, !tbaa !10
  %27 = call ptr @mListWrite(ptr noundef %1, i32 noundef -1, ptr noundef nonnull %0, i32 noundef 8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #4
  %28 = call ptr @m_Permutation(ptr noundef %1, i32 noundef 4) #4
  %.not19 = icmp eq ptr %28, null
  br i1 %.not19, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %66
  %29 = phi ptr [ %67, %66 ], [ %28, %.preheader ]
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = getelementptr inbounds i8, ptr %31, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %31, i64 8
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %31, i64 24
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = call i32 @mLineCross(ptr noundef %32, ptr noundef %34, ptr noundef %36, ptr noundef %38, ptr noundef null) #4
  %.not17 = icmp eq i32 %39, 0
  br i1 %.not17, label %66, label %40

40:                                               ; preds = %.lr.ph
  %41 = load ptr, ptr %31, align 8, !tbaa !15
  %42 = load float, ptr %41, align 4, !tbaa !5
  %43 = fpext float %42 to double
  %44 = getelementptr inbounds i8, ptr %41, i64 4
  %45 = load float, ptr %44, align 4, !tbaa !10
  %46 = fpext float %45 to double
  %47 = load ptr, ptr %35, align 8, !tbaa !15
  %48 = load float, ptr %47, align 4, !tbaa !5
  %49 = fpext float %48 to double
  %50 = getelementptr inbounds i8, ptr %47, i64 4
  %51 = load float, ptr %50, align 4, !tbaa !10
  %52 = fpext float %51 to double
  %53 = load ptr, ptr %33, align 8, !tbaa !15
  %54 = load float, ptr %53, align 4, !tbaa !5
  %55 = fpext float %54 to double
  %56 = getelementptr inbounds i8, ptr %53, i64 4
  %57 = load float, ptr %56, align 4, !tbaa !10
  %58 = fpext float %57 to double
  %59 = load ptr, ptr %37, align 8, !tbaa !15
  %60 = load float, ptr %59, align 4, !tbaa !5
  %61 = fpext float %60 to double
  %62 = getelementptr inbounds i8, ptr %59, i64 4
  %63 = load float, ptr %62, align 4, !tbaa !10
  %64 = fpext float %63 to double
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, double noundef %43, double noundef %46, double noundef %49, double noundef %52, double noundef %55, double noundef %58, double noundef %61, double noundef %64)
  br label %66

66:                                               ; preds = %40, %.lr.ph
  %67 = call ptr @m_Permutation(ptr noundef %1, i32 noundef 4) #4
  %.not = icmp eq ptr %67, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %66, %.preheader
  ret void
}

declare i32 @m_Rand(i32 noundef, i32 noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #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 = { 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 #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, !7, i64 0}
!6 = !{!"MImagePoint", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !14, i64 8}
!12 = !{!"MList", !13, i64 0, !14, i64 8}
!13 = !{!"int", !8, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!14, !14, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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