; LLVM IR from gem5/gem5 :: ext/systemc/src/sysc/datatypes/fx/scfx_pow10.ll (ZN5sc_dt10scfx_pow103negEi)

; 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.sc_dt::scfx_pow10" = type { [32 x %"class.sc_dt::scfx_rep"], [32 x %"class.sc_dt::scfx_rep"] }
%"class.sc_dt::scfx_rep" = type <{ %"class.sc_dt::scfx_mant", i32, i32, i32, i32, i32, i8, [3 x i8] }>
%"class.sc_dt::scfx_mant" = type <{ ptr, i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN5sc_dt10scfx_pow103negEi(ptr noundef nonnull align 8 dereferenceable(2560) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %"class.sc_dt::scfx_pow10", ptr %5, i32 0, i32 1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [32 x %"class.sc_dt::scfx_rep"], ptr %6, i64 0, i64 %8
  %10 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep9is_normalEv(ptr noundef nonnull align 8 dereferenceable(37) %9)
  br i1 %10, label %22, label %11

11:                                               ; preds = %2
  %12 = getelementptr inbounds %"class.sc_dt::scfx_pow10", ptr %5, i32 0, i32 1
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [32 x %"class.sc_dt::scfx_rep"], ptr %12, i64 0, i64 %14
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = sub nsw i32 %16, 1
  %18 = call noundef ptr @_ZN5sc_dt10scfx_pow103negEi(ptr noundef nonnull align 8 dereferenceable(2560) %5, i32 noundef %17)
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sub nsw i32 %19, 1
  %21 = call noundef ptr @_ZN5sc_dt10scfx_pow103negEi(ptr noundef nonnull align 8 dereferenceable(2560) %5, i32 noundef %20)
  call void @_ZN5sc_dt8multiplyERNS_8scfx_repERKS0_S3_i(ptr noundef nonnull align 8 dereferenceable(37) %15, ptr noundef nonnull align 8 dereferenceable(37) %18, ptr noundef nonnull align 8 dereferenceable(37) %21, i32 noundef 1024)
  br label %22

22:                                               ; preds = %11, %2
  %23 = getelementptr inbounds %"class.sc_dt::scfx_pow10", ptr %5, i32 0, i32 1
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [32 x %"class.sc_dt::scfx_rep"], ptr %23, i64 0, i64 %25
  ret ptr %26
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep9is_normalEv(ptr noundef nonnull align 8 dereferenceable(37)) #1 align 2

declare void @_ZN5sc_dt8multiplyERNS_8scfx_repERKS0_S3_i(ptr noundef nonnull align 8 dereferenceable(37), ptr noundef nonnull align 8 dereferenceable(37), ptr noundef nonnull align 8 dereferenceable(37), i32 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 = { 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 #2 = { "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}


; 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.sc_dt::scfx_rep" = type <{ %"class.sc_dt::scfx_mant", i32, i32, i32, i32, i32, i8, [3 x i8] }>
%"class.sc_dt::scfx_mant" = type <{ ptr, i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN5sc_dt10scfx_pow103negEi(ptr noundef nonnull align 8 dereferenceable(2560) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1280
  %4 = sext i32 %1 to i64
  %5 = getelementptr inbounds [32 x %"class.sc_dt::scfx_rep"], ptr %3, i64 0, i64 %4
  %6 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep9is_normalEv(ptr noundef nonnull align 8 dereferenceable(37) %5)
  br i1 %6, label %common.ret5, label %7

common.ret5:                                      ; preds = %2, %7
  ret ptr %5

7:                                                ; preds = %2
  %8 = add nsw i32 %1, -1
  %9 = tail call noundef ptr @_ZN5sc_dt10scfx_pow103negEi(ptr noundef nonnull align 8 dereferenceable(2560) %0, i32 noundef %8)
  %10 = tail call noundef ptr @_ZN5sc_dt10scfx_pow103negEi(ptr noundef nonnull align 8 dereferenceable(2560) %0, i32 noundef %8)
  tail call void @_ZN5sc_dt8multiplyERNS_8scfx_repERKS0_S3_i(ptr noundef nonnull align 8 dereferenceable(37) %5, ptr noundef nonnull align 8 dereferenceable(37) %9, ptr noundef nonnull align 8 dereferenceable(37) %10, i32 noundef 1024)
  br label %common.ret5
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep9is_normalEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #1 align 2

declare void @_ZN5sc_dt8multiplyERNS_8scfx_repERKS0_S3_i(ptr noundef nonnull align 8 dereferenceable(37), ptr noundef nonnull align 8 dereferenceable(37), ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #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 = { 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 #2 = { "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,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass