; LLVM IR from aap/librw :: src/anim.ll (ZN2rw16AnimInterpolator6createEii)

; 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::Error" = type { i32, i32 }
%"struct.rw::AnimInterpolator" = type { ptr, float, ptr, i32, i32, i32, i32, ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [72 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: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) #3

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw16AnimInterpolator6createEii(i32 noundef %0, i32 noundef %1) #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.rw::Error", align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %11 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %11, ptr %8, align 4, !tbaa !5
  %12 = load i32, ptr %8, align 4, !tbaa !5
  %13 = add nsw i32 %12, 16
  store i32 %13, ptr %8, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load i32, ptr %8, align 4, !tbaa !5
  %16 = mul nsw i32 %14, %15
  %17 = sext i32 %16 to i64
  %18 = add i64 72, %17
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr %7, align 4, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %21, i32 noundef 196635, ptr noundef @.str.6)
  store ptr %22, ptr %6, align 8, !tbaa !9
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %37

25:                                               ; preds = %2
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %27 = getelementptr inbounds %"struct.rw::Error", ptr %9, i32 0, i32 0
  store i32 27, ptr %27, align 4, !tbaa !11
  %28 = getelementptr inbounds %"struct.rw::Error", ptr %9, i32 0, i32 1
  store i32 -2147483646, ptr %28, align 4, !tbaa !13
  %29 = load ptr, ptr @stderr, align 8, !tbaa !9
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 199) #5
  %31 = load ptr, ptr @stderr, align 8, !tbaa !9
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i32 noundef %32)
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.4, ptr noundef %33) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %35

35:                                               ; preds = %26
  br label %36

36:                                               ; preds = %35
  store ptr null, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %56

37:                                               ; preds = %2
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  %39 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %38, i32 0, i32 0
  store ptr null, ptr %39, align 8, !tbaa !14
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %40, i32 0, i32 1
  store float 0.000000e+00, ptr %41, align 8, !tbaa !17
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %42, i32 0, i32 2
  store ptr null, ptr %43, align 8, !tbaa !18
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  %46 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %45, i32 0, i32 3
  store i32 %44, ptr %46, align 8, !tbaa !19
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !9
  %49 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %48, i32 0, i32 4
  store i32 %47, ptr %49, align 4, !tbaa !20
  %50 = load ptr, ptr %6, align 8, !tbaa !9
  %51 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %50, i32 0, i32 5
  store i32 -1, ptr %51, align 8, !tbaa !21
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds %"struct.rw::AnimInterpolator", ptr %53, i32 0, i32 6
  store i32 %52, ptr %54, align 4, !tbaa !22
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %55, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %56

56:                                               ; preds = %37, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %57 = load ptr, ptr %3, align 8
  ret ptr %57
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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 = { "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 = { 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 #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 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN2rw5ErrorE", !6, i64 0, !6, i64 4}
!13 = !{!12, !6, i64 4}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTSN2rw16AnimInterpolatorE", !10, i64 0, !16, i64 8, !10, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!16 = !{!"float", !7, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!15, !10, i64 16}
!19 = !{!15, !6, i64 24}
!20 = !{!15, !6, i64 28}
!21 = !{!15, !6, i64 32}
!22 = !{!15, !6, i64 36}


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

@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [72 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) local_unnamed_addr #3

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw16AnimInterpolator6createEii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #4 align 2 {
  %3 = alloca %"struct.rw::Error", align 4
  %4 = add nsw i32 %1, 16
  %5 = mul nsw i32 %4, %0
  %6 = add i32 %5, 72
  %7 = sext i32 %6 to i64
  %8 = tail call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %7, i32 noundef 196635, ptr noundef nonnull @.str.6)
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %17

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store i32 27, ptr %3, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 -2147483646, ptr %11, align 4, !tbaa !10
  %12 = load ptr, ptr @stderr, align 8, !tbaa !11
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 199) #6
  %14 = load ptr, ptr @stderr, align 8, !tbaa !11
  %15 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i32 noundef %6)
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.4, ptr noundef %15) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %24

17:                                               ; preds = %2
  store ptr null, ptr %8, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %8, i64 8
  store float 0.000000e+00, ptr %18, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr null, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %8, i64 24
  store i32 %1, ptr %20, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %8, i64 28
  store i32 %1, ptr %21, align 4, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %8, i64 32
  store i32 -1, ptr %22, align 8, !tbaa !20
  %23 = getelementptr inbounds i8, ptr %8, i64 36
  store i32 %0, ptr %23, align 4, !tbaa !21
  br label %24

24:                                               ; preds = %17, %10
  ret ptr %8
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { nofree 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 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { cold 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, !7, i64 0}
!6 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN2rw16AnimInterpolatorE", !12, i64 0, !15, i64 8, !12, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64}
!15 = !{!"float", !8, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{!14, !12, i64 16}
!18 = !{!14, !7, i64 24}
!19 = !{!14, !7, i64 28}
!20 = !{!14, !7, i64 32}
!21 = !{!14, !7, i64 36}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass