; LLVM IR from mitdbg/deneva :: storage/catalog.ll (ZN7Catalog7add_colEPcmS0_)

; 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.Catalog = type <{ i32, [4 x i8], ptr, i32, [4 x i8], ptr, i32, [24 x i8], [4 x i8] }>
%class.Column = type { i64, i32, i32, ptr, ptr, [24 x i8] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7Catalog7add_colEPcmS0_(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = trunc i64 %10 to i32
  %12 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 5
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds %class.Column, ptr %13, i64 %16
  %18 = getelementptr inbounds %class.Column, ptr %17, i32 0, i32 1
  store i32 %11, ptr %18, align 8, !tbaa !15
  %19 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 5
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds %class.Column, ptr %20, i64 %23
  %25 = getelementptr inbounds %class.Column, ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call ptr @strcpy(ptr noundef %26, ptr noundef %27) #2
  %29 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !14
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds %class.Column, ptr %30, i64 %33
  %35 = getelementptr inbounds %class.Column, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call ptr @strcpy(ptr noundef %36, ptr noundef %37) #2
  %39 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 5
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !14
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds %class.Column, ptr %43, i64 %46
  %48 = getelementptr inbounds %class.Column, ptr %47, i32 0, i32 0
  store i64 %41, ptr %48, align 8, !tbaa !19
  %49 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 6
  %50 = load i32, ptr %49, align 8, !tbaa !20
  %51 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 5
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !14
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds %class.Column, ptr %52, i64 %55
  %57 = getelementptr inbounds %class.Column, ptr %56, i32 0, i32 2
  store i32 %50, ptr %57, align 4, !tbaa !21
  %58 = load i64, ptr %7, align 8, !tbaa !9
  %59 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 6
  %60 = load i32, ptr %59, align 8, !tbaa !20
  %61 = zext i32 %60 to i64
  %62 = add i64 %61, %58
  %63 = trunc i64 %62 to i32
  store i32 %63, ptr %59, align 8, !tbaa !20
  %64 = getelementptr inbounds %class.Catalog, ptr %9, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !14
  %66 = add i32 %65, 1
  store i32 %66, ptr %64, align 8, !tbaa !14
  ret void
}

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #1

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 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 24}
!12 = !{!"_ZTS7Catalog", !13, i64 0, !6, i64 8, !13, i64 16, !6, i64 24, !13, i64 32, !7, i64 36}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!16, !13, i64 8}
!16 = !{!"_ZTS6Column", !10, i64 0, !13, i64 8, !13, i64 12, !6, i64 16, !6, i64 24, !7, i64 32}
!17 = !{!16, !6, i64 16}
!18 = !{!16, !6, i64 24}
!19 = !{!16, !10, i64 0}
!20 = !{!12, !13, i64 32}
!21 = !{!16, !13, i64 12}


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

%class.Column = type { i64, i32, i32, ptr, ptr, [24 x i8] }

; Function Attrs: mustprogress nofree nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN7Catalog7add_colEPcmS0_(ptr nocapture noundef nonnull align 8 dereferenceable(60) %0, ptr nocapture noundef readonly %1, i64 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 align 2 {
  %5 = trunc i64 %2 to i32
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = load i32, ptr %0, align 8, !tbaa !11
  %9 = zext i32 %8 to i64
  %10 = getelementptr inbounds %class.Column, ptr %7, i64 %9, i32 1
  store i32 %5, ptr %10, align 8, !tbaa !12
  %11 = getelementptr inbounds %class.Column, ptr %7, i64 %9, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %12, ptr noundef nonnull dereferenceable(1) %3) #2
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i32, ptr %0, align 8, !tbaa !11
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds %class.Column, ptr %14, i64 %16, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %1) #2
  %20 = load i32, ptr %0, align 8, !tbaa !11
  %21 = zext i32 %20 to i64
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.Column, ptr %22, i64 %21
  store i64 %21, ptr %23, align 8, !tbaa !17
  %24 = getelementptr inbounds i8, ptr %0, i64 32
  %25 = load i32, ptr %24, align 8, !tbaa !18
  %26 = getelementptr inbounds %class.Column, ptr %22, i64 %21, i32 2
  store i32 %25, ptr %26, align 4, !tbaa !19
  %27 = add i32 %25, %5
  store i32 %27, ptr %24, align 8, !tbaa !18
  %28 = add i32 %20, 1
  store i32 %28, ptr %0, align 8, !tbaa !11
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(readwrite, inaccessiblemem: none) 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 memory(argmem: readwrite) "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 }

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


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