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

; 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.4 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw9uninstV3dEiPNS_3V3dEPhjj = external hidden unnamed_addr constant [56 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 @_ZN2rw9uninstV3dEiPNS_3V3dEPhjj(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
  %14 = alloca [3 x 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
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 8
  br i1 %16, label %17, label %36

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

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

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %35

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

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

35:                                               ; preds = %22
  br label %116

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

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

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

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %113

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  %47 = load i32, ptr %46, align 4, !tbaa !5
  store i32 %47, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #4
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = and i32 %48, 2047
  %50 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  store i32 %49, ptr %50, align 4, !tbaa !5
  %51 = load i32, ptr %13, align 4, !tbaa !5
  %52 = lshr i32 %51, 11
  %53 = and i32 %52, 2047
  %54 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 1
  store i32 %53, ptr %54, align 4, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !5
  %56 = lshr i32 %55, 22
  %57 = and i32 %56, 1023
  %58 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 2
  store i32 %57, ptr %58, align 4, !tbaa !5
  %59 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = and i32 %60, 1024
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %67

63:                                               ; preds = %45
  %64 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = or i32 %65, -2048
  store i32 %66, ptr %64, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %63, %45
  %68 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 1
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = and i32 %69, 1024
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %76

72:                                               ; preds = %67
  %73 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 1
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = or i32 %74, -2048
  store i32 %75, ptr %73, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %72, %67
  %77 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 2
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = and i32 %78, 512
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %85

81:                                               ; preds = %76
  %82 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 2
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = or i32 %83, -1024
  store i32 %84, ptr %82, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %81, %76
  %86 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 0
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = sitofp i32 %87 to float
  %89 = fdiv float %88, 1.023000e+03
  %90 = load ptr, ptr %7, align 8, !tbaa !9
  %91 = getelementptr inbounds %"struct.rw::V3d", ptr %90, i32 0, i32 0
  store float %89, ptr %91, align 4, !tbaa !13
  %92 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 1
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = sitofp i32 %93 to float
  %95 = fdiv float %94, 1.023000e+03
  %96 = load ptr, ptr %7, align 8, !tbaa !9
  %97 = getelementptr inbounds %"struct.rw::V3d", ptr %96, i32 0, i32 1
  store float %95, ptr %97, align 4, !tbaa !16
  %98 = getelementptr inbounds [3 x i32], ptr %14, i64 0, i64 2
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sitofp i32 %99 to float
  %101 = fdiv float %100, 5.110000e+02
  %102 = load ptr, ptr %7, align 8, !tbaa !9
  %103 = getelementptr inbounds %"struct.rw::V3d", ptr %102, i32 0, i32 2
  store float %101, ptr %103, align 4, !tbaa !17
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = load ptr, ptr %8, align 8, !tbaa !9
  %106 = zext i32 %104 to i64
  %107 = getelementptr inbounds i8, ptr %105, i64 %106
  store ptr %107, ptr %8, align 8, !tbaa !9
  %108 = load ptr, ptr %7, align 8, !tbaa !9
  %109 = getelementptr inbounds %"struct.rw::V3d", ptr %108, i32 1
  store ptr %109, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %110

110:                                              ; preds = %85
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = add i32 %111, 1
  store i32 %112, ptr %12, align 4, !tbaa !5
  br label %40, !llvm.loop !18

113:                                              ; preds = %44
  br label %115

114:                                              ; preds = %36
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 130, ptr noundef @__PRETTY_FUNCTION__._ZN2rw9uninstV3dEiPNS_3V3dEPhjj) #5
  unreachable

115:                                              ; preds = %113
  br label %116

116:                                              ; preds = %115, %35
  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 0}
!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 8}
!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.4 = external hidden unnamed_addr constant [34 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw9uninstV3dEiPNS_3V3dEPhjj = external hidden unnamed_addr constant [56 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 @_ZN2rw9uninstV3dEiPNS_3V3dEPhjj(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 %.preheader37
  ]

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

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

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

.lr.ph45:                                         ; 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.ph45.new

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

9:                                                ; preds = %9, %.lr.ph45.new
  %.044 = phi ptr [ %1, %.lr.ph45.new ], [ %17, %9 ]
  %.03042 = phi ptr [ %2, %.lr.ph45.new ], [ %16, %9 ]
  %niter = phi i32 [ 0, %.lr.ph45.new ], [ %niter.next.3, %9 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %.044, ptr noundef nonnull align 1 dereferenceable(12) %.03042, i64 12, i1 false)
  %10 = getelementptr inbounds i8, ptr %.03042, i64 %7
  %11 = getelementptr inbounds i8, ptr %.044, i64 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 1 dereferenceable(12) %10, i64 12, i1 false)
  %12 = getelementptr inbounds i8, ptr %10, i64 %7
  %13 = getelementptr inbounds i8, ptr %.044, i64 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %13, ptr noundef nonnull align 1 dereferenceable(12) %12, i64 12, i1 false)
  %14 = getelementptr inbounds i8, ptr %12, i64 %7
  %15 = getelementptr inbounds i8, ptr %.044, i64 36
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %15, ptr noundef nonnull align 1 dereferenceable(12) %14, i64 12, i1 false)
  %16 = getelementptr inbounds i8, ptr %14, i64 %7
  %17 = getelementptr inbounds i8, ptr %.044, 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
  %.141 = phi ptr [ %1, %.lr.ph ], [ %37, %18 ]
  %.02840 = phi i32 [ 0, %.lr.ph ], [ %38, %18 ]
  %.13139 = phi ptr [ %2, %.lr.ph ], [ %36, %18 ]
  %19 = load i32, ptr %.13139, align 4, !tbaa !7
  %20 = lshr i32 %19, 11
  %21 = lshr i32 %19, 22
  %22 = or disjoint i32 %21, -1024
  %.not3436 = icmp slt i32 %19, 0
  %.sroa.12.0 = select i1 %.not3436, i32 %22, i32 %21
  %23 = insertelement <2 x i32> poison, i32 %19, i64 0
  %24 = insertelement <2 x i32> %23, i32 %20, i64 1
  %25 = and <2 x i32> %24, <i32 2047, i32 2047>
  %26 = shufflevector <2 x i32> %23, <2 x i32> poison, <2 x i32> zeroinitializer
  %27 = and <2 x i32> %26, <i32 1024, i32 2097152>
  %28 = icmp eq <2 x i32> %27, zeroinitializer
  %29 = select <2 x i1> %28, <2 x i32> zeroinitializer, <2 x i32> <i32 -2048, i32 -2048>
  %30 = or disjoint <2 x i32> %29, %25
  %31 = sitofp <2 x i32> %30 to <2 x float>
  %32 = fdiv <2 x float> %31, <float 1.023000e+03, float 1.023000e+03>
  store <2 x float> %32, ptr %.141, align 4, !tbaa !11
  %33 = sitofp i32 %.sroa.12.0 to float
  %34 = fdiv float %33, 5.110000e+02
  %35 = getelementptr inbounds i8, ptr %.141, i64 8
  store float %34, ptr %35, align 4, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %.13139, i64 %6
  %37 = getelementptr inbounds i8, ptr %.141, i64 12
  %38 = add nuw i32 %.02840, 1
  %exitcond.not = icmp eq i32 %38, %3
  br i1 %exitcond.not, label %.loopexit, label %18, !llvm.loop !15

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

.loopexit.loopexit.unr-lcssa:                     ; preds = %9, %.lr.ph45
  %.044.unr = phi ptr [ %1, %.lr.ph45 ], [ %17, %9 ]
  %.03042.unr = phi ptr [ %2, %.lr.ph45 ], [ %16, %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
  %.044.epil = phi ptr [ %41, %.epil.preheader ], [ %.044.unr, %.loopexit.loopexit.unr-lcssa ]
  %.03042.epil = phi ptr [ %40, %.epil.preheader ], [ %.03042.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 4 dereferenceable(12) %.044.epil, ptr noundef nonnull align 1 dereferenceable(12) %.03042.epil, i64 12, i1 false)
  %40 = getelementptr inbounds i8, ptr %.03042.epil, i64 %7
  %41 = getelementptr inbounds i8, ptr %.044.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 !16

.loopexit:                                        ; preds = %18, %.loopexit.loopexit.unr-lcssa, %.epil.preheader, %.preheader37, %.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, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTSN2rw3V3dE", !12, i64 0, !12, i64 4, !12, i64 8}
!15 = distinct !{!15, !6}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}


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