; 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.b2Body = type { [32 x i8], ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, i32, i32, i32, i16, i8, i8, i8, i8 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

; 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

declare ptr @b2GetWorld(i32 noundef) #3

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

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %33, %17
  %19 = load i32, ptr %7, align 4, !tbaa !13
  %20 = icmp slt i32 %19, 31
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %36

22:                                               ; preds = %18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !13
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !14
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.b2Body, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %7, align 4, !tbaa !13
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [32 x i8], ptr %29, i64 0, i64 %31
  store i8 %27, ptr %32, align 1, !tbaa !14
  br label %33

33:                                               ; preds = %22
  %34 = load i32, ptr %7, align 4, !tbaa !13
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %7, align 4, !tbaa !13
  br label %18, !llvm.loop !15

36:                                               ; preds = %21
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.b2Body, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds [32 x i8], ptr %38, i64 0, i64 31
  store i8 0, ptr %39, align 1, !tbaa !14
  br label %44

40:                                               ; preds = %2
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.b2Body, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds [32 x i8], ptr %42, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %43, i8 0, i64 32, i1 false)
  br label %44

44:                                               ; preds = %40, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #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 = !{!"any pointer", !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 = !{!11, !11, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

declare ptr @b2GetWorld(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @b2Body_SetName(i64 %0, ptr noundef readonly %1) local_unnamed_addr #1 {
  %.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 @b2GetWorld(i32 noundef %4) #3
  %6 = tail call ptr @b2GetBodyFullId(ptr noundef %5, i64 %0)
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %99, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %7 = load i8, ptr %1, align 1, !tbaa !5
  store i8 %7, ptr %6, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %6, i64 1
  store i8 %9, ptr %10, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %6, i64 2
  store i8 %12, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 3
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %6, i64 3
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %6, i64 4
  store i8 %18, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 5
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %6, i64 5
  store i8 %21, ptr %22, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 6
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %6, i64 6
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 7
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %6, i64 7
  store i8 %27, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %6, i64 8
  store i8 %30, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 9
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %6, i64 9
  store i8 %33, ptr %34, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %1, i64 10
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %6, i64 10
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %1, i64 11
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %6, i64 11
  store i8 %39, ptr %40, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %1, i64 12
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %6, i64 12
  store i8 %42, ptr %43, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %1, i64 13
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %6, i64 13
  store i8 %45, ptr %46, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %1, i64 14
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %6, i64 14
  store i8 %48, ptr %49, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %1, i64 15
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %6, i64 15
  store i8 %51, ptr %52, align 1, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %1, i64 16
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %6, i64 16
  store i8 %54, ptr %55, align 1, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %1, i64 17
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %6, i64 17
  store i8 %57, ptr %58, align 1, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %1, i64 18
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %6, i64 18
  store i8 %60, ptr %61, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %1, i64 19
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %6, i64 19
  store i8 %63, ptr %64, align 1, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %1, i64 20
  %66 = load i8, ptr %65, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %6, i64 20
  store i8 %66, ptr %67, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %1, i64 21
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %6, i64 21
  store i8 %69, ptr %70, align 1, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %1, i64 22
  %72 = load i8, ptr %71, align 1, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %6, i64 22
  store i8 %72, ptr %73, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %1, i64 23
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %6, i64 23
  store i8 %75, ptr %76, align 1, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %1, i64 24
  %78 = load i8, ptr %77, align 1, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %6, i64 24
  store i8 %78, ptr %79, align 1, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %1, i64 25
  %81 = load i8, ptr %80, align 1, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %6, i64 25
  store i8 %81, ptr %82, align 1, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %1, i64 26
  %84 = load i8, ptr %83, align 1, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %6, i64 26
  store i8 %84, ptr %85, align 1, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %1, i64 27
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %6, i64 27
  store i8 %87, ptr %88, align 1, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %1, i64 28
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %6, i64 28
  store i8 %90, ptr %91, align 1, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %1, i64 29
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %6, i64 29
  store i8 %93, ptr %94, align 1, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %1, i64 30
  %96 = load i8, ptr %95, align 1, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %6, i64 30
  store i8 %96, ptr %97, align 1, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %6, i64 31
  store i8 0, ptr %98, align 1, !tbaa !5
  br label %100

99:                                               ; preds = %2
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %6, i8 0, i64 32, i1 false)
  br label %100

100:                                              ; preds = %99, %.preheader.preheader
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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