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

@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [59 x i8], align 1

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

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #2

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

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

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

declare zeroext i1 @b2IsValidFloat(float noundef) #1

declare ptr @b2GetWorldLocked(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @b2Body_SetAngularDamping(i64 %0, float noundef %1) #0 {
  %3 = alloca %struct.b2BodyId, align 4
  %4 = alloca float, align 4
  %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
  store float %1, ptr %4, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %2
  %10 = load float, ptr %4, align 4, !tbaa !5
  %11 = call zeroext i1 @b2IsValidFloat(float noundef %10)
  br i1 %11, label %12, label %15

12:                                               ; preds = %9
  %13 = load float, ptr %4, align 4, !tbaa !5
  %14 = fcmp oge float %13, 0.000000e+00
  br i1 %14, label %19, label %15

15:                                               ; preds = %12, %9
  %16 = call i32 @b2InternalAssertFcn(ptr noundef @.str.36, ptr noundef @.str.1, i32 noundef 1417)
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  call void @llvm.trap()
  br label %19

19:                                               ; preds = %18, %15, %12
  br label %20

20:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %21 = getelementptr inbounds %struct.b2BodyId, ptr %3, i32 0, i32 1
  %22 = load i16, ptr %21, align 4, !tbaa !9
  %23 = zext i16 %22 to i32
  %24 = call ptr @b2GetWorldLocked(i32 noundef %23)
  store ptr %24, ptr %5, align 8, !tbaa !13
  %25 = load ptr, ptr %5, align 8, !tbaa !13
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %20
  store i32 1, ptr %6, align 4
  br label %38

28:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %29 = load ptr, ptr %5, align 8, !tbaa !13
  %30 = load i64, ptr %3, align 4
  %31 = call ptr @b2GetBodyFullId(ptr noundef %29, i64 %30)
  store ptr %31, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %32 = load ptr, ptr %5, align 8, !tbaa !13
  %33 = load ptr, ptr %7, align 8, !tbaa !13
  %34 = call ptr @b2GetBodySim(ptr noundef %32, ptr noundef %33)
  store ptr %34, ptr %8, align 8, !tbaa !13
  %35 = load float, ptr %4, align 4, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.b2BodySim, ptr %36, i32 0, i32 12
  store float %35, ptr %37, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  store i32 0, ptr %6, align 4
  br label %38

38:                                               ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  %39 = load i32, ptr %6, align 4
  switch i32 %39, label %41 [
    i32 0, label %40
    i32 1, label %40
  ]

40:                                               ; preds = %38, %38
  ret void

41:                                               ; preds = %38
  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 = { "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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{!"float", !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 = !{!16, !6, i64 80}
!16 = !{!"b2BodySim", !17, i64 0, !18, i64 16, !19, i64 24, !18, i64 32, !18, i64 40, !18, i64 48, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !11, i64 88, !20, i64 92, !20, i64 93, !20, i64 94, !20, i64 95, !20, i64 96}
!17 = !{!"b2Transform", !18, i64 0, !19, i64 8}
!18 = !{!"b2Vec2", !6, i64 0, !6, i64 4}
!19 = !{!"b2Rot", !6, i64 0, !6, i64 4}
!20 = !{!"_Bool", !7, i64 0}


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

@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [59 x i8], align 1

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

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #2

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

declare zeroext i1 @b2IsValidFloat(float noundef) local_unnamed_addr #1

declare ptr @b2GetWorldLocked(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @b2Body_SetAngularDamping(i64 %0, float noundef %1) local_unnamed_addr #0 {
  %.sroa.2.0.extract.shift = lshr i64 %0, 32
  %3 = tail call zeroext i1 @b2IsValidFloat(float noundef %1) #3
  %4 = fcmp oge float %1, 0.000000e+00
  %or.cond = and i1 %4, %3
  br i1 %or.cond, label %8, label %5

5:                                                ; preds = %2
  %6 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.1, i32 noundef 1417) #3
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %5
  tail call void @llvm.trap()
  unreachable

8:                                                ; preds = %5, %2
  %9 = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %10 = and i32 %9, 65535
  %11 = tail call ptr @b2GetWorldLocked(i32 noundef %10) #3
  %12 = icmp eq ptr %11, null
  br i1 %12, label %17, label %13

13:                                               ; preds = %8
  %14 = tail call ptr @b2GetBodyFullId(ptr noundef nonnull %11, i64 %0)
  %15 = tail call ptr @b2GetBodySim(ptr noundef nonnull %11, ptr noundef %14)
  %16 = getelementptr inbounds i8, ptr %15, i64 80
  store float %1, ptr %16, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %8, %13
  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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
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, !9, i64 80}
!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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass