; 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_Joint = type { %struct.TPE_Vec3, [3 x i16], i8 }
%struct.TPE_Vec3 = type { i32, i32, i32 }
%struct.TPE_Connection = type { i8, i8, i16 }

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_joint(ptr dead_on_unwind noalias writable sret(%struct.TPE_Joint) align 4, i64, i32, i32 noundef) #0

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

; 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
define dso_local void @TPE_makeRect(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca %struct.TPE_Joint, align 4
  %13 = alloca %struct.TPE_Vec3, align 4
  %14 = alloca { i64, i32 }, align 8
  %15 = alloca { i64, i32 }, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = sdiv i32 %16, 2
  store i32 %17, ptr %8, align 4, !tbaa !9
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = sdiv i32 %18, 2
  store i32 %19, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  store i8 0, ptr %11, align 1, !tbaa !11
  br label %20

20:                                               ; preds = %58, %5
  %21 = load i8, ptr %11, align 1, !tbaa !11
  %22 = zext i8 %21 to i32
  %23 = icmp slt i32 %22, 4
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  br label %61

25:                                               ; preds = %20
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load i8, ptr %11, align 1, !tbaa !11
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds %struct.TPE_Joint, ptr %26, i64 %28
  call void @llvm.lifetime.start.p0(i64 20, ptr %12) #3
  %30 = load i8, ptr %11, align 1, !tbaa !11
  %31 = zext i8 %30 to i32
  %32 = srem i32 %31, 2
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %25
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = mul nsw i32 -1, %35
  br label %39

37:                                               ; preds = %25
  %38 = load i32, ptr %8, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %37, %34
  %40 = phi i32 [ %36, %34 ], [ %38, %37 ]
  %41 = load i8, ptr %11, align 1, !tbaa !11
  %42 = zext i8 %41 to i32
  %43 = sdiv i32 %42, 2
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %48

45:                                               ; preds = %39
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = mul nsw i32 -1, %46
  br label %50

48:                                               ; preds = %39
  %49 = load i32, ptr %9, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %48, %45
  %51 = phi i32 [ %47, %45 ], [ %49, %48 ]
  %52 = call { i64, i32 } @TPE_vec3(i32 noundef %40, i32 noundef 0, i32 noundef %51)
  store { i64, i32 } %52, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %14, i64 12, i1 false)
  %53 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %13, i64 12, i1 false)
  %54 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %55 = load i64, ptr %54, align 4
  %56 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %57 = load i32, ptr %56, align 4
  call void @TPE_joint(ptr dead_on_unwind writable sret(%struct.TPE_Joint) align 4 %12, i64 %55, i32 %57, i32 noundef %53)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 4 %12, i64 20, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 20, ptr %12) #3
  br label %58

58:                                               ; preds = %50
  %59 = load i8, ptr %11, align 1, !tbaa !11
  %60 = add i8 %59, 1
  store i8 %60, ptr %11, align 1, !tbaa !11
  br label %20, !llvm.loop !13

61:                                               ; preds = %24
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TPE_Connection, ptr %62, i64 0
  %64 = getelementptr inbounds %struct.TPE_Connection, ptr %63, i32 0, i32 0
  store i8 0, ptr %64, align 2, !tbaa !15
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.TPE_Connection, ptr %65, i64 0
  %67 = getelementptr inbounds %struct.TPE_Connection, ptr %66, i32 0, i32 1
  store i8 1, ptr %67, align 1, !tbaa !18
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TPE_Connection, ptr %68, i64 1
  %70 = getelementptr inbounds %struct.TPE_Connection, ptr %69, i32 0, i32 0
  store i8 0, ptr %70, align 2, !tbaa !15
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TPE_Connection, ptr %71, i64 1
  %73 = getelementptr inbounds %struct.TPE_Connection, ptr %72, i32 0, i32 1
  store i8 2, ptr %73, align 1, !tbaa !18
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.TPE_Connection, ptr %74, i64 2
  %76 = getelementptr inbounds %struct.TPE_Connection, ptr %75, i32 0, i32 0
  store i8 3, ptr %76, align 2, !tbaa !15
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.TPE_Connection, ptr %77, i64 2
  %79 = getelementptr inbounds %struct.TPE_Connection, ptr %78, i32 0, i32 1
  store i8 1, ptr %79, align 1, !tbaa !18
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TPE_Connection, ptr %80, i64 3
  %82 = getelementptr inbounds %struct.TPE_Connection, ptr %81, i32 0, i32 0
  store i8 3, ptr %82, align 2, !tbaa !15
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TPE_Connection, ptr %83, i64 3
  %85 = getelementptr inbounds %struct.TPE_Connection, ptr %84, i32 0, i32 1
  store i8 2, ptr %85, align 1, !tbaa !18
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.TPE_Connection, ptr %86, i64 4
  %88 = getelementptr inbounds %struct.TPE_Connection, ptr %87, i32 0, i32 0
  store i8 0, ptr %88, align 2, !tbaa !15
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.TPE_Connection, ptr %89, i64 4
  %91 = getelementptr inbounds %struct.TPE_Connection, ptr %90, i32 0, i32 1
  store i8 3, ptr %91, align 1, !tbaa !18
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.TPE_Connection, ptr %92, i64 5
  %94 = getelementptr inbounds %struct.TPE_Connection, ptr %93, i32 0, i32 0
  store i8 1, ptr %94, align 2, !tbaa !15
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.TPE_Connection, ptr %95, i64 5
  %97 = getelementptr inbounds %struct.TPE_Connection, ptr %96, i32 0, i32 1
  store i8 2, ptr %97, align 1, !tbaa !18
  ret void
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 6, !11, i64 18, i64 1, !11}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !7, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 1, !17, i64 2}
!17 = !{!"short", !7, i64 0}
!18 = !{!16, !7, i64 1}


; 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_Joint = type { %struct.TPE_Vec3, [3 x i16], i8 }
%struct.TPE_Vec3 = type { i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_joint(ptr dead_on_unwind noalias writable sret(%struct.TPE_Joint) align 4, i64, i32, i32 noundef) local_unnamed_addr #0

; 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: 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) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @TPE_makeRect(ptr nocapture noundef writeonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.TPE_Joint, align 4
  %7 = sdiv i32 %2, 2
  %8 = sdiv i32 %3, 2
  %9 = sub nsw i32 0, %7
  %10 = sub nsw i32 0, %8
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %6) #3
  %11 = tail call { i64, i32 } @TPE_vec3(i32 noundef %7, i32 noundef 0, i32 noundef %8)
  %.fca.0.extract = extractvalue { i64, i32 } %11, 0
  %.fca.1.extract = extractvalue { i64, i32 } %11, 1
  call void @TPE_joint(ptr dead_on_unwind nonnull writable sret(%struct.TPE_Joint) align 4 %6, i64 %.fca.0.extract, i32 %.fca.1.extract, i32 noundef %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef nonnull align 4 dereferenceable(20) %6, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %6) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 20
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %6) #3
  %13 = call { i64, i32 } @TPE_vec3(i32 noundef %9, i32 noundef 0, i32 noundef %8)
  %.fca.0.extract.1 = extractvalue { i64, i32 } %13, 0
  %.fca.1.extract.1 = extractvalue { i64, i32 } %13, 1
  call void @TPE_joint(ptr dead_on_unwind nonnull writable sret(%struct.TPE_Joint) align 4 %6, i64 %.fca.0.extract.1, i32 %.fca.1.extract.1, i32 noundef %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %12, ptr noundef nonnull align 4 dereferenceable(20) %6, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %6) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %6) #3
  %15 = call { i64, i32 } @TPE_vec3(i32 noundef %7, i32 noundef 0, i32 noundef %10)
  %.fca.0.extract.2 = extractvalue { i64, i32 } %15, 0
  %.fca.1.extract.2 = extractvalue { i64, i32 } %15, 1
  call void @TPE_joint(ptr dead_on_unwind nonnull writable sret(%struct.TPE_Joint) align 4 %6, i64 %.fca.0.extract.2, i32 %.fca.1.extract.2, i32 noundef %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %14, ptr noundef nonnull align 4 dereferenceable(20) %6, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %6) #3
  %16 = getelementptr inbounds i8, ptr %0, i64 60
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %6) #3
  %17 = call { i64, i32 } @TPE_vec3(i32 noundef %9, i32 noundef 0, i32 noundef %10)
  %.fca.0.extract.3 = extractvalue { i64, i32 } %17, 0
  %.fca.1.extract.3 = extractvalue { i64, i32 } %17, 1
  call void @TPE_joint(ptr dead_on_unwind nonnull writable sret(%struct.TPE_Joint) align 4 %6, i64 %.fca.0.extract.3, i32 %.fca.1.extract.3, i32 noundef %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %16, ptr noundef nonnull align 4 dereferenceable(20) %6, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %6) #3
  store i8 0, ptr %1, align 2, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 1, ptr %18, align 1, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 0, ptr %19, align 2, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 2, ptr %20, align 1, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 3, ptr %21, align 2, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 1, ptr %22, align 1, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 3, ptr %23, align 2, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 2, ptr %24, align 1, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  store i8 0, ptr %25, align 2, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %1, i64 17
  store i8 3, ptr %26, align 1, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %1, i64 20
  store i8 1, ptr %27, align 2, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %1, i64 21
  store i8 2, ptr %28, align 1, !tbaa !14
  ret void
}

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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 6, !10, i64 18, i64 1, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !8, i64 0}
!12 = !{!"", !8, i64 0, !8, i64 1, !13, i64 2}
!13 = !{!"short", !8, i64 0}
!14 = !{!12, !8, i64 1}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass