; LLVM IR from jingweizhanghuai/Morn :: src/image (morn_image_geometry)

; 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.MList = type { i32, ptr }
%struct.MImagePoint = type { float, float }

@.str = external hidden unnamed_addr constant [87 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mQuadrangle = external hidden unnamed_addr constant [12 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 @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, 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 void @mListPlace(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @mQuadrangle(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6, float noundef %7, float noundef %8) #2 {
  %10 = alloca ptr, align 8
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  store ptr %0, ptr %10, align 8, !tbaa !5
  store float %1, ptr %11, align 4, !tbaa !9
  store float %2, ptr %12, align 4, !tbaa !9
  store float %3, ptr %13, align 4, !tbaa !9
  store float %4, ptr %14, align 4, !tbaa !9
  store float %5, ptr %15, align 4, !tbaa !9
  store float %6, ptr %16, align 4, !tbaa !9
  store float %7, ptr %17, align 4, !tbaa !9
  store float %8, ptr %18, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %28, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = ptrtoint ptr %25 to i64
  %27 = icmp eq i64 %26, -1
  br label %28

28:                                               ; preds = %24, %21
  %29 = phi i1 [ true, %21 ], [ %27, %24 ]
  %30 = zext i1 %29 to i32
  store i32 %30, ptr %19, align 4, !tbaa !11
  %31 = load i32, ptr %19, align 4, !tbaa !11
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %28
  %34 = load i32, ptr %19, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %34, i32 noundef -1, ptr noundef @.str, i32 noundef 182, ptr noundef @__FUNCTION__.mQuadrangle, ptr noundef @.str.2)
  br label %35

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

36:                                               ; preds = %35
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  call void @mListPlace(ptr noundef %37, ptr noundef null, i32 noundef 4, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MList, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  store ptr %40, ptr %20, align 8, !tbaa !5
  %41 = load float, ptr %11, align 4, !tbaa !9
  %42 = load ptr, ptr %20, align 8, !tbaa !5
  %43 = getelementptr inbounds ptr, ptr %42, i64 0
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.MImagePoint, ptr %44, i32 0, i32 0
  store float %41, ptr %45, align 4, !tbaa !15
  %46 = load float, ptr %12, align 4, !tbaa !9
  %47 = load ptr, ptr %20, align 8, !tbaa !5
  %48 = getelementptr inbounds ptr, ptr %47, i64 0
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.MImagePoint, ptr %49, i32 0, i32 1
  store float %46, ptr %50, align 4, !tbaa !17
  %51 = load float, ptr %13, align 4, !tbaa !9
  %52 = load ptr, ptr %20, align 8, !tbaa !5
  %53 = getelementptr inbounds ptr, ptr %52, i64 1
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.MImagePoint, ptr %54, i32 0, i32 0
  store float %51, ptr %55, align 4, !tbaa !15
  %56 = load float, ptr %14, align 4, !tbaa !9
  %57 = load ptr, ptr %20, align 8, !tbaa !5
  %58 = getelementptr inbounds ptr, ptr %57, i64 1
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.MImagePoint, ptr %59, i32 0, i32 1
  store float %56, ptr %60, align 4, !tbaa !17
  %61 = load float, ptr %15, align 4, !tbaa !9
  %62 = load ptr, ptr %20, align 8, !tbaa !5
  %63 = getelementptr inbounds ptr, ptr %62, i64 2
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.MImagePoint, ptr %64, i32 0, i32 0
  store float %61, ptr %65, align 4, !tbaa !15
  %66 = load float, ptr %16, align 4, !tbaa !9
  %67 = load ptr, ptr %20, align 8, !tbaa !5
  %68 = getelementptr inbounds ptr, ptr %67, i64 2
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.MImagePoint, ptr %69, i32 0, i32 1
  store float %66, ptr %70, align 4, !tbaa !17
  %71 = load float, ptr %17, align 4, !tbaa !9
  %72 = load ptr, ptr %20, align 8, !tbaa !5
  %73 = getelementptr inbounds ptr, ptr %72, i64 3
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.MImagePoint, ptr %74, i32 0, i32 0
  store float %71, ptr %75, align 4, !tbaa !15
  %76 = load float, ptr %18, align 4, !tbaa !9
  %77 = load ptr, ptr %20, align 8, !tbaa !5
  %78 = getelementptr inbounds ptr, ptr %77, i64 3
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.MImagePoint, ptr %79, i32 0, i32 1
  store float %76, ptr %80, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  ret void
}

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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"MList", !12, i64 0, !6, i64 8}
!15 = !{!16, !10, i64 0}
!16 = !{!"MImagePoint", !10, i64 0, !10, i64 4}
!17 = !{!16, !10, i64 4}


; 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 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mQuadrangle = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mQuadrangle(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6, float noundef %7, float noundef %8) local_unnamed_addr #1 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %15 [
    i64 -1, label %10
    i64 0, label %10
  ]

10:                                               ; preds = %9, %9
  %11 = icmp eq ptr %0, null
  %12 = icmp eq ptr %0, inttoptr (i64 -1 to ptr)
  %13 = or i1 %11, %12
  %14 = zext i1 %13 to i32
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %14, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 182, ptr noundef nonnull @__FUNCTION__.mQuadrangle, ptr noundef nonnull @.str.2) #2
  br label %15

15:                                               ; preds = %9, %10
  tail call void @mListPlace(ptr noundef %0, ptr noundef null, i32 noundef 4, i32 noundef 8) #2
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  store float %1, ptr %18, align 4, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  store float %2, ptr %19, align 4, !tbaa !15
  %20 = getelementptr inbounds i8, ptr %17, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  store float %3, ptr %21, align 4, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %21, i64 4
  store float %4, ptr %22, align 4, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %17, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  store float %5, ptr %24, align 4, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %24, i64 4
  store float %6, ptr %25, align 4, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %17, i64 24
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  store float %7, ptr %27, align 4, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  store float %8, ptr %28, align 4, !tbaa !15
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass