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

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

@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 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

; 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 noundef ptr @_ZN2rw9Animation6createEPNS_20AnimInterpolatorInfoEiif(ptr noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %"struct.rw::Error", align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.rw::AnimInterpolatorInfo", ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = mul nsw i32 %15, %18
  %20 = sext i32 %19 to i64
  %21 = add i64 40, %20
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.rw::AnimInterpolatorInfo", ptr %22, i32 0, i32 3
  %24 = load i32, ptr %23, align 4, !tbaa !15
  %25 = sext i32 %24 to i64
  %26 = add i64 %21, %25
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %29, i32 noundef 196635, ptr noundef @.str.2)
  store ptr %30, ptr %11, align 8, !tbaa !5
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %45

33:                                               ; preds = %4
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %35 = getelementptr inbounds %"struct.rw::Error", ptr %12, i32 0, i32 0
  store i32 27, ptr %35, align 4, !tbaa !16
  %36 = getelementptr inbounds %"struct.rw::Error", ptr %12, i32 0, i32 1
  store i32 -2147483646, ptr %36, align 4, !tbaa !18
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 72) #5
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i32 noundef %40)
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.4, ptr noundef %41) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %12)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %43

43:                                               ; preds = %34
  br label %44

44:                                               ; preds = %43
  store ptr null, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %78

45:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %46, ptr %14, align 8, !tbaa !5
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %47, i64 40
  store ptr %48, ptr %11, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.rw::Animation", ptr %50, i32 0, i32 0
  store ptr %49, ptr %51, align 8, !tbaa !19
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.rw::Animation", ptr %53, i32 0, i32 1
  store i32 %52, ptr %54, align 8, !tbaa !21
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = load ptr, ptr %14, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.rw::Animation", ptr %56, i32 0, i32 2
  store i32 %55, ptr %57, align 4, !tbaa !22
  %58 = load float, ptr %9, align 4, !tbaa !11
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.rw::Animation", ptr %59, i32 0, i32 3
  store float %58, ptr %60, align 8, !tbaa !23
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = load ptr, ptr %14, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.rw::Animation", ptr %62, i32 0, i32 4
  store ptr %61, ptr %63, align 8, !tbaa !24
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.rw::Animation", ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 8, !tbaa !21
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.rw::AnimInterpolatorInfo", ptr %67, i32 0, i32 2
  %69 = load i32, ptr %68, align 8, !tbaa !13
  %70 = mul nsw i32 %66, %69
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = sext i32 %70 to i64
  %73 = getelementptr inbounds i8, ptr %71, i64 %72
  store ptr %73, ptr %11, align 8, !tbaa !5
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.rw::Animation", ptr %75, i32 0, i32 5
  store ptr %74, ptr %76, align 8, !tbaa !25
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %77, ptr %5, align 8
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %78

78:                                               ; preds = %45, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %79 = load ptr, ptr %5, align 8
  ret ptr %79
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #2

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #4

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 = { 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 #3 = { 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 #4 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN2rw20AnimInterpolatorInfoE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!15 = !{!14, !10, i64 12}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTSN2rw5ErrorE", !10, i64 0, !10, i64 4}
!18 = !{!17, !10, i64 4}
!19 = !{!20, !6, i64 0}
!20 = !{!"_ZTSN2rw9AnimationE", !6, i64 0, !10, i64 8, !10, i64 12, !12, i64 16, !6, i64 24, !6, i64 32}
!21 = !{!20, !10, i64 8}
!22 = !{!20, !10, i64 12}
!23 = !{!20, !12, i64 16}
!24 = !{!20, !6, i64 24}
!25 = !{!20, !6, i64 32}


; 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
@.str.2 = external hidden unnamed_addr constant [71 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

; 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: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw9Animation6createEPNS_20AnimInterpolatorInfoEiif(ptr noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"struct.rw::Error", align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = mul nsw i32 %7, %1
  %9 = add i32 %8, 40
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = add i32 %9, %11
  %13 = sext i32 %12 to i64
  %14 = tail call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %13, i32 noundef 196635, ptr noundef nonnull @.str.2)
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %23

16:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  store i32 27, ptr %5, align 4, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 -2147483646, ptr %17, align 4, !tbaa !14
  %18 = load ptr, ptr @stderr, align 8, !tbaa !15
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 72) #6
  %20 = load ptr, ptr @stderr, align 8, !tbaa !15
  %21 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i32 noundef %12)
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.4, ptr noundef %21) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %34

23:                                               ; preds = %4
  %24 = getelementptr inbounds i8, ptr %14, i64 40
  store ptr %0, ptr %14, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %14, i64 8
  store i32 %1, ptr %25, align 8, !tbaa !19
  %26 = getelementptr inbounds i8, ptr %14, i64 12
  store i32 %2, ptr %26, align 4, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %14, i64 16
  store float %3, ptr %27, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %14, i64 24
  store ptr %24, ptr %28, align 8, !tbaa !22
  %29 = load i32, ptr %6, align 8, !tbaa !5
  %30 = mul nsw i32 %29, %1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %24, i64 %31
  %33 = getelementptr inbounds i8, ptr %14, i64 32
  store ptr %32, ptr %33, align 8, !tbaa !23
  br label %34

34:                                               ; preds = %23, %16
  ret ptr %14
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress 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 = { 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 #3 = { 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 #4 = { "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 8}
!6 = !{!"_ZTSN2rw20AnimInterpolatorInfoE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 12}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!14 = !{!13, !7, i64 4}
!15 = !{!10, !10, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTSN2rw9AnimationE", !10, i64 0, !7, i64 8, !7, i64 12, !18, i64 16, !10, i64 24, !10, i64 32}
!18 = !{!"float", !8, i64 0}
!19 = !{!17, !7, i64 8}
!20 = !{!17, !7, i64 12}
!21 = !{!17, !18, i64 16}
!22 = !{!17, !10, i64 24}
!23 = !{!17, !10, i64 32}


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