; LLVM IR from mtsamis/box2d-optimized :: src/rope/b2_rope.ll (ZNK6b2Rope4DrawEP6b2Draw)

; 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.b2Color = type { float, float, float, float }
%class.b2Rope = type { %struct.b2Vec2, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.b2Vec2, %struct.b2RopeTuning }
%struct.b2Vec2 = type { float, float }
%struct.b2RopeTuning = type <{ i32, i32, float, float, float, float, float, float, float, i8, i8, i8, i8 }>

; 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: mustprogress uwtable
define dso_local void @_ZNK6b2Rope4DrawEP6b2Draw(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.b2Color, align 4
  %6 = alloca %struct.b2Color, align 4
  %7 = alloca %struct.b2Color, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #3
  call void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %5, float noundef 0x3FD99999A0000000, float noundef 5.000000e-01, float noundef 0x3FE6666660000000, float noundef 1.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  call void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %6, float noundef 0x3FB99999A0000000, float noundef 0x3FE99999A0000000, float noundef 0x3FB99999A0000000, float noundef 1.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  call void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %7, float noundef 0x3FE6666660000000, float noundef 0x3FC99999A0000000, float noundef 0x3FD99999A0000000, float noundef 1.000000e+00)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %56, %2
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = sub nsw i32 %15, 1
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %59

19:                                               ; preds = %12
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 7
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %struct.b2Vec2, ptr %22, i64 %24
  %26 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 7
  %27 = load ptr, ptr %26, align 8, !tbaa !19
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds %struct.b2Vec2, ptr %27, i64 %30
  %32 = load ptr, ptr %20, align 8, !tbaa !20
  %33 = getelementptr inbounds ptr, ptr %32, i64 7
  %34 = load ptr, ptr %33, align 8
  call void %34(ptr noundef nonnull align 8 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(8) %25, ptr noundef nonnull align 4 dereferenceable(8) %31, ptr noundef nonnull align 4 dereferenceable(16) %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %35 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 10
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %36, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !23
  %41 = fcmp ogt float %40, 0.000000e+00
  br i1 %41, label %42, label %43

42:                                               ; preds = %19
  br label %44

43:                                               ; preds = %19
  br label %44

44:                                               ; preds = %43, %42
  %45 = phi ptr [ %7, %42 ], [ %6, %43 ]
  store ptr %45, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 7
  %48 = load ptr, ptr %47, align 8, !tbaa !19
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.b2Vec2, ptr %48, i64 %50
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %46, align 8, !tbaa !20
  %54 = getelementptr inbounds ptr, ptr %53, i64 9
  %55 = load ptr, ptr %54, align 8
  call void %55(ptr noundef nonnull align 8 dereferenceable(12) %46, ptr noundef nonnull align 4 dereferenceable(8) %51, float noundef 5.000000e+00, ptr noundef nonnull align 4 dereferenceable(16) %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %56

56:                                               ; preds = %44
  %57 = load i32, ptr %8, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %8, align 4, !tbaa !9
  br label %12, !llvm.loop !24

59:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %60 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 10
  %61 = load ptr, ptr %60, align 8, !tbaa !22
  %62 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 1
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = sub nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds float, ptr %61, i64 %65
  %67 = load float, ptr %66, align 4, !tbaa !23
  %68 = fcmp ogt float %67, 0.000000e+00
  br i1 %68, label %69, label %70

69:                                               ; preds = %59
  br label %71

70:                                               ; preds = %59
  br label %71

71:                                               ; preds = %70, %69
  %72 = phi ptr [ %7, %69 ], [ %6, %70 ]
  store ptr %72, ptr %10, align 8, !tbaa !5
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 7
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  %76 = getelementptr inbounds %class.b2Rope, ptr %11, i32 0, i32 1
  %77 = load i32, ptr %76, align 8, !tbaa !11
  %78 = sub nsw i32 %77, 1
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.b2Vec2, ptr %75, i64 %79
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load ptr, ptr %73, align 8, !tbaa !20
  %83 = getelementptr inbounds ptr, ptr %82, i64 9
  %84 = load ptr, ptr %83, align 8
  call void %84(ptr noundef nonnull align 8 dereferenceable(12) %73, ptr noundef nonnull align 4 dereferenceable(8) %80, float noundef 5.000000e+00, ptr noundef nonnull align 4 dereferenceable(16) %81)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef, float noundef) unnamed_addr #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS6b2Rope", !13, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !15, i64 88}
!13 = !{!"_ZTS6b2Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_ZTS12b2RopeTuning", !16, i64 0, !17, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !18, i64 36, !18, i64 37, !18, i64 38}
!16 = !{!"_ZTS17b2StretchingModel", !7, i64 0}
!17 = !{!"_ZTS14b2BendingModel", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!12, !6, i64 48}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !8, i64 0}
!22 = !{!12, !6, i64 72}
!23 = !{!14, !14, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

%struct.b2Color = type { float, float, float, float }
%struct.b2Vec2 = type { float, float }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK6b2Rope4DrawEP6b2Draw(ptr nocapture noundef nonnull readonly align 8 dereferenceable(128) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %struct.b2Color, align 4
  %4 = alloca %struct.b2Color, align 4
  %5 = alloca %struct.b2Color, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #3
  call void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %3, float noundef 0x3FD99999A0000000, float noundef 5.000000e-01, float noundef 0x3FE6666660000000, float noundef 1.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %4, float noundef 0x3FB99999A0000000, float noundef 0x3FE99999A0000000, float noundef 0x3FB99999A0000000, float noundef 1.000000e+00)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  call void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16) %5, float noundef 0x3FE6666660000000, float noundef 0x3FC99999A0000000, float noundef 0x3FD99999A0000000, float noundef 1.000000e+00)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp sgt i32 %7, 1
  br i1 %8, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %2
  %9 = add nsw i32 %7, -1
  %.pre = sext i32 %9 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 48
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  br label %24

._crit_edge:                                      ; preds = %24, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %42, %24 ]
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %14 = getelementptr inbounds float, ptr %13, i64 %.pre-phi
  %15 = load float, ptr %14, align 4, !tbaa !18
  %16 = fcmp ogt float %15, 0.000000e+00
  %17 = select i1 %16, ptr %5, ptr %4
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = getelementptr inbounds %struct.b2Vec2, ptr %19, i64 %.pre-phi
  %21 = load ptr, ptr %1, align 8, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %21, i64 72
  %23 = load ptr, ptr %22, align 8
  call void %23(ptr noundef nonnull align 8 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(8) %20, float noundef 5.000000e+00, ptr noundef nonnull align 4 dereferenceable(16) %17)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #3
  ret void

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %25 = load ptr, ptr %10, align 8, !tbaa !19
  %26 = getelementptr inbounds %struct.b2Vec2, ptr %25, i64 %indvars.iv
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = getelementptr inbounds %struct.b2Vec2, ptr %25, i64 %indvars.iv.next
  %28 = load ptr, ptr %1, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %28, i64 56
  %30 = load ptr, ptr %29, align 8
  call void %30(ptr noundef nonnull align 8 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(8) %26, ptr noundef nonnull align 4 dereferenceable(8) %27, ptr noundef nonnull align 4 dereferenceable(16) %3)
  %31 = load ptr, ptr %11, align 8, !tbaa !17
  %32 = getelementptr inbounds float, ptr %31, i64 %indvars.iv
  %33 = load float, ptr %32, align 4, !tbaa !18
  %34 = fcmp ogt float %33, 0.000000e+00
  %. = select i1 %34, ptr %5, ptr %4
  %35 = load ptr, ptr %10, align 8, !tbaa !19
  %36 = getelementptr inbounds %struct.b2Vec2, ptr %35, i64 %indvars.iv
  %37 = load ptr, ptr %1, align 8, !tbaa !20
  %38 = getelementptr inbounds i8, ptr %37, i64 72
  %39 = load ptr, ptr %38, align 8
  call void %39(ptr noundef nonnull align 8 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(8) %36, float noundef 5.000000e+00, ptr noundef nonnull align 4 dereferenceable(16) %.)
  %40 = load i32, ptr %6, align 8, !tbaa !5
  %41 = add nsw i32 %40, -1
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %24, label %._crit_edge, !llvm.loop !22
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7b2ColorC2Effff(ptr noundef nonnull align 4 dereferenceable(16), float noundef, float noundef, float noundef, float noundef) unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress 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, !11, i64 8}
!6 = !{!"_ZTS6b2Rope", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !7, i64 80, !13, i64 88}
!7 = !{!"_ZTS6b2Vec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_ZTS12b2RopeTuning", !14, i64 0, !15, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !8, i64 32, !16, i64 36, !16, i64 37, !16, i64 38}
!14 = !{!"_ZTS17b2StretchingModel", !9, i64 0}
!15 = !{!"_ZTS14b2BendingModel", !9, i64 0}
!16 = !{!"bool", !9, i64 0}
!17 = !{!6, !12, i64 72}
!18 = !{!8, !8, i64 0}
!19 = !{!6, !12, i64 48}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !10, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass