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

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

@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw13instTexCoordsEiPhPNS_9TexCoordsEjj = external hidden unnamed_addr constant [66 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 @_ZN2rw13instTexCoordsEiPhPNS_9TexCoordsEjj(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
  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
  %12 = load i32, ptr %6, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 7
  br i1 %13, label %14, label %15

14:                                               ; preds = %5
  br label %17

15:                                               ; preds = %5
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 136, ptr noundef @__PRETTY_FUNCTION__._ZN2rw13instTexCoordsEiPhPNS_9TexCoordsEjj) #4
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  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) #5
  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 1 %24, ptr align 4 %25, i64 8, i1 false)
  %26 = load i32, ptr %10, align 4, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  %28 = zext i32 %26 to i64
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  store ptr %29, ptr %7, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = getelementptr inbounds %"struct.rw::TexCoords", ptr %30, i32 1
  store ptr %31, ptr %8, 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
  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 = { noreturn nounwind }
attributes #5 = { 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"}


; 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.5 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw13instTexCoordsEiPhPNS_9TexCoordsEjj = external hidden unnamed_addr constant [66 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2rw13instTexCoordsEiPhPNS_9TexCoordsEjj(i32 noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = icmp eq i32 %0, 7
  br i1 %6, label %.preheader, label %9

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

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

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i32 %3, -8
  br label %13

9:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 136, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw13instTexCoordsEiPhPNS_9TexCoordsEjj) #2
  unreachable

._crit_edge.loopexit.unr-lcssa:                   ; preds = %13, %.lr.ph
  %.0811.unr = phi ptr [ %1, %.lr.ph ], [ %36, %13 ]
  %.0910.unr = phi ptr [ %2, %.lr.ph ], [ %37, %13 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.0811.epil = phi ptr [ %11, %.epil.preheader ], [ %.0811.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.0910.epil = phi ptr [ %12, %.epil.preheader ], [ %.0910.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %10 = load i64, ptr %.0910.epil, align 4
  store i64 %10, ptr %.0811.epil, align 1
  %11 = getelementptr inbounds i8, ptr %.0811.epil, i64 %7
  %12 = getelementptr inbounds i8, ptr %.0910.epil, i64 8
  %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 %._crit_edge, label %.epil.preheader, !llvm.loop !5

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %.preheader
  ret void

13:                                               ; preds = %13, %.lr.ph.new
  %.0811 = phi ptr [ %1, %.lr.ph.new ], [ %36, %13 ]
  %.0910 = phi ptr [ %2, %.lr.ph.new ], [ %37, %13 ]
  %niter = phi i32 [ 0, %.lr.ph.new ], [ %niter.next.7, %13 ]
  %14 = load i64, ptr %.0910, align 4
  store i64 %14, ptr %.0811, align 1
  %15 = getelementptr inbounds i8, ptr %.0811, i64 %7
  %16 = getelementptr inbounds i8, ptr %.0910, i64 8
  %17 = load i64, ptr %16, align 4
  store i64 %17, ptr %15, align 1
  %18 = getelementptr inbounds i8, ptr %15, i64 %7
  %19 = getelementptr inbounds i8, ptr %.0910, i64 16
  %20 = load i64, ptr %19, align 4
  store i64 %20, ptr %18, align 1
  %21 = getelementptr inbounds i8, ptr %18, i64 %7
  %22 = getelementptr inbounds i8, ptr %.0910, i64 24
  %23 = load i64, ptr %22, align 4
  store i64 %23, ptr %21, align 1
  %24 = getelementptr inbounds i8, ptr %21, i64 %7
  %25 = getelementptr inbounds i8, ptr %.0910, i64 32
  %26 = load i64, ptr %25, align 4
  store i64 %26, ptr %24, align 1
  %27 = getelementptr inbounds i8, ptr %24, i64 %7
  %28 = getelementptr inbounds i8, ptr %.0910, i64 40
  %29 = load i64, ptr %28, align 4
  store i64 %29, ptr %27, align 1
  %30 = getelementptr inbounds i8, ptr %27, i64 %7
  %31 = getelementptr inbounds i8, ptr %.0910, i64 48
  %32 = load i64, ptr %31, align 4
  store i64 %32, ptr %30, align 1
  %33 = getelementptr inbounds i8, ptr %30, i64 %7
  %34 = getelementptr inbounds i8, ptr %.0910, i64 56
  %35 = load i64, ptr %34, align 4
  store i64 %35, ptr %33, align 1
  %36 = getelementptr inbounds i8, ptr %33, i64 %7
  %37 = getelementptr inbounds i8, ptr %.0910, i64 64
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7 = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.loopexit.unr-lcssa, label %13, !llvm.loop !7
}

attributes #0 = { 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 #1 = { 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 #2 = { 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.unroll.disable"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.mustprogress"}


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