; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN16TPCCQueryMessage8get_sizeEv)

; 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.TPCCQueryMessage = type { %class.QueryMessage, i64, i64, i64, i64, i64, i64, i64, i64, [16 x i8], i64, i8, %class.Array.2, i8, i8, i64, i64 }
%class.QueryMessage = type { %class.Message, i64, i64 }
%class.Message = type { ptr, i32, i64, i64, i64, i64, i64, i64, double, double, double, double, double, double, double }
%class.Array.2 = type { ptr, i64, i64 }

; 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 nounwind uwtable
declare dso_local noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN16TPCCQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(280) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = call noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136) %4)
  store i64 %5, ptr %3, align 8, !tbaa !9
  %6 = load i64, ptr %3, align 8, !tbaa !9
  %7 = add i64 %6, 8
  store i64 %7, ptr %3, align 8, !tbaa !9
  %8 = load i64, ptr %3, align 8, !tbaa !9
  %9 = add i64 %8, 8
  store i64 %9, ptr %3, align 8, !tbaa !9
  %10 = load i64, ptr %3, align 8, !tbaa !9
  %11 = add i64 %10, 24
  store i64 %11, ptr %3, align 8, !tbaa !9
  %12 = getelementptr inbounds %class.TPCCQueryMessage, ptr %4, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = icmp eq i64 %13, 1
  br i1 %14, label %15, label %22

15:                                               ; preds = %1
  %16 = load i64, ptr %3, align 8, !tbaa !9
  %17 = add i64 %16, 32
  store i64 %17, ptr %3, align 8, !tbaa !9
  %18 = load i64, ptr %3, align 8, !tbaa !9
  %19 = add i64 %18, 16
  store i64 %19, ptr %3, align 8, !tbaa !9
  %20 = load i64, ptr %3, align 8, !tbaa !9
  %21 = add i64 %20, 1
  store i64 %21, ptr %3, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %15, %1
  %23 = getelementptr inbounds %class.TPCCQueryMessage, ptr %4, i32 0, i32 1
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i64 %24, 2
  br i1 %25, label %26, label %38

26:                                               ; preds = %22
  %27 = load i64, ptr %3, align 8, !tbaa !9
  %28 = add i64 %27, 16
  store i64 %28, ptr %3, align 8, !tbaa !9
  %29 = load i64, ptr %3, align 8, !tbaa !9
  %30 = add i64 %29, 2
  store i64 %30, ptr %3, align 8, !tbaa !9
  %31 = getelementptr inbounds %class.TPCCQueryMessage, ptr %4, i32 0, i32 12
  %32 = call noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %31)
  %33 = mul i64 24, %32
  %34 = load i64, ptr %3, align 8, !tbaa !9
  %35 = add i64 %34, %33
  store i64 %35, ptr %3, align 8, !tbaa !9
  %36 = load i64, ptr %3, align 8, !tbaa !9
  %37 = add i64 %36, 8
  store i64 %37, ptr %3, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %26, %22
  %39 = load i64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i64 %39
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 }

!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, !10, i64 136}
!12 = !{!"_ZTS16TPCCQueryMessage", !13, i64 0, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !7, i64 200, !10, i64 216, !17, i64 224, !18, i64 232, !17, i64 256, !17, i64 257, !10, i64 264, !10, i64 272}
!13 = !{!"_ZTS12QueryMessage", !14, i64 0, !10, i64 120, !10, i64 128}
!14 = !{!"_ZTS7Message", !15, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !16, i64 64, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !16, i64 104, !16, i64 112}
!15 = !{!"_ZTS10RemReqType", !7, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTS5ArrayIP7Item_noE", !6, i64 0, !10, i64 8, !10, i64 16}


; 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
declare dso_local noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN16TPCCQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(280) %0) unnamed_addr #0 align 2 {
  %2 = tail call noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 136
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i64 %4, 1
  %spec.select.v = select i1 %5, i64 89, i64 40
  %spec.select = add i64 %spec.select.v, %2
  %6 = icmp eq i64 %4, 2
  br i1 %6, label %7, label %13

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 232
  %9 = tail call noundef i64 @_ZN5ArrayIP7Item_noE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = mul i64 %9, 24
  %11 = add i64 %2, 66
  %12 = add i64 %11, %10
  br label %13

13:                                               ; preds = %7, %1
  %.1 = phi i64 [ %12, %7 ], [ %spec.select, %1 ]
  ret i64 %.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" }

!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, !12, i64 136}
!6 = !{!"_ZTS16TPCCQueryMessage", !7, i64 0, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !10, i64 200, !12, i64 216, !14, i64 224, !15, i64 232, !14, i64 256, !14, i64 257, !12, i64 264, !12, i64 272}
!7 = !{!"_ZTS12QueryMessage", !8, i64 0, !12, i64 120, !12, i64 128}
!8 = !{!"_ZTS7Message", !9, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112}
!9 = !{!"_ZTS10RemReqType", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!"double", !10, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = !{!"_ZTS5ArrayIP7Item_noE", !16, i64 0, !12, i64 8, !12, i64 16}
!16 = !{!"any pointer", !10, i64 0}


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