; LLVM IR from ESPboy-edu/ESPboy_tinyphysicsengine :: programs (hello)

; 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.TPE_Vec3 = type { i32, i32, i32 }

; 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) #0

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Minus(i64, i32, i64, i32) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @TPE_abs(i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Plus(i64, i32, i64, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Project(i64, i32, i64, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Dot(i64, i32, i64, i32) #1

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_envLineSegment(i64 %0, i32 %1, i64 %2, i32 %3, i64 %4, i32 %5) #1 {
  %7 = alloca %struct.TPE_Vec3, align 4
  %8 = alloca %struct.TPE_Vec3, align 4
  %9 = alloca { i64, i32 }, align 4
  %10 = alloca %struct.TPE_Vec3, align 4
  %11 = alloca { i64, i32 }, align 4
  %12 = alloca %struct.TPE_Vec3, align 4
  %13 = alloca { i64, i32 }, align 4
  %14 = alloca %struct.TPE_Vec3, align 4
  %15 = alloca { i64, i32 }, align 4
  %16 = alloca { i64, i32 }, align 4
  %17 = alloca { i64, i32 }, align 8
  %18 = alloca %struct.TPE_Vec3, align 4
  %19 = alloca { i64, i32 }, align 4
  %20 = alloca { i64, i32 }, align 4
  %21 = alloca { i64, i32 }, align 8
  %22 = alloca %struct.TPE_Vec3, align 4
  %23 = alloca { i64, i32 }, align 4
  %24 = alloca { i64, i32 }, align 4
  %25 = alloca { i64, i32 }, align 8
  %26 = alloca { i64, i32 }, align 4
  %27 = alloca { i64, i32 }, align 4
  %28 = alloca %struct.TPE_Vec3, align 4
  %29 = alloca { i64, i32 }, align 8
  %30 = alloca %struct.TPE_Vec3, align 4
  %31 = alloca { i64, i32 }, align 4
  %32 = alloca { i64, i32 }, align 4
  %33 = alloca { i64, i32 }, align 8
  %34 = alloca { i64, i32 }, align 8
  %35 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  store i64 %0, ptr %35, align 4
  %36 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  store i32 %1, ptr %36, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %9, i64 12, i1 false)
  %37 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 0
  store i64 %2, ptr %37, align 4
  %38 = getelementptr inbounds { i64, i32 }, ptr %11, i32 0, i32 1
  store i32 %3, ptr %38, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %11, i64 12, i1 false)
  %39 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 0
  store i64 %4, ptr %39, align 4
  %40 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 1
  store i32 %5, ptr %40, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %13, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %8, i64 12, i1 false)
  %41 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %42 = load i64, ptr %41, align 4
  %43 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %44 = load i32, ptr %43, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %10, i64 12, i1 false)
  %45 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 0
  %46 = load i64, ptr %45, align 4
  %47 = getelementptr inbounds { i64, i32 }, ptr %16, i32 0, i32 1
  %48 = load i32, ptr %47, align 4
  %49 = call { i64, i32 } @TPE_vec3Minus(i64 %42, i32 %44, i64 %46, i32 %48)
  store { i64, i32 } %49, ptr %17, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %17, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %14, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %12, i64 12, i1 false)
  %50 = getelementptr inbounds { i64, i32 }, ptr %19, i32 0, i32 0
  %51 = load i64, ptr %50, align 4
  %52 = getelementptr inbounds { i64, i32 }, ptr %19, i32 0, i32 1
  %53 = load i32, ptr %52, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %10, i64 12, i1 false)
  %54 = getelementptr inbounds { i64, i32 }, ptr %20, i32 0, i32 0
  %55 = load i64, ptr %54, align 4
  %56 = getelementptr inbounds { i64, i32 }, ptr %20, i32 0, i32 1
  %57 = load i32, ptr %56, align 4
  %58 = call { i64, i32 } @TPE_vec3Minus(i64 %51, i32 %53, i64 %55, i32 %57)
  store { i64, i32 } %58, ptr %21, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 8 %21, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %18, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 12, ptr %22) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %8, i64 12, i1 false)
  %59 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 0
  %60 = load i64, ptr %59, align 4
  %61 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 1
  %62 = load i32, ptr %61, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %12, i64 12, i1 false)
  %63 = getelementptr inbounds { i64, i32 }, ptr %24, i32 0, i32 0
  %64 = load i64, ptr %63, align 4
  %65 = getelementptr inbounds { i64, i32 }, ptr %24, i32 0, i32 1
  %66 = load i32, ptr %65, align 4
  %67 = call { i64, i32 } @TPE_vec3Project(i64 %60, i32 %62, i64 %64, i32 %66)
  store { i64, i32 } %67, ptr %25, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 8 %25, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %22, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %22) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %8, i64 12, i1 false)
  %68 = getelementptr inbounds { i64, i32 }, ptr %26, i32 0, i32 0
  %69 = load i64, ptr %68, align 4
  %70 = getelementptr inbounds { i64, i32 }, ptr %26, i32 0, i32 1
  %71 = load i32, ptr %70, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %12, i64 12, i1 false)
  %72 = getelementptr inbounds { i64, i32 }, ptr %27, i32 0, i32 0
  %73 = load i64, ptr %72, align 4
  %74 = getelementptr inbounds { i64, i32 }, ptr %27, i32 0, i32 1
  %75 = load i32, ptr %74, align 4
  %76 = call i32 @TPE_vec3Dot(i64 %69, i32 %71, i64 %73, i32 %75)
  %77 = icmp slt i32 %76, 0
  br i1 %77, label %78, label %80

78:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 12, ptr %28) #4
  %79 = call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 0)
  store { i64, i32 } %79, ptr %29, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 8 %29, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %28, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %28) #4
  br label %106

80:                                               ; preds = %6
  %81 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !10
  %83 = call i32 @TPE_abs(i32 noundef %82)
  %84 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !12
  %86 = call i32 @TPE_abs(i32 noundef %85)
  %87 = add nsw i32 %83, %86
  %88 = getelementptr inbounds %struct.TPE_Vec3, ptr %8, i32 0, i32 2
  %89 = load i32, ptr %88, align 4, !tbaa !13
  %90 = call i32 @TPE_abs(i32 noundef %89)
  %91 = add nsw i32 %87, %90
  %92 = getelementptr inbounds %struct.TPE_Vec3, ptr %12, i32 0, i32 0
  %93 = load i32, ptr %92, align 4, !tbaa !10
  %94 = call i32 @TPE_abs(i32 noundef %93)
  %95 = getelementptr inbounds %struct.TPE_Vec3, ptr %12, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !12
  %97 = call i32 @TPE_abs(i32 noundef %96)
  %98 = add nsw i32 %94, %97
  %99 = getelementptr inbounds %struct.TPE_Vec3, ptr %12, i32 0, i32 2
  %100 = load i32, ptr %99, align 4, !tbaa !13
  %101 = call i32 @TPE_abs(i32 noundef %100)
  %102 = add nsw i32 %98, %101
  %103 = icmp sgt i32 %91, %102
  br i1 %103, label %104, label %105

104:                                              ; preds = %80
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %12, i64 12, i1 false), !tbaa.struct !5
  br label %105

105:                                              ; preds = %104, %80
  br label %106

106:                                              ; preds = %105, %78
  call void @llvm.lifetime.start.p0(i64 12, ptr %30) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %31, ptr align 4 %8, i64 12, i1 false)
  %107 = getelementptr inbounds { i64, i32 }, ptr %31, i32 0, i32 0
  %108 = load i64, ptr %107, align 4
  %109 = getelementptr inbounds { i64, i32 }, ptr %31, i32 0, i32 1
  %110 = load i32, ptr %109, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 4 %10, i64 12, i1 false)
  %111 = getelementptr inbounds { i64, i32 }, ptr %32, i32 0, i32 0
  %112 = load i64, ptr %111, align 4
  %113 = getelementptr inbounds { i64, i32 }, ptr %32, i32 0, i32 1
  %114 = load i32, ptr %113, align 4
  %115 = call { i64, i32 } @TPE_vec3Plus(i64 %108, i32 %110, i64 %112, i32 %114)
  store { i64, i32 } %115, ptr %33, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 8 %33, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %30, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 12, ptr %30) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %8, i64 12, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 4 %7, i64 12, i1 false)
  %116 = load { i64, i32 }, ptr %34, align 8
  ret { i64, i32 } %116
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!12 = !{!11, !7, i64 4}
!13 = !{!11, !7, i64 8}


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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Minus(i64, i32, i64, i32) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @TPE_abs(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Plus(i64, i32, i64, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Project(i64, i32, i64, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Dot(i64, i32, i64, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_envLineSegment(i64 %0, i32 %1, i64 %2, i32 %3, i64 %4, i32 %5) local_unnamed_addr #0 {
  %7 = tail call { i64, i32 } @TPE_vec3Minus(i64 %0, i32 %1, i64 %2, i32 %3)
  %.fca.0.extract38 = extractvalue { i64, i32 } %7, 0
  %.fca.1.extract39 = extractvalue { i64, i32 } %7, 1
  %8 = tail call { i64, i32 } @TPE_vec3Minus(i64 %4, i32 %5, i64 %2, i32 %3)
  %.fca.0.extract28 = extractvalue { i64, i32 } %8, 0
  %.fca.1.extract29 = extractvalue { i64, i32 } %8, 1
  %9 = tail call { i64, i32 } @TPE_vec3Project(i64 %.fca.0.extract38, i32 %.fca.1.extract39, i64 %.fca.0.extract28, i32 %.fca.1.extract29)
  %.fca.0.extract18 = extractvalue { i64, i32 } %9, 0
  %.fca.1.extract19 = extractvalue { i64, i32 } %9, 1
  %10 = tail call i32 @TPE_vec3Dot(i64 %.fca.0.extract18, i32 %.fca.1.extract19, i64 %.fca.0.extract28, i32 %.fca.1.extract29)
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %6
  %13 = tail call { i64, i32 } @TPE_vec3(i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %.fca.0.extract8 = extractvalue { i64, i32 } %13, 0
  %.fca.1.extract9 = extractvalue { i64, i32 } %13, 1
  %.sroa.088.sroa.12.0.extract.shift110 = lshr i64 %.fca.0.extract8, 32
  br label %27

14:                                               ; preds = %6
  %.sroa.088.sroa.0.0.extract.trunc100 = trunc i64 %.fca.0.extract18 to i32
  %.sroa.088.sroa.12.0.extract.shift120 = lshr i64 %.fca.0.extract18, 32
  %.sroa.088.sroa.12.0.extract.trunc121 = trunc nuw i64 %.sroa.088.sroa.12.0.extract.shift120 to i32
  %.sroa.050.sroa.0.0.extract.trunc = trunc i64 %.fca.0.extract28 to i32
  %.sroa.050.sroa.7.0.extract.shift = lshr i64 %.fca.0.extract28, 32
  %.sroa.050.sroa.7.0.extract.trunc = trunc nuw i64 %.sroa.050.sroa.7.0.extract.shift to i32
  %15 = tail call i32 @TPE_abs(i32 noundef %.sroa.088.sroa.0.0.extract.trunc100)
  %16 = tail call i32 @TPE_abs(i32 noundef %.sroa.088.sroa.12.0.extract.trunc121)
  %17 = add nsw i32 %16, %15
  %18 = tail call i32 @TPE_abs(i32 noundef %.fca.1.extract19)
  %19 = add nsw i32 %17, %18
  %20 = tail call i32 @TPE_abs(i32 noundef %.sroa.050.sroa.0.0.extract.trunc)
  %21 = tail call i32 @TPE_abs(i32 noundef %.sroa.050.sroa.7.0.extract.trunc)
  %22 = add nsw i32 %21, %20
  %23 = tail call i32 @TPE_abs(i32 noundef %.fca.1.extract29)
  %24 = add nsw i32 %22, %23
  %25 = icmp sgt i32 %19, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %14
  br label %27

27:                                               ; preds = %14, %26, %12
  %.sroa.13.0 = phi i32 [ %.fca.1.extract9, %12 ], [ %.fca.1.extract29, %26 ], [ %.fca.1.extract19, %14 ]
  %.sroa.088.sroa.0.0 = phi i64 [ %.fca.0.extract8, %12 ], [ %.fca.0.extract28, %26 ], [ %.fca.0.extract18, %14 ]
  %.sroa.088.sroa.12.0 = phi i64 [ %.sroa.088.sroa.12.0.extract.shift110, %12 ], [ %.sroa.050.sroa.7.0.extract.shift, %26 ], [ %.sroa.088.sroa.12.0.extract.shift120, %14 ]
  %.sroa.088.sroa.12.0.insert.shift = shl nuw i64 %.sroa.088.sroa.12.0, 32
  %.sroa.088.sroa.0.0.insert.ext = and i64 %.sroa.088.sroa.0.0, 4294967295
  %.sroa.088.sroa.0.0.insert.insert = or disjoint i64 %.sroa.088.sroa.12.0.insert.shift, %.sroa.088.sroa.0.0.insert.ext
  %28 = tail call { i64, i32 } @TPE_vec3Plus(i64 %.sroa.088.sroa.0.0.insert.insert, i32 %.sroa.13.0, i64 %2, i32 %3)
  ret { i64, i32 } %28
}

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 = { inlinehint 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" }

!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)"}


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