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

; 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_index" = type { i32, i32 }
%"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: 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_ZNK5sc_dt8scfx_rep12calc_indicesEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5sc_dt10scfx_index2biEv(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1) #4 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"class.sc_dt::scfx_index", align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep9is_normalEv(ptr noundef nonnull align 8 dereferenceable(37) %9)
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %36

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = call i64 @_ZNK5sc_dt8scfx_rep12calc_indicesEi(ptr noundef nonnull align 8 dereferenceable(37) %9, i32 noundef %13)
  store i64 %14, ptr %6, align 4
  %15 = call noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %16 = call noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37) %9)
  %17 = icmp sge i32 %15, %16
  br i1 %17, label %18, label %20

18:                                               ; preds = %12
  %19 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_negEv(ptr noundef nonnull align 8 dereferenceable(37) %9)
  store i1 %19, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %35

20:                                               ; preds = %12
  %21 = call noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %35

24:                                               ; preds = %20
  call void @_ZN5sc_dt8scfx_rep9toggle_tcEv(ptr noundef nonnull align 8 dereferenceable(37) %9)
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  %25 = getelementptr inbounds %"class.sc_dt::scfx_rep", ptr %9, i32 0, i32 0
  %26 = call noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %27 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %25, i32 noundef %26)
  %28 = call noundef i32 @_ZNK5sc_dt10scfx_index2biEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %29 = shl i32 1, %28
  %30 = and i32 %27, %29
  %31 = icmp ne i32 %30, 0
  %32 = zext i1 %31 to i8
  store i8 %32, ptr %8, align 1, !tbaa !11
  call void @_ZN5sc_dt8scfx_rep9toggle_tcEv(ptr noundef nonnull align 8 dereferenceable(37) %9)
  %33 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %34 = trunc i8 %33 to i1
  store i1 %34, ptr %3, align 1
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  br label %35

35:                                               ; preds = %24, %23, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %36

36:                                               ; preds = %35, %11
  %37 = load i1, ptr %3, align 1
  ret i1 %37
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt8scfx_rep9toggle_tcEv(ptr noundef nonnull align 8 dereferenceable(37)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { 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 #3 = { 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 #4 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; 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_index" = type { i32, i32 }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_ZNK5sc_dt8scfx_rep12calc_indicesEi(ptr noundef nonnull align 8 dereferenceable(37), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5sc_dt10scfx_index2biEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK5sc_dt8scfx_rep7get_bitEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1) local_unnamed_addr #4 align 2 {
  %3 = alloca %"class.sc_dt::scfx_index", align 8
  %4 = tail call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep9is_normalEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  br i1 %4, label %5, label %22

5:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %6 = tail call i64 @_ZNK5sc_dt8scfx_rep12calc_indicesEi(ptr noundef nonnull align 8 dereferenceable(37) %0, i32 noundef %1)
  store i64 %6, ptr %3, align 8
  %7 = call noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %8 = call noundef i32 @_ZNK5sc_dt8scfx_rep4sizeEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  %.not = icmp slt i32 %7, %8
  br i1 %.not, label %11, label %9

9:                                                ; preds = %5
  %10 = call noundef zeroext i1 @_ZNK5sc_dt8scfx_rep6is_negEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  br label %21

11:                                               ; preds = %5
  %12 = call noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %13 = icmp slt i32 %12, 0
  br i1 %13, label %21, label %14

14:                                               ; preds = %11
  call void @_ZN5sc_dt8scfx_rep9toggle_tcEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  %15 = call noundef i32 @_ZNK5sc_dt10scfx_index2wiEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %16 = call noundef i32 @_ZNK5sc_dt9scfx_mantixEi(ptr noundef nonnull align 8 dereferenceable(12) %0, i32 noundef %15)
  %17 = call noundef i32 @_ZNK5sc_dt10scfx_index2biEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %18 = shl nuw i32 1, %17
  %19 = and i32 %18, %16
  %20 = icmp ne i32 %19, 0
  call void @_ZN5sc_dt8scfx_rep9toggle_tcEv(ptr noundef nonnull align 8 dereferenceable(37) %0)
  br label %21

21:                                               ; preds = %11, %14, %9
  %.0 = phi i1 [ %10, %9 ], [ %20, %14 ], [ false, %11 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %22

22:                                               ; preds = %2, %21
  %.1 = phi i1 [ %.0, %21 ], [ false, %2 ]
  ret i1 %.1
}

; 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 #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5sc_dt8scfx_rep9toggle_tcEv(ptr noundef nonnull align 8 dereferenceable(37)) local_unnamed_addr #1 align 2

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


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