; LLVM IR from The-Order-of-the-Simulation/Path-Tracing-Renderer :: cpu/main.ll (Z11process_hitRK12intersectionS1_)

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

%class.intersection = type { float, float, i8, %class.vec3, %class.material }
%class.vec3 = type { float, float, float }
%class.material = type { i8, %class.vec3, float, float }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11process_hitRK12intersectionS1_(ptr dead_on_unwind noalias writable sret(%class.intersection) align 4 %0, ptr noundef nonnull align 4 dereferenceable(48) %1, ptr noundef nonnull align 4 dereferenceable(48) %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds %class.intersection, ptr %7, i32 0, i32 2
  %9 = load i8, ptr %8, align 4, !tbaa !9, !range !15, !noundef !16
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %66

11:                                               ; preds = %3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.intersection, ptr %12, i32 0, i32 2
  %14 = load i8, ptr %13, align 4, !tbaa !9, !range !15, !noundef !16
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %64

16:                                               ; preds = %11
  call void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48) %0)
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.intersection, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.intersection, ptr %19, i32 0, i32 0
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %20)
  %22 = load float, ptr %21, align 4, !tbaa !17
  %23 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 0
  store float %22, ptr %23, align 4, !tbaa !18
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.intersection, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %class.intersection, ptr %26, i32 0, i32 1
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %27)
  %29 = load float, ptr %28, align 4, !tbaa !17
  %30 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 1
  store float %29, ptr %30, align 4, !tbaa !19
  %31 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 2
  store i8 1, ptr %31, align 4, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.intersection, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !18
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.intersection, ptr %35, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !18
  %38 = fcmp olt float %34, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %16
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.intersection, ptr %40, i32 0, i32 3
  br label %45

42:                                               ; preds = %16
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %class.intersection, ptr %43, i32 0, i32 3
  br label %45

45:                                               ; preds = %42, %39
  %46 = phi ptr [ %41, %39 ], [ %44, %42 ]
  %47 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 4 %46, i64 12, i1 false), !tbaa.struct !20
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.intersection, ptr %48, i32 0, i32 0
  %50 = load float, ptr %49, align 4, !tbaa !18
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %class.intersection, ptr %51, i32 0, i32 0
  %53 = load float, ptr %52, align 4, !tbaa !18
  %54 = fcmp olt float %50, %53
  br i1 %54, label %55, label %58

55:                                               ; preds = %45
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %class.intersection, ptr %56, i32 0, i32 4
  br label %61

58:                                               ; preds = %45
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %class.intersection, ptr %59, i32 0, i32 4
  br label %61

61:                                               ; preds = %58, %55
  %62 = phi ptr [ %57, %55 ], [ %60, %58 ]
  %63 = getelementptr inbounds %class.intersection, ptr %0, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %63, ptr align 4 %62, i64 24, i1 false), !tbaa.struct !21
  br label %68

64:                                               ; preds = %11
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN12intersectionC2ERKS_(ptr noundef nonnull align 4 dereferenceable(48) %0, ptr noundef nonnull align 4 dereferenceable(48) %65)
  br label %68

66:                                               ; preds = %3
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN12intersectionC2ERKS_(ptr noundef nonnull align 4 dereferenceable(48) %0, ptr noundef nonnull align 4 dereferenceable(48) %67)
  br label %68

68:                                               ; preds = %66, %64, %61
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12intersectionC2ERKS_(ptr noundef nonnull align 4 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(48)) unnamed_addr #0 align 2

attributes #0 = { inlinehint mustprogress 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 = { mustprogress 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" }

!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++ TBAA"}
!9 = !{!10, !12, i64 8}
!10 = !{!"_ZTS12intersection", !11, i64 0, !11, i64 4, !12, i64 8, !13, i64 12, !14, i64 24}
!11 = !{!"float", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTS4vec3", !11, i64 0, !11, i64 4, !11, i64 8}
!14 = !{!"_ZTS8material", !12, i64 0, !13, i64 4, !11, i64 16, !11, i64 20}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !11, i64 0}
!19 = !{!10, !11, i64 4}
!20 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17}
!21 = !{i64 0, i64 1, !22, i64 4, i64 4, !17, i64 8, i64 4, !17, i64 12, i64 4, !17, i64 16, i64 4, !17, i64 20, i64 4, !17}
!22 = !{!12, !12, i64 0}


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

%class.intersection = type { float, float, i8, %class.vec3, %class.material }
%class.vec3 = type { float, float, float }
%class.material = type { i8, %class.vec3, float, float }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11process_hitRK12intersectionS1_(ptr dead_on_unwind noalias writable sret(%class.intersection) align 4 %0, ptr noundef nonnull align 4 dereferenceable(48) %1, ptr noundef nonnull align 4 dereferenceable(48) %2) local_unnamed_addr #3 {
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %5 = load i8, ptr %4, align 4, !tbaa !5, !range !13, !noundef !14
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %7, label %28

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i8, ptr %8, align 4, !tbaa !5, !range !13, !noundef !14
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %27

11:                                               ; preds = %7
  tail call void @_ZN12intersectionC2Ev(ptr noundef nonnull align 4 dereferenceable(48) %0)
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %13 = load float, ptr %12, align 4, !tbaa !15
  store float %13, ptr %0, align 4, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  %15 = getelementptr inbounds i8, ptr %2, i64 4
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %17 = load float, ptr %16, align 4, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %0, i64 4
  store float %17, ptr %18, align 4, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 1, ptr %19, align 4, !tbaa !5
  %20 = load float, ptr %1, align 4, !tbaa !16
  %21 = load float, ptr %2, align 4, !tbaa !16
  %22 = fcmp olt float %20, %21
  %.v = select i1 %22, ptr %1, ptr %2
  %23 = getelementptr inbounds i8, ptr %.v, i64 12
  %24 = getelementptr inbounds i8, ptr %0, i64 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %24, ptr noundef nonnull align 4 dereferenceable(12) %23, i64 12, i1 false), !tbaa.struct !18
  %25 = getelementptr inbounds i8, ptr %.v, i64 24
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(24) %26, ptr noundef nonnull align 4 dereferenceable(24) %25, i64 24, i1 false), !tbaa.struct !19
  br label %29

27:                                               ; preds = %7
  tail call void @_ZN12intersectionC2ERKS_(ptr noundef nonnull align 4 dereferenceable(48) %0, ptr noundef nonnull align 4 dereferenceable(48) %2)
  br label %29

28:                                               ; preds = %3
  tail call void @_ZN12intersectionC2ERKS_(ptr noundef nonnull align 4 dereferenceable(48) %0, ptr noundef nonnull align 4 dereferenceable(48) %1)
  br label %29

29:                                               ; preds = %28, %27, %11
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN12intersectionC2ERKS_(ptr noundef nonnull align 4 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(48)) unnamed_addr #0 align 2

attributes #0 = { inlinehint mustprogress 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 = { mustprogress 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" }

!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 = !{!"_ZTS12intersection", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 12, !12, i64 24}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS4vec3", !7, i64 0, !7, i64 4, !7, i64 8}
!12 = !{!"_ZTS8material", !10, i64 0, !11, i64 4, !7, i64 16, !7, i64 20}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !7, i64 4}
!18 = !{i64 0, i64 4, !15, i64 4, i64 4, !15, i64 8, i64 4, !15}
!19 = !{i64 0, i64 1, !20, i64 4, i64 4, !15, i64 8, i64 4, !15, i64 12, i64 4, !15, i64 16, i64 4, !15, i64 20, i64 4, !15}
!20 = !{!10, !10, i64 0}


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