; 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__.mTriangle = 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 @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 @mTriangle(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store float %1, ptr %9, align 4, !tbaa !9
  store float %2, ptr %10, align 4, !tbaa !9
  store float %3, ptr %11, align 4, !tbaa !9
  store float %4, ptr %12, align 4, !tbaa !9
  store float %5, ptr %13, align 4, !tbaa !9
  store float %6, ptr %14, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %24, label %20

20:                                               ; preds = %17
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = ptrtoint ptr %21 to i64
  %23 = icmp eq i64 %22, -1
  br label %24

24:                                               ; preds = %20, %17
  %25 = phi i1 [ true, %17 ], [ %23, %20 ]
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %15, align 4, !tbaa !11
  %27 = load i32, ptr %15, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  %30 = load i32, ptr %15, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %30, i32 noundef -1, ptr noundef @.str, i32 noundef 167, ptr noundef @__FUNCTION__.mTriangle, ptr noundef @.str.2)
  br label %31

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

32:                                               ; preds = %31
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mListPlace(ptr noundef %33, ptr noundef null, i32 noundef 3, i32 noundef 8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.MList, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  store ptr %36, ptr %16, align 8, !tbaa !5
  %37 = load float, ptr %9, align 4, !tbaa !9
  %38 = load ptr, ptr %16, align 8, !tbaa !5
  %39 = getelementptr inbounds ptr, ptr %38, i64 0
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.MImagePoint, ptr %40, i32 0, i32 0
  store float %37, ptr %41, align 4, !tbaa !15
  %42 = load float, ptr %10, align 4, !tbaa !9
  %43 = load ptr, ptr %16, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i64 0
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MImagePoint, ptr %45, i32 0, i32 1
  store float %42, ptr %46, align 4, !tbaa !17
  %47 = load float, ptr %11, align 4, !tbaa !9
  %48 = load ptr, ptr %16, align 8, !tbaa !5
  %49 = getelementptr inbounds ptr, ptr %48, i64 1
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MImagePoint, ptr %50, i32 0, i32 0
  store float %47, ptr %51, align 4, !tbaa !15
  %52 = load float, ptr %12, align 4, !tbaa !9
  %53 = load ptr, ptr %16, align 8, !tbaa !5
  %54 = getelementptr inbounds ptr, ptr %53, i64 1
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MImagePoint, ptr %55, i32 0, i32 1
  store float %52, ptr %56, align 4, !tbaa !17
  %57 = load float, ptr %13, align 4, !tbaa !9
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = getelementptr inbounds ptr, ptr %58, i64 2
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.MImagePoint, ptr %60, i32 0, i32 0
  store float %57, ptr %61, align 4, !tbaa !15
  %62 = load float, ptr %14, align 4, !tbaa !9
  %63 = load ptr, ptr %16, align 8, !tbaa !5
  %64 = getelementptr inbounds ptr, ptr %63, i64 2
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.MImagePoint, ptr %65, i32 0, i32 1
  store float %62, ptr %66, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #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__.mTriangle = external hidden unnamed_addr constant [10 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 @mTriangle(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, float noundef %5, float noundef %6) local_unnamed_addr #1 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %13 [
    i64 -1, label %8
    i64 0, label %8
  ]

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

13:                                               ; preds = %7, %8
  tail call void @mListPlace(ptr noundef %0, ptr noundef null, i32 noundef 3, i32 noundef 8) #2
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store float %1, ptr %16, align 4, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %16, i64 4
  store float %2, ptr %17, align 4, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %15, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store float %3, ptr %19, align 4, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  store float %4, ptr %20, align 4, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %15, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  store float %5, ptr %22, align 4, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  store float %6, ptr %23, 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