; LLVM IR from aap/librw :: src/pipeline.ll (ZN2rw7instV3dEiPhPNS_3V3dEjj)

; 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.rw::V3d" = type { float, float, float }

@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw7instV3dEiPhPNS_3V3dEjj = external hidden unnamed_addr constant [54 x i8], align 1

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2rw7instV3dEiPhPNS_3V3dEjj(i32 noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 8
  br i1 %15, label %16, label %35

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

17:                                               ; preds = %31, %16
  %18 = load i32, ptr %11, align 4, !tbaa !5
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = icmp ult i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %34

22:                                               ; preds = %17
  %23 = load ptr, ptr %7, align 8, !tbaa !9
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %23, ptr align 4 %24, i64 12, i1 false)
  %25 = load i32, ptr %10, align 4, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = zext i32 %25 to i64
  %28 = getelementptr inbounds i8, ptr %26, i64 %27
  store ptr %28, ptr %7, align 8, !tbaa !9
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = getelementptr inbounds %"struct.rw::V3d", ptr %29, i32 1
  store ptr %30, ptr %8, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %22
  %32 = load i32, ptr %11, align 4, !tbaa !5
  %33 = add i32 %32, 1
  store i32 %33, ptr %11, align 4, !tbaa !5
  br label %17, !llvm.loop !11

34:                                               ; preds = %21
  br label %82

35:                                               ; preds = %5
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = icmp eq i32 %36, 12
  br i1 %37, label %38, label %80

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

39:                                               ; preds = %76, %38
  %40 = load i32, ptr %12, align 4, !tbaa !5
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = icmp ult i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %79

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = getelementptr inbounds %"struct.rw::V3d", ptr %45, i32 0, i32 2
  %47 = load float, ptr %46, align 4, !tbaa !13
  %48 = fmul float %47, 5.110000e+02
  %49 = fptoui float %48 to i32
  %50 = and i32 %49, 1023
  %51 = shl i32 %50, 22
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = getelementptr inbounds %"struct.rw::V3d", ptr %52, i32 0, i32 1
  %54 = load float, ptr %53, align 4, !tbaa !16
  %55 = fmul float %54, 1.023000e+03
  %56 = fptoui float %55 to i32
  %57 = and i32 %56, 2047
  %58 = shl i32 %57, 11
  %59 = or i32 %51, %58
  %60 = load ptr, ptr %8, align 8, !tbaa !9
  %61 = getelementptr inbounds %"struct.rw::V3d", ptr %60, i32 0, i32 0
  %62 = load float, ptr %61, align 4, !tbaa !17
  %63 = fmul float %62, 1.023000e+03
  %64 = fptoui float %63 to i32
  %65 = and i32 %64, 2047
  %66 = shl i32 %65, 0
  %67 = or i32 %59, %66
  store i32 %67, ptr %13, align 4, !tbaa !5
  %68 = load i32, ptr %13, align 4, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %68, ptr %69, align 4, !tbaa !5
  %70 = load i32, ptr %10, align 4, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !9
  %72 = zext i32 %70 to i64
  %73 = getelementptr inbounds i8, ptr %71, i64 %72
  store ptr %73, ptr %7, align 8, !tbaa !9
  %74 = load ptr, ptr %8, align 8, !tbaa !9
  %75 = getelementptr inbounds %"struct.rw::V3d", ptr %74, i32 1
  store ptr %75, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %76

76:                                               ; preds = %44
  %77 = load i32, ptr %12, align 4, !tbaa !5
  %78 = add i32 %77, 1
  store i32 %78, ptr %12, align 4, !tbaa !5
  br label %39, !llvm.loop !18

79:                                               ; preds = %43
  br label %81

80:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 100, ptr noundef @__PRETTY_FUNCTION__._ZN2rw7instV3dEiPhPNS_3V3dEjj) #5
  unreachable

81:                                               ; preds = %79
  br label %82

82:                                               ; preds = %81, %34
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn nounwind "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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !15, i64 8}
!14 = !{!"_ZTSN2rw3V3dE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !15, i64 4}
!17 = !{!14, !15, i64 0}
!18 = distinct !{!18, !12}


; 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.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw7instV3dEiPhPNS_3V3dEjj = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2rw7instV3dEiPhPNS_3V3dEjj(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #2 {
  switch i32 %0, label %39 [
    i32 8, label %.preheader
    i32 12, label %.preheader25
  ]

.preheader25:                                     ; preds = %5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader25
  %6 = zext i32 %4 to i64
  br label %18

.preheader:                                       ; preds = %5
  %.not34 = icmp eq i32 %3, 0
  br i1 %.not34, label %.loopexit, label %.lr.ph33

.lr.ph33:                                         ; preds = %.preheader
  %7 = zext i32 %4 to i64
  %xtraiter = and i32 %3, 3
  %8 = icmp ult i32 %3, 4
  br i1 %8, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph33.new

.lr.ph33.new:                                     ; preds = %.lr.ph33
  %unroll_iter = and i32 %3, -4
  br label %9

9:                                                ; preds = %9, %.lr.ph33.new
  %.032 = phi ptr [ %1, %.lr.ph33.new ], [ %16, %9 ]
  %.02230 = phi ptr [ %2, %.lr.ph33.new ], [ %17, %9 ]
  %niter = phi i32 [ 0, %.lr.ph33.new ], [ %niter.next.3, %9 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %.032, ptr noundef nonnull align 4 dereferenceable(12) %.02230, i64 12, i1 false)
  %10 = getelementptr inbounds i8, ptr %.032, i64 %7
  %11 = getelementptr inbounds i8, ptr %.02230, i64 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %11, i64 12, i1 false)
  %12 = getelementptr inbounds i8, ptr %10, i64 %7
  %13 = getelementptr inbounds i8, ptr %.02230, i64 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %12, ptr noundef nonnull align 4 dereferenceable(12) %13, i64 12, i1 false)
  %14 = getelementptr inbounds i8, ptr %12, i64 %7
  %15 = getelementptr inbounds i8, ptr %.02230, i64 36
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %14, ptr noundef nonnull align 4 dereferenceable(12) %15, i64 12, i1 false)
  %16 = getelementptr inbounds i8, ptr %14, i64 %7
  %17 = getelementptr inbounds i8, ptr %.02230, i64 48
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit.loopexit.unr-lcssa, label %9, !llvm.loop !5

18:                                               ; preds = %.lr.ph, %18
  %.129 = phi ptr [ %1, %.lr.ph ], [ %36, %18 ]
  %.02028 = phi i32 [ 0, %.lr.ph ], [ %38, %18 ]
  %.12327 = phi ptr [ %2, %.lr.ph ], [ %37, %18 ]
  %19 = getelementptr inbounds i8, ptr %.12327, i64 8
  %20 = load float, ptr %19, align 4, !tbaa !7
  %21 = fmul float %20, 5.110000e+02
  %22 = fptoui float %21 to i32
  %23 = shl i32 %22, 22
  %24 = getelementptr inbounds i8, ptr %.12327, i64 4
  %25 = load float, ptr %24, align 4, !tbaa !12
  %26 = fmul float %25, 1.023000e+03
  %27 = fptoui float %26 to i32
  %28 = shl i32 %27, 11
  %29 = and i32 %28, 4192256
  %30 = or disjoint i32 %29, %23
  %31 = load float, ptr %.12327, align 4, !tbaa !13
  %32 = fmul float %31, 1.023000e+03
  %33 = fptoui float %32 to i32
  %34 = and i32 %33, 2047
  %35 = or disjoint i32 %30, %34
  store i32 %35, ptr %.129, align 4, !tbaa !14
  %36 = getelementptr inbounds i8, ptr %.129, i64 %6
  %37 = getelementptr inbounds i8, ptr %.12327, i64 12
  %38 = add nuw i32 %.02028, 1
  %exitcond.not = icmp eq i32 %38, %3
  br i1 %exitcond.not, label %.loopexit, label %18, !llvm.loop !16

39:                                               ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 100, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw7instV3dEiPhPNS_3V3dEjj) #3
  unreachable

.loopexit.loopexit.unr-lcssa:                     ; preds = %9, %.lr.ph33
  %.032.unr = phi ptr [ %1, %.lr.ph33 ], [ %16, %9 ]
  %.02230.unr = phi ptr [ %2, %.lr.ph33 ], [ %17, %9 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.epil.preheader

.epil.preheader:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.epil.preheader
  %.032.epil = phi ptr [ %40, %.epil.preheader ], [ %.032.unr, %.loopexit.loopexit.unr-lcssa ]
  %.02230.epil = phi ptr [ %41, %.epil.preheader ], [ %.02230.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(12) %.032.epil, ptr noundef nonnull align 4 dereferenceable(12) %.02230.epil, i64 12, i1 false)
  %40 = getelementptr inbounds i8, ptr %.032.epil, i64 %7
  %41 = getelementptr inbounds i8, ptr %.02230.epil, i64 12
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.epil.preheader, !llvm.loop !17

.loopexit:                                        ; preds = %18, %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %.preheader25, %.preheader
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 8}
!8 = !{!"_ZTSN2rw3V3dE", !9, i64 0, !9, i64 4, !9, i64 8}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!8, !9, i64 4}
!13 = !{!8, !9, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !10, i64 0}
!16 = distinct !{!16, !6}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass