; LLVM IR from erincatto/box2d :: shared (benchmarks)

; 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.RainData = type { [30 x %struct.Group], float, i32, i32, i32 }
%struct.Group = type { [2 x %struct.Human] }
%struct.Human = type { [11 x %struct.Bone], float, i8 }
%struct.Bone = type { %struct.b2BodyId, %struct.b2JointId, float, i32 }
%struct.b2BodyId = type { i32, i16, i16 }
%struct.b2JointId = type { i32, i16, i16 }
%struct.b2WorldId = type { i16, i16 }

@g_rainData = external dso_local global %struct.RainData, align 4

; 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 void @CreateGroup(i32, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @DestroyGroup(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local float @StepRain(i32 %0, i32 noundef %1) #2 {
  %3 = alloca %struct.b2WorldId, align 2
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 2
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 31, ptr %5, align 4, !tbaa !5
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = and i32 %8, %9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %49

12:                                               ; preds = %2
  %13 = load i32, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 3), align 4, !tbaa !9
  %14 = icmp slt i32 %13, 10
  br i1 %14, label %15, label %30

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %24, %15
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp slt i32 %17, 3
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %27

20:                                               ; preds = %16
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 3), align 4, !tbaa !9
  %23 = load i32, ptr %3, align 2
  call void @CreateGroup(i32 %23, i32 noundef %21, i32 noundef %22)
  br label %24

24:                                               ; preds = %20
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %6, align 4, !tbaa !5
  br label %16, !llvm.loop !12

27:                                               ; preds = %19
  %28 = load i32, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 3), align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 3), align 4, !tbaa !9
  br label %48

30:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %41, %30
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 3
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %44

35:                                               ; preds = %31
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load i32, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 4), align 4, !tbaa !14
  call void @DestroyGroup(i32 noundef %36, i32 noundef %37)
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 4), align 4, !tbaa !14
  %40 = load i32, ptr %3, align 2
  call void @CreateGroup(i32 %40, i32 noundef %38, i32 noundef %39)
  br label %41

41:                                               ; preds = %35
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %7, align 4, !tbaa !5
  br label %31, !llvm.loop !15

44:                                               ; preds = %34
  %45 = load i32, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 4), align 4, !tbaa !14
  %46 = add nsw i32 %45, 1
  %47 = srem i32 %46, 10
  store i32 %47, ptr getelementptr inbounds (%struct.RainData, ptr @g_rainData, i32 0, i32 4), align 4, !tbaa !14
  br label %48

48:                                               ; preds = %44, %27
  br label %49

49:                                               ; preds = %48, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float 0.000000e+00
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16328}
!10 = !{!"RainData", !7, i64 0, !11, i64 16320, !6, i64 16324, !6, i64 16328, !6, i64 16332}
!11 = !{!"float", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 16332}
!15 = distinct !{!15, !13}


; 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.RainData = type { [30 x %struct.Group], float, i32, i32, i32 }
%struct.Group = type { [2 x %struct.Human] }
%struct.Human = type { [11 x %struct.Bone], float, i8 }
%struct.Bone = type { %struct.b2BodyId, %struct.b2JointId, float, i32 }
%struct.b2BodyId = type { i32, i16, i16 }
%struct.b2JointId = type { i32, i16, i16 }

@g_rainData = external dso_local local_unnamed_addr global %struct.RainData, align 4

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

; Function Attrs: nounwind uwtable
declare dso_local void @DestroyGroup(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef float @StepRain(i32 %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = and i32 %1, 31
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %5, label %21

5:                                                ; preds = %2
  %6 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16328), align 4, !tbaa !5
  %7 = icmp slt i32 %6, 10
  br i1 %7, label %.preheader.preheader, label %.preheader11.preheader

.preheader11.preheader:                           ; preds = %5
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  tail call void @DestroyGroup(i32 noundef 0, i32 noundef %8)
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  tail call void @CreateGroup(i32 %0, i32 noundef 0, i32 noundef %9)
  %10 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  tail call void @DestroyGroup(i32 noundef 1, i32 noundef %10)
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  tail call void @CreateGroup(i32 %0, i32 noundef 1, i32 noundef %11)
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  tail call void @DestroyGroup(i32 noundef 2, i32 noundef %12)
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  tail call void @CreateGroup(i32 %0, i32 noundef 2, i32 noundef %13)
  %14 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  %15 = add nsw i32 %14, 1
  %16 = srem i32 %15, 10
  store i32 %16, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16332), align 4, !tbaa !11
  br label %21

.preheader.preheader:                             ; preds = %5
  tail call void @CreateGroup(i32 %0, i32 noundef 0, i32 noundef %6)
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16328), align 4, !tbaa !5
  tail call void @CreateGroup(i32 %0, i32 noundef 1, i32 noundef %17)
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16328), align 4, !tbaa !5
  tail call void @CreateGroup(i32 %0, i32 noundef 2, i32 noundef %18)
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16328), align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr getelementptr inbounds (i8, ptr @g_rainData, i64 16328), align 4, !tbaa !5
  br label %21

21:                                               ; preds = %.preheader.preheader, %.preheader11.preheader, %2
  ret float 0.000000e+00
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { 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 16328}
!6 = !{!"RainData", !7, i64 0, !9, i64 16320, !10, i64 16324, !10, i64 16328, !10, i64 16332}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"float", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!6, !10, i64 16332}


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