; LLVM IR from erincatto/box2d :: src (body)

; 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.b2BodyId = type { i32, i16, i16 }
%struct.b2BodySim = type { %struct.b2Transform, %struct.b2Vec2, %struct.b2Rot, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, float, float, float, float, i32, i8, i8, i8, i8, i8 }
%struct.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Rot = type { float, float }
%struct.b2Vec2 = type { float, float }

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

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

; Function Attrs: 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 ptr @b2GetBodySim(ptr noundef, ptr noundef) #0

declare ptr @b2GetWorldLocked(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @b2Body_SetBullet(i64 %0, i1 noundef zeroext %1) #0 {
  %3 = alloca %struct.b2BodyId, align 4
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store i64 %0, ptr %3, align 4
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %4, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %10 = getelementptr inbounds %struct.b2BodyId, ptr %3, i32 0, i32 1
  %11 = load i16, ptr %10, align 4, !tbaa !9
  %12 = zext i16 %11 to i32
  %13 = call ptr @b2GetWorldLocked(i32 noundef %12)
  store ptr %13, ptr %5, align 8, !tbaa !13
  %14 = load ptr, ptr %5, align 8, !tbaa !13
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  store i32 1, ptr %6, align 4
  br label %29

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !13
  %19 = load i64, ptr %3, align 4
  %20 = call ptr @b2GetBodyFullId(ptr noundef %18, i64 %19)
  store ptr %20, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !13
  %22 = load ptr, ptr %7, align 8, !tbaa !13
  %23 = call ptr @b2GetBodySim(ptr noundef %21, ptr noundef %22)
  store ptr %23, ptr %8, align 8, !tbaa !13
  %24 = load i8, ptr %4, align 1, !tbaa !5, !range !15, !noundef !16
  %25 = trunc i8 %24 to i1
  %26 = load ptr, ptr %8, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.b2BodySim, ptr %26, i32 0, i32 16
  %28 = zext i1 %25 to i8
  store i8 %28, ptr %27, align 1, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  store i32 0, ptr %6, align 4
  br label %29

29:                                               ; preds = %17, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %30 = load i32, ptr %6, align 4
  switch i32 %30, label %32 [
    i32 0, label %31
    i32 1, label %31
  ]

31:                                               ; preds = %29, %29
  ret void

32:                                               ; preds = %29
  unreachable
}

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 #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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 4}
!10 = !{!"b2BodyId", !11, i64 0, !12, i64 4, !12, i64 6}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !6, i64 93}
!18 = !{!"b2BodySim", !19, i64 0, !20, i64 16, !22, i64 24, !20, i64 32, !20, i64 40, !20, i64 48, !21, i64 56, !21, i64 60, !21, i64 64, !21, i64 68, !21, i64 72, !21, i64 76, !21, i64 80, !21, i64 84, !11, i64 88, !6, i64 92, !6, i64 93, !6, i64 94, !6, i64 95, !6, i64 96}
!19 = !{!"b2Transform", !20, i64 0, !22, i64 8}
!20 = !{!"b2Vec2", !21, i64 0, !21, i64 4}
!21 = !{!"float", !7, i64 0}
!22 = !{!"b2Rot", !21, i64 0, !21, i64 4}


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

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

declare ptr @b2GetWorldLocked(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @b2Body_SetBullet(i64 %0, i1 noundef zeroext %1) local_unnamed_addr #0 {
  %.sroa.2.0.extract.shift = lshr i64 %0, 32
  %3 = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %4 = and i32 %3, 65535
  %5 = tail call ptr @b2GetWorldLocked(i32 noundef %4) #2
  %6 = icmp eq ptr %5, null
  br i1 %6, label %12, label %7

7:                                                ; preds = %2
  %8 = zext i1 %1 to i8
  %9 = tail call ptr @b2GetBodyFullId(ptr noundef nonnull %5, i64 %0)
  %10 = tail call ptr @b2GetBodySim(ptr noundef nonnull %5, ptr noundef %9)
  %11 = getelementptr inbounds i8, ptr %10, i64 93
  store i8 %8, ptr %11, align 1, !tbaa !5
  br label %12

12:                                               ; preds = %2, %7
  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 = { "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, !14, i64 93}
!6 = !{!"b2BodySim", !7, i64 0, !8, i64 16, !12, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !9, i64 56, !9, i64 60, !9, i64 64, !9, i64 68, !9, i64 72, !9, i64 76, !9, i64 80, !9, i64 84, !13, i64 88, !14, i64 92, !14, i64 93, !14, i64 94, !14, i64 95, !14, i64 96}
!7 = !{!"b2Transform", !8, i64 0, !12, i64 8}
!8 = !{!"b2Vec2", !9, i64 0, !9, i64 4}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"b2Rot", !9, i64 0, !9, i64 4}
!13 = !{!"int", !10, i64 0}
!14 = !{!"_Bool", !10, i64 0}


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