; 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_Body = type { ptr, i8, ptr, i8, i16, i16, i16, i8, i8 }
%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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @_TPE_hash(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_jointHash(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_connectionHash(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @TPE_bodyHash(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.TPE_Body, ptr %6, i32 0, i32 4
  %8 = load i16, ptr %7, align 2, !tbaa !9
  %9 = sext i16 %8 to i32
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.TPE_Body, ptr %10, i32 0, i32 7
  %12 = load i8, ptr %11, align 8, !tbaa !12
  %13 = zext i8 %12 to i32
  %14 = shl i32 %13, 16
  %15 = or i32 %9, %14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TPE_Body, ptr %16, i32 0, i32 8
  %18 = load i8, ptr %17, align 1, !tbaa !13
  %19 = zext i8 %18 to i32
  %20 = shl i32 %19, 24
  %21 = or i32 %15, %20
  %22 = call i32 @_TPE_hash(i32 noundef %21)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TPE_Body, ptr %23, i32 0, i32 5
  %25 = load i16, ptr %24, align 4, !tbaa !14
  %26 = sext i16 %25 to i32
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TPE_Body, ptr %27, i32 0, i32 6
  %29 = load i16, ptr %28, align 2, !tbaa !15
  %30 = sext i16 %29 to i32
  %31 = shl i32 %30, 16
  %32 = or i32 %26, %31
  %33 = call i32 @_TPE_hash(i32 noundef %32)
  %34 = xor i32 %22, %33
  store i32 %34, ptr %3, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  store i8 0, ptr %4, align 1, !tbaa !18
  br label %35

35:                                               ; preds = %55, %1
  %36 = load i8, ptr %4, align 1, !tbaa !18
  %37 = zext i8 %36 to i32
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TPE_Body, ptr %38, i32 0, i32 1
  %40 = load i8, ptr %39, align 8, !tbaa !19
  %41 = zext i8 %40 to i32
  %42 = icmp slt i32 %37, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  br label %58

44:                                               ; preds = %35
  %45 = load i32, ptr %3, align 4, !tbaa !16
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.TPE_Body, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  %49 = load i8, ptr %4, align 1, !tbaa !18
  %50 = zext i8 %49 to i64
  %51 = getelementptr inbounds %struct.TPE_Joint, ptr %48, i64 %50
  %52 = call i32 @TPE_jointHash(ptr noundef %51)
  %53 = xor i32 %45, %52
  %54 = call i32 @_TPE_hash(i32 noundef %53)
  store i32 %54, ptr %3, align 4, !tbaa !16
  br label %55

55:                                               ; preds = %44
  %56 = load i8, ptr %4, align 1, !tbaa !18
  %57 = add i8 %56, 1
  store i8 %57, ptr %4, align 1, !tbaa !18
  br label %35, !llvm.loop !21

58:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 0, ptr %5, align 1, !tbaa !18
  br label %59

59:                                               ; preds = %79, %58
  %60 = load i8, ptr %5, align 1, !tbaa !18
  %61 = zext i8 %60 to i32
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TPE_Body, ptr %62, i32 0, i32 3
  %64 = load i8, ptr %63, align 8, !tbaa !23
  %65 = zext i8 %64 to i32
  %66 = icmp slt i32 %61, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  br label %82

68:                                               ; preds = %59
  %69 = load i32, ptr %3, align 4, !tbaa !16
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.TPE_Body, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !24
  %73 = load i8, ptr %5, align 1, !tbaa !18
  %74 = zext i8 %73 to i64
  %75 = getelementptr inbounds %struct.TPE_Connection, ptr %72, i64 %74
  %76 = call i32 @TPE_connectionHash(ptr noundef %75)
  %77 = xor i32 %69, %76
  %78 = call i32 @_TPE_hash(i32 noundef %77)
  store i32 %78, ptr %3, align 4, !tbaa !16
  br label %79

79:                                               ; preds = %68
  %80 = load i8, ptr %5, align 1, !tbaa !18
  %81 = add i8 %80, 1
  store i8 %81, ptr %5, align 1, !tbaa !18
  br label %59, !llvm.loop !25

82:                                               ; preds = %67
  %83 = load i32, ptr %3, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %83
}

attributes #0 = { nocallback nofree nosync 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 = { 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, !11, i64 26}
!10 = !{!"", !6, i64 0, !7, i64 8, !6, i64 16, !7, i64 24, !11, i64 26, !11, i64 28, !11, i64 30, !7, i64 32, !7, i64 33}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !7, i64 32}
!13 = !{!10, !7, i64 33}
!14 = !{!10, !11, i64 28}
!15 = !{!10, !11, i64 30}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!10, !7, i64 8}
!20 = !{!10, !6, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !7, i64 24}
!24 = !{!10, !6, i64 16}
!25 = distinct !{!25, !22}


; 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 }
%struct.TPE_Connection = type { i8, i8, i16 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @_TPE_hash(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_jointHash(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_connectionHash(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @TPE_bodyHash(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 26
  %3 = load i16, ptr %2, align 2, !tbaa !5
  %4 = sext i16 %3 to i32
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load i8, ptr %5, align 8, !tbaa !11
  %7 = zext i8 %6 to i32
  %8 = shl nuw nsw i32 %7, 16
  %9 = or i32 %8, %4
  %10 = getelementptr inbounds i8, ptr %0, i64 33
  %11 = load i8, ptr %10, align 1, !tbaa !12
  %12 = zext i8 %11 to i32
  %13 = shl nuw i32 %12, 24
  %14 = or i32 %9, %13
  %15 = tail call i32 @_TPE_hash(i32 noundef %14)
  %16 = getelementptr inbounds i8, ptr %0, i64 28
  %17 = load i16, ptr %16, align 4, !tbaa !13
  %18 = sext i16 %17 to i32
  %19 = getelementptr inbounds i8, ptr %0, i64 30
  %20 = load i16, ptr %19, align 2, !tbaa !14
  %21 = sext i16 %20 to i32
  %22 = shl nsw i32 %21, 16
  %23 = or i32 %22, %18
  %24 = tail call i32 @_TPE_hash(i32 noundef %23)
  %25 = xor i32 %24, %15
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = load i8, ptr %26, align 8, !tbaa !15
  %.not = icmp eq i8 %27, 0
  br i1 %.not, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %1
  %.018.lcssa = phi i32 [ %25, %1 ], [ %35, %.lr.ph ]
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = load i8, ptr %28, align 8, !tbaa !16
  %.not25 = icmp eq i8 %29, 0
  br i1 %.not25, label %._crit_edge, label %.lr.ph23

.lr.ph23:                                         ; preds = %.preheader
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  br label %39

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %.01819 = phi i32 [ %35, %.lr.ph ], [ %25, %1 ]
  %31 = load ptr, ptr %0, align 8, !tbaa !17
  %32 = getelementptr inbounds %struct.TPE_Joint, ptr %31, i64 %indvars.iv
  %33 = tail call i32 @TPE_jointHash(ptr noundef %32)
  %34 = xor i32 %33, %.01819
  %35 = tail call i32 @_TPE_hash(i32 noundef %34)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %36 = load i8, ptr %26, align 8, !tbaa !15
  %37 = zext i8 %36 to i64
  %38 = icmp ult i64 %indvars.iv.next, %37
  br i1 %38, label %.lr.ph, label %.preheader, !llvm.loop !18

._crit_edge:                                      ; preds = %39, %.preheader
  %.1.lcssa = phi i32 [ %.018.lcssa, %.preheader ], [ %44, %39 ]
  ret i32 %.1.lcssa

39:                                               ; preds = %.lr.ph23, %39
  %indvars.iv28 = phi i64 [ 0, %.lr.ph23 ], [ %indvars.iv.next29, %39 ]
  %.121 = phi i32 [ %.018.lcssa, %.lr.ph23 ], [ %44, %39 ]
  %40 = load ptr, ptr %30, align 8, !tbaa !20
  %41 = getelementptr inbounds %struct.TPE_Connection, ptr %40, i64 %indvars.iv28
  %42 = tail call i32 @TPE_connectionHash(ptr noundef %41)
  %43 = xor i32 %42, %.121
  %44 = tail call i32 @_TPE_hash(i32 noundef %43)
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %45 = load i8, ptr %28, align 8, !tbaa !16
  %46 = zext i8 %45 to i64
  %47 = icmp ult i64 %indvars.iv.next29, %46
  br i1 %47, label %39, label %._crit_edge, !llvm.loop !21
}

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

!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 26}
!6 = !{!"", !7, i64 0, !8, i64 8, !7, i64 16, !8, i64 24, !10, i64 26, !10, i64 28, !10, i64 30, !8, i64 32, !8, i64 33}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !8, i64 32}
!12 = !{!6, !8, i64 33}
!13 = !{!6, !10, i64 28}
!14 = !{!6, !10, i64 30}
!15 = !{!6, !8, i64 8}
!16 = !{!6, !8, i64 24}
!17 = !{!6, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!6, !7, i64 16}
!21 = distinct !{!21, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass