; 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 i32 @TPE_vec3Len(i64, i32) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_vec3Normalize(ptr noundef) #1

; 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_vec3Times(i64, i32, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_envSphereInside(i64 %0, i32 %1, i64 %2, i32 %3, i32 noundef %4) #1 {
  %6 = alloca %struct.TPE_Vec3, align 4
  %7 = alloca %struct.TPE_Vec3, align 4
  %8 = alloca { i64, i32 }, align 4
  %9 = alloca %struct.TPE_Vec3, align 4
  %10 = alloca { i64, i32 }, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.TPE_Vec3, align 4
  %13 = alloca { i64, i32 }, align 4
  %14 = alloca { i64, i32 }, align 4
  %15 = alloca { i64, i32 }, align 8
  %16 = alloca i32, align 4
  %17 = alloca { i64, i32 }, align 4
  %18 = alloca i32, align 4
  %19 = alloca { i64, i32 }, align 8
  %20 = alloca %struct.TPE_Vec3, align 4
  %21 = alloca { i64, i32 }, align 4
  %22 = alloca { i64, i32 }, align 8
  %23 = alloca { i64, i32 }, align 4
  %24 = alloca { i64, i32 }, align 4
  %25 = alloca { i64, i32 }, align 8
  %26 = alloca { i64, i32 }, align 8
  %27 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 0
  store i64 %0, ptr %27, align 4
  %28 = getelementptr inbounds { i64, i32 }, ptr %8, i32 0, i32 1
  store i32 %1, ptr %28, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %8, i64 12, i1 false)
  %29 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 0
  store i64 %2, ptr %29, align 4
  %30 = getelementptr inbounds { i64, i32 }, ptr %10, i32 0, i32 1
  store i32 %3, ptr %30, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %10, i64 12, i1 false)
  store i32 %4, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %12) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %7, i64 12, i1 false)
  %31 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 0
  %32 = load i64, ptr %31, align 4
  %33 = getelementptr inbounds { i64, i32 }, ptr %13, i32 0, i32 1
  %34 = load i32, ptr %33, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %9, i64 12, i1 false)
  %35 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 0
  %36 = load i64, ptr %35, align 4
  %37 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 1
  %38 = load i32, ptr %37, align 4
  %39 = call { i64, i32 } @TPE_vec3Minus(i64 %32, i32 %34, i64 %36, i32 %38)
  store { i64, i32 } %39, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 8 %15, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %12, i64 12, i1 false)
  %40 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 0
  %41 = load i64, ptr %40, align 4
  %42 = getelementptr inbounds { i64, i32 }, ptr %17, i32 0, i32 1
  %43 = load i32, ptr %42, align 4
  %44 = call i32 @TPE_vec3Len(i64 %41, i32 %43)
  store i32 %44, ptr %16, align 4, !tbaa !5
  %45 = load i32, ptr %16, align 4, !tbaa !5
  %46 = load i32, ptr %11, align 4, !tbaa !5
  %47 = icmp sge i32 %45, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 12, i1 false), !tbaa.struct !9
  store i32 1, ptr %18, align 4
  br label %79

49:                                               ; preds = %5
  %50 = load i32, ptr %16, align 4, !tbaa !5
  %51 = icmp slt i32 %50, 0
  br i1 %51, label %52, label %62

52:                                               ; preds = %49
  %53 = getelementptr inbounds %struct.TPE_Vec3, ptr %9, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !10
  %55 = load i32, ptr %11, align 4, !tbaa !5
  %56 = add nsw i32 %54, %55
  %57 = getelementptr inbounds %struct.TPE_Vec3, ptr %9, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !12
  %59 = getelementptr inbounds %struct.TPE_Vec3, ptr %9, i32 0, i32 2
  %60 = load i32, ptr %59, align 4, !tbaa !13
  %61 = call { i64, i32 } @TPE_vec3(i32 noundef %56, i32 noundef %58, i32 noundef %60)
  store { i64, i32 } %61, ptr %19, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %19, i64 12, i1 false)
  store i32 1, ptr %18, align 4
  br label %79

62:                                               ; preds = %49
  br label %63

63:                                               ; preds = %62
  call void @TPE_vec3Normalize(ptr noundef %12)
  %64 = load i32, ptr %11, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %12, i64 12, i1 false)
  %65 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 0
  %66 = load i64, ptr %65, align 4
  %67 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 1
  %68 = load i32, ptr %67, align 4
  %69 = call { i64, i32 } @TPE_vec3Times(i64 %66, i32 %68, i32 noundef %64)
  store { i64, i32 } %69, ptr %22, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 8 %22, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %9, i64 12, i1 false)
  %70 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 0
  %71 = load i64, ptr %70, align 4
  %72 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 1
  %73 = load i32, ptr %72, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %20, i64 12, i1 false)
  %74 = getelementptr inbounds { i64, i32 }, ptr %24, i32 0, i32 0
  %75 = load i64, ptr %74, align 4
  %76 = getelementptr inbounds { i64, i32 }, ptr %24, i32 0, i32 1
  %77 = load i32, ptr %76, align 4
  %78 = call { i64, i32 } @TPE_vec3Plus(i64 %71, i32 %73, i64 %75, i32 %77)
  store { i64, i32 } %78, ptr %25, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %25, i64 12, i1 false)
  store i32 1, ptr %18, align 4
  br label %79

79:                                               ; preds = %63, %52, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %12) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %26, ptr align 4 %6, i64 12, i1 false)
  %80 = load { i64, i32 }, ptr %26, align 8
  ret { i64, i32 } %80
}

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

%struct.TPE_Vec3 = type { i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) 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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Len(i64, i32) 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: nounwind uwtable
declare dso_local void @TPE_vec3Normalize(ptr noundef) local_unnamed_addr #0

; 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_vec3Times(i64, i32, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { i64, i32 } @TPE_envSphereInside(i64 %0, i32 %1, i64 %2, i32 %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.TPE_Vec3, align 8
  %.sroa.035.0.extract.trunc = trunc i64 %2 to i32
  %.sroa.4.0.extract.shift = lshr i64 %2, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #2
  %7 = tail call { i64, i32 } @TPE_vec3Minus(i64 %0, i32 %1, i64 %2, i32 %3)
  %.fca.0.extract22 = extractvalue { i64, i32 } %7, 0
  %.fca.1.extract23 = extractvalue { i64, i32 } %7, 1
  store i64 %.fca.0.extract22, ptr %6, align 8
  %.sroa.225.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %.fca.1.extract23, ptr %.sroa.225.0..sroa_idx, align 8
  %8 = tail call i32 @TPE_vec3Len(i64 %.fca.0.extract22, i32 %.fca.1.extract23)
  %.not = icmp slt i32 %8, %4
  br i1 %.not, label %9, label %17

9:                                                ; preds = %5
  %10 = icmp slt i32 %8, 0
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = add nsw i32 %.sroa.035.0.extract.trunc, %4
  %13 = tail call { i64, i32 } @TPE_vec3(i32 noundef %12, i32 noundef %.sroa.4.0.extract.trunc, i32 noundef %3)
  %.fca.0.extract15 = extractvalue { i64, i32 } %13, 0
  %.fca.1.extract16 = extractvalue { i64, i32 } %13, 1
  br label %17

14:                                               ; preds = %9
  call void @TPE_vec3Normalize(ptr noundef nonnull %6)
  %.sroa.011.0.copyload = load i64, ptr %6, align 8
  %.sroa.212.0.copyload = load i32, ptr %.sroa.225.0..sroa_idx, align 8
  %15 = call { i64, i32 } @TPE_vec3Times(i64 %.sroa.011.0.copyload, i32 %.sroa.212.0.copyload, i32 noundef %4)
  %.fca.0.extract7 = extractvalue { i64, i32 } %15, 0
  %.fca.1.extract8 = extractvalue { i64, i32 } %15, 1
  %16 = call { i64, i32 } @TPE_vec3Plus(i64 %2, i32 %3, i64 %.fca.0.extract7, i32 %.fca.1.extract8)
  %.fca.0.extract = extractvalue { i64, i32 } %16, 0
  %.fca.1.extract = extractvalue { i64, i32 } %16, 1
  br label %17

17:                                               ; preds = %5, %14, %11
  %.sroa.048.0 = phi i64 [ %.fca.0.extract15, %11 ], [ %.fca.0.extract, %14 ], [ %0, %5 ]
  %.sroa.449.0 = phi i32 [ %.fca.1.extract16, %11 ], [ %.fca.1.extract, %14 ], [ %1, %5 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #2
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.048.0, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.sroa.449.0, 1
  ret { i64, i32 } %.fca.1.insert
}

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}


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