; LLVM IR from jordan4ibanez/tinyphysicsengine :: old (test)

; 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 { i8, [3 x i32], [2 x ptr], i8, i32, %struct.TPE_Vec4, %struct.TPE_Vec4, %struct.TPE_RotationState, i32, i8 }
%struct.TPE_Vec4 = type { i32, i32, i32, i32 }
%struct.TPE_RotationState = type { %struct.TPE_Vec4, %struct.TPE_Vec4, i32 }

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_vec3Add(i64, i64, i64, i64, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @TPE_bodyStep(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.TPE_Body, ptr %3, i32 0, i32 4
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = icmp ne i32 %5, 2147483647
  br i1 %6, label %7, label %32

7:                                                ; preds = %1
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.TPE_Body, ptr %8, i32 0, i32 5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.TPE_Body, ptr %10, i32 0, i32 6
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.TPE_Body, ptr %12, i32 0, i32 5
  %14 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %17 = load i64, ptr %16, align 8
  %18 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %21 = load i64, ptr %20, align 8
  call void @TPE_vec3Add(i64 %15, i64 %17, i64 %19, i64 %21, ptr noundef %13)
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.TPE_Body, ptr %22, i32 0, i32 7
  %24 = getelementptr inbounds %struct.TPE_RotationState, ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds %struct.TPE_Vec4, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TPE_Body, ptr %27, i32 0, i32 7
  %29 = getelementptr inbounds %struct.TPE_RotationState, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !15
  %31 = add nsw i32 %30, %26
  store i32 %31, ptr %29, align 8, !tbaa !15
  br label %32

32:                                               ; preds = %7, %1
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TPE_Body, ptr %33, i32 0, i32 9
  %35 = load i8, ptr %34, align 8, !tbaa !16
  %36 = zext i8 %35 to i32
  %37 = and i32 %36, 127
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %39, label %64

39:                                               ; preds = %32
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.TPE_Body, ptr %40, i32 0, i32 9
  %42 = load i8, ptr %41, align 8, !tbaa !16
  %43 = zext i8 %42 to i32
  %44 = and i32 %43, 128
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.TPE_Body, ptr %45, i32 0, i32 9
  %47 = load i8, ptr %46, align 8, !tbaa !16
  %48 = zext i8 %47 to i32
  %49 = and i32 %48, 127
  %50 = sub nsw i32 %49, 1
  %51 = or i32 %44, %50
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TPE_Body, ptr %53, i32 0, i32 9
  store i8 %52, ptr %54, align 8, !tbaa !16
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.TPE_Body, ptr %55, i32 0, i32 9
  %57 = load i8, ptr %56, align 8, !tbaa !16
  %58 = zext i8 %57 to i32
  %59 = icmp eq i32 %58, 128
  br i1 %59, label %60, label %63

60:                                               ; preds = %39
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.TPE_Body, ptr %61, i32 0, i32 9
  store i8 0, ptr %62, align 8, !tbaa !16
  br label %63

63:                                               ; preds = %60, %39
  br label %64

64:                                               ; preds = %63, %32
  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" }

!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 36}
!10 = !{!"", !7, i64 0, !7, i64 4, !7, i64 16, !7, i64 32, !11, i64 36, !12, i64 40, !12, i64 56, !13, i64 72, !11, i64 108, !7, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!13 = !{!"", !12, i64 0, !12, i64 16, !11, i64 32}
!14 = !{!10, !11, i64 100}
!15 = !{!10, !11, i64 104}
!16 = !{!10, !7, i64 112}


; 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 void @TPE_vec3Add(i64, i64, i64, i64, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @TPE_bodyStep(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 36
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 2147483647
  br i1 %.not, label %18, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load i64, ptr %5, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load i64, ptr %8, align 8
  %10 = load i64, ptr %6, align 8
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load i64, ptr %11, align 8
  tail call void @TPE_vec3Add(i64 %7, i64 %9, i64 %10, i64 %12, ptr noundef nonnull %5)
  %13 = getelementptr inbounds i8, ptr %0, i64 100
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %0, i64 104
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = add nsw i32 %16, %14
  store i32 %17, ptr %15, align 8, !tbaa !13
  br label %18

18:                                               ; preds = %4, %1
  %19 = getelementptr inbounds i8, ptr %0, i64 112
  %20 = load i8, ptr %19, align 8, !tbaa !14
  %21 = zext i8 %20 to i32
  %22 = and i32 %21, 127
  %.not12 = icmp eq i32 %22, 0
  br i1 %.not12, label %30, label %23

23:                                               ; preds = %18
  %24 = and i32 %21, 128
  %25 = add nuw nsw i32 %22, 255
  %26 = or i32 %25, %24
  %27 = trunc i32 %26 to i8
  %28 = and i32 %26, 255
  %29 = icmp eq i32 %28, 128
  %spec.store.select = select i1 %29, i8 0, i8 %27
  store i8 %spec.store.select, ptr %19, align 8
  br label %30

30:                                               ; preds = %23, %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" }

!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, !9, i64 36}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 16, !7, i64 32, !9, i64 36, !10, i64 40, !10, i64 56, !11, i64 72, !9, i64 108, !7, i64 112}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12}
!11 = !{!"", !10, i64 0, !10, i64 16, !9, i64 32}
!12 = !{!6, !9, i64 100}
!13 = !{!6, !9, i64 104}
!14 = !{!6, !7, i64 112}


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