; LLVM IR from aap/librw :: src/uvanim.ll (ZN2rw6UVAnim7addTimeEPNS_8MaterialEf)

; 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::UVAnim" = type { [2 x ptr], [8 x ptr] }

@_ZN2rw12uvAnimOffsetE = external dso_local global i32, 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: mustprogress uwtable
define dso_local void @_ZN2rw6UVAnim7addTimeEPNS_8MaterialEf(ptr noundef %0, float noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load i32, ptr @_ZN2rw12uvAnimOffsetE, align 4, !tbaa !11
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i8, ptr %7, i64 %9
  store ptr %10, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %31, %2
  %12 = load i32, ptr %5, align 4, !tbaa !11
  %13 = icmp slt i32 %12, 8
  br i1 %13, label %14, label %34

14:                                               ; preds = %11
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.rw::UVAnim", ptr %15, i32 0, i32 1
  %17 = load i32, ptr %5, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [8 x ptr], ptr %16, i64 0, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %30

22:                                               ; preds = %14
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.rw::UVAnim", ptr %23, i32 0, i32 1
  %25 = load i32, ptr %5, align 4, !tbaa !11
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [8 x ptr], ptr %24, i64 0, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = load float, ptr %4, align 4, !tbaa !9
  call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %28, float noundef %29)
  br label %30

30:                                               ; preds = %22, %14
  br label %31

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

34:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

declare void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72), float noundef) #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 = { "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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@_ZN2rw12uvAnimOffsetE = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw6UVAnim7addTimeEPNS_8MaterialEf(ptr nocapture noundef readonly %0, float noundef %1) local_unnamed_addr #0 align 2 {
  %3 = load i32, ptr @_ZN2rw12uvAnimOffsetE, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds i8, ptr %0, i64 %4
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %9, label %8

8:                                                ; preds = %2
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %7, float noundef %1)
  br label %9

9:                                                ; preds = %2, %8
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %.not.1 = icmp eq ptr %11, null
  br i1 %.not.1, label %13, label %12

12:                                               ; preds = %9
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %11, float noundef %1)
  br label %13

13:                                               ; preds = %12, %9
  %14 = getelementptr inbounds i8, ptr %5, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %.not.2 = icmp eq ptr %15, null
  br i1 %.not.2, label %17, label %16

16:                                               ; preds = %13
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %15, float noundef %1)
  br label %17

17:                                               ; preds = %16, %13
  %18 = getelementptr inbounds i8, ptr %5, i64 40
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %.not.3 = icmp eq ptr %19, null
  br i1 %.not.3, label %21, label %20

20:                                               ; preds = %17
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %19, float noundef %1)
  br label %21

21:                                               ; preds = %20, %17
  %22 = getelementptr inbounds i8, ptr %5, i64 48
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %.not.4 = icmp eq ptr %23, null
  br i1 %.not.4, label %25, label %24

24:                                               ; preds = %21
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %23, float noundef %1)
  br label %25

25:                                               ; preds = %24, %21
  %26 = getelementptr inbounds i8, ptr %5, i64 56
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %.not.5 = icmp eq ptr %27, null
  br i1 %.not.5, label %29, label %28

28:                                               ; preds = %25
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %27, float noundef %1)
  br label %29

29:                                               ; preds = %28, %25
  %30 = getelementptr inbounds i8, ptr %5, i64 64
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %.not.6 = icmp eq ptr %31, null
  br i1 %.not.6, label %33, label %32

32:                                               ; preds = %29
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %31, float noundef %1)
  br label %33

33:                                               ; preds = %32, %29
  %34 = getelementptr inbounds i8, ptr %5, i64 72
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %.not.7 = icmp eq ptr %35, null
  br i1 %.not.7, label %37, label %36

36:                                               ; preds = %33
  tail call void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72) %35, float noundef %1)
  br label %37

37:                                               ; preds = %36, %33
  ret void
}

declare void @_ZN2rw16AnimInterpolator7addTimeEf(ptr noundef nonnull align 8 dereferenceable(72), float noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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, !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}


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