; LLVM IR from sp-nitech/SPTK :: src/math/statistics_accumulation.ll (ZN4sptk22StatisticsAccumulationC2Eiibb)

; 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.sptk::StatisticsAccumulation" = type <{ ptr, i32, i32, i8, i8, i8, [5 x i8] }>

@_ZTVN4sptk22StatisticsAccumulationE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4sptk22StatisticsAccumulationC2Eiibb(ptr noundef nonnull align 8 dereferenceable(19) %0, i32 noundef %1, i32 noundef %2, i1 noundef zeroext %3, i1 noundef zeroext %4) unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  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
  %11 = zext i1 %3 to i8
  store i8 %11, ptr %9, align 1, !tbaa !11
  %12 = zext i1 %4 to i8
  store i8 %12, ptr %10, align 1, !tbaa !11
  %13 = load ptr, ptr %6, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN4sptk22StatisticsAccumulationE, i32 0, i32 0, i32 2), ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 1
  %15 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %15, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 2
  %17 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %17, ptr %16, align 4, !tbaa !17
  %18 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 3
  %19 = load i8, ptr %9, align 1, !tbaa !11, !range !18, !noundef !19
  %20 = trunc i8 %19 to i1
  %21 = zext i1 %20 to i8
  store i8 %21, ptr %18, align 8, !tbaa !20
  %22 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 4
  %23 = load i8, ptr %10, align 1, !tbaa !11, !range !18, !noundef !19
  %24 = trunc i8 %23 to i1
  %25 = zext i1 %24 to i8
  store i8 %25, ptr %22, align 1, !tbaa !21
  %26 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 5
  store i8 1, ptr %26, align 2, !tbaa !22
  %27 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = icmp slt i32 %28, 0
  br i1 %29, label %38, label %30

30:                                               ; preds = %5
  %31 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 2
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %38, label %34

34:                                               ; preds = %30
  %35 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 2
  %36 = load i32, ptr %35, align 4, !tbaa !17
  %37 = icmp slt i32 2, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %34, %30, %5
  %39 = getelementptr inbounds %"class.sptk::StatisticsAccumulation", ptr %13, i32 0, i32 5
  store i8 0, ptr %39, align 2, !tbaa !22
  br label %40

40:                                               ; preds = %38, %34
  ret void
}

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, !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 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !10, i64 8}
!16 = !{!"_ZTSN4sptk22StatisticsAccumulationE", !10, i64 8, !10, i64 12, !12, i64 16, !12, i64 17, !12, i64 18}
!17 = !{!16, !10, i64 12}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!16, !12, i64 16}
!21 = !{!16, !12, i64 17}
!22 = !{!16, !12, i64 18}


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

@_ZTVN4sptk22StatisticsAccumulationE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN4sptk22StatisticsAccumulationC2Eiibb(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(19) %0, i32 noundef %1, i32 noundef %2, i1 noundef zeroext %3, i1 noundef zeroext %4) unnamed_addr #0 align 2 {
  %6 = zext i1 %3 to i8
  %7 = zext i1 %4 to i8
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN4sptk22StatisticsAccumulationE, i64 16), ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %8, align 8, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %2, ptr %9, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %6, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 %7, ptr %11, align 1, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 18
  %13 = icmp sgt i32 %1, -1
  %or.cond = icmp ult i32 %2, 3
  %or.cond4.not = and i1 %13, %or.cond
  %spec.store.select = zext i1 %or.cond4.not to i8
  store i8 %spec.store.select, ptr %12, align 2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTSN4sptk22StatisticsAccumulationE", !10, i64 8, !10, i64 12, !12, i64 16, !12, i64 17, !12, i64 18}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"bool", !11, i64 0}
!13 = !{!9, !10, i64 12}
!14 = !{!9, !12, i64 16}
!15 = !{!9, !12, i64 17}


; Effective O3 passes: EarlyCSEPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass