; LLVM IR from robotic-vision-lab/Cloud-Object-Recognition-Engine :: 3rdparty/libsvm/svm.ll (ZN5CacheC2Eil)

; 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"

%class.Cache = type { i32, i64, ptr, %"struct.Cache::head_t" }
%"struct.Cache::head_t" = type { ptr, ptr, ptr, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5CacheC2Eil(ptr noundef nonnull align 8 dereferenceable(56) %0, i32 noundef %1, i64 noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !11
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %9, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 1
  %11 = load i64, ptr %6, align 8, !tbaa !11
  store i64 %11, ptr %10, align 8, !tbaa !16
  %12 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 3
  %13 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = sext i32 %14 to i64
  %16 = call noalias ptr @calloc(i64 noundef %15, i64 noundef 32) #3
  %17 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 2
  store ptr %16, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 1
  %19 = load i64, ptr %18, align 8, !tbaa !16
  %20 = udiv i64 %19, 4
  store i64 %20, ptr %18, align 8, !tbaa !16
  %21 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = sext i32 %22 to i64
  %24 = mul i64 %23, 32
  %25 = udiv i64 %24, 4
  %26 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 1
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = sub i64 %27, %25
  store i64 %28, ptr %26, align 8, !tbaa !16
  %29 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !16
  %31 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = sext i32 %32 to i64
  %34 = mul nsw i64 2, %33
  %35 = call noundef i64 @_ZL3maxIlET_S0_S0_(i64 noundef %30, i64 noundef %34)
  %36 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 1
  store i64 %35, ptr %36, align 8, !tbaa !16
  %37 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 3
  %38 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 3
  %39 = getelementptr inbounds %"struct.Cache::head_t", ptr %38, i32 0, i32 0
  store ptr %37, ptr %39, align 8, !tbaa !18
  %40 = getelementptr inbounds %class.Cache, ptr %7, i32 0, i32 3
  %41 = getelementptr inbounds %"struct.Cache::head_t", ptr %40, i32 0, i32 1
  store ptr %37, ptr %41, align 8, !tbaa !19
  ret void
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL3maxIlET_S0_S0_(i64 noundef, i64 noundef) #2

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 = { nounwind allocsize(0,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" }
attributes #2 = { inlinehint 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 = { nounwind allocsize(0,1) }

!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 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS5Cache", !10, i64 0, !12, i64 8, !6, i64 16, !15, i64 24}
!15 = !{!"_ZTSN5Cache6head_tE", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24}
!16 = !{!14, !12, i64 8}
!17 = !{!14, !6, i64 16}
!18 = !{!14, !6, i64 24}
!19 = !{!14, !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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5CacheC2Eil(ptr noundef nonnull align 8 dereferenceable(56) %0, i32 noundef %1, i64 noundef %2) unnamed_addr #0 align 2 {
  store i32 %1, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = sext i32 %1 to i64
  %6 = tail call noalias ptr @calloc(i64 noundef %5, i64 noundef 32) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %6, ptr %7, align 8, !tbaa !13
  %8 = lshr i64 %2, 2
  %9 = shl nsw i64 %5, 3
  %10 = and i64 %9, 4611686018427387896
  %11 = sub nsw i64 %8, %10
  store i64 %11, ptr %4, align 8, !tbaa !14
  %12 = shl nsw i64 %5, 1
  %13 = tail call noundef i64 @_ZL3maxIlET_S0_S0_(i64 noundef %11, i64 noundef %12)
  store i64 %13, ptr %4, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %14, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %14, ptr %15, align 8, !tbaa !16
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL3maxIlET_S0_S0_(i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 = { nounwind allocsize(0,1) }

!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 = !{!"_ZTS5Cache", !7, i64 0, !10, i64 8, !11, i64 16, !12, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTSN5Cache6head_tE", !11, i64 0, !11, i64 8, !11, i64 16, !7, i64 24}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !11, i64 24}
!16 = !{!6, !11, i64 32}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass