; LLVM IR from ShahjalalShohag/code-library :: Strings/Number of Palindromes in Range.ll (Z3oddii)

; 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.wavelet_tree = type { i32, i32, ptr, ptr, ptr, ptr, i32, i32 }

@oddl = external dso_local global %struct.wavelet_tree, align 8
@oddr = external dso_local global %struct.wavelet_tree, align 8

; 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 i32 @_Z3getii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3oddii(i32 noundef %0, i32 noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = add nsw i32 %10, %11
  %13 = sdiv i32 %12, 2
  store i32 %13, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = sub nsw i32 1, %14
  store i32 %15, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = call noundef i32 @_ZN12wavelet_tree3LTEEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddl, i32 noundef %16, i32 noundef %17, i32 noundef %18)
  store i32 %19, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = call noundef i32 @_Z3getii(i32 noundef %20, i32 noundef %21)
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = call noundef i32 @_ZN12wavelet_tree3sumEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddl, i32 noundef %23, i32 noundef %24, i32 noundef %25)
  %27 = add nsw i32 %22, %26
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sub nsw i32 %28, %29
  %31 = add nsw i32 %30, 1
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = sub nsw i32 %31, %32
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = mul nsw i32 %33, %34
  %36 = add nsw i32 %27, %35
  store i32 %36, ptr %8, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = add nsw i32 1, %37
  store i32 %38, ptr %6, align 4, !tbaa !5
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = call noundef i32 @_ZN12wavelet_tree3LTEEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddr, i32 noundef %40, i32 noundef %41, i32 noundef %42)
  store i32 %43, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %44 = load i32, ptr %5, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = call noundef i32 @_Z3getii(i32 noundef %45, i32 noundef %46)
  %48 = sub nsw i32 0, %47
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = call noundef i32 @_ZN12wavelet_tree3sumEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddr, i32 noundef %50, i32 noundef %51, i32 noundef %52)
  %54 = add nsw i32 %48, %53
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = sub nsw i32 %55, %56
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = sub nsw i32 %57, %58
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = mul nsw i32 %59, %60
  %62 = add nsw i32 %54, %61
  store i32 %62, ptr %9, align 4, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = add nsw i32 %63, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %65
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN12wavelet_tree3LTEEiii(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN12wavelet_tree3sumEiii(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i32 noundef, i32 noundef) #2 align 2

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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.wavelet_tree = type { i32, i32, ptr, ptr, ptr, ptr, i32, i32 }

@oddl = external dso_local global %struct.wavelet_tree, align 8
@oddr = external dso_local global %struct.wavelet_tree, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3getii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3oddii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = add nsw i32 %1, %0
  %4 = sdiv i32 %3, 2
  %5 = sub nsw i32 1, %0
  %6 = tail call noundef i32 @_ZN12wavelet_tree3LTEEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddl, i32 noundef %0, i32 noundef %4, i32 noundef %5)
  %7 = tail call noundef i32 @_Z3getii(i32 noundef %0, i32 noundef %4)
  %8 = tail call noundef i32 @_ZN12wavelet_tree3sumEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddl, i32 noundef %0, i32 noundef %4, i32 noundef %5)
  %9 = add nsw i32 %4, 1
  %10 = add i32 %6, %0
  %11 = sub i32 %9, %10
  %12 = mul nsw i32 %11, %5
  %13 = add nsw i32 %1, 1
  %14 = tail call noundef i32 @_ZN12wavelet_tree3LTEEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddr, i32 noundef %9, i32 noundef %1, i32 noundef %13)
  %15 = tail call noundef i32 @_Z3getii(i32 noundef %9, i32 noundef %1)
  %16 = tail call noundef i32 @_ZN12wavelet_tree3sumEiii(ptr noundef nonnull align 8 dereferenceable(48) @oddr, i32 noundef %9, i32 noundef %1, i32 noundef %13)
  %17 = add i32 %4, %14
  %18 = sub i32 %1, %17
  %19 = mul nsw i32 %18, %13
  %20 = add i32 %8, %7
  %21 = add i32 %20, %12
  %22 = sub i32 %21, %15
  %23 = add i32 %22, %16
  %24 = add i32 %23, %19
  ret i32 %24
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN12wavelet_tree3LTEEiii(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN12wavelet_tree3sumEiii(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1 align 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 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)"}


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