; LLVM IR from gem5/gem5 :: src/systemc/tests/systemc/datatypes/int/arith/arith01 (arith01)

; 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.int31 = type { i32 }

@_ZN7sc_core23SC_ID_ASSERTION_FAILED_E = external constant [0 x i8], align 1
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6crunchRN5sc_dt9sc_signedE5int31ii(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca %struct.int31, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = getelementptr inbounds %struct.int31, ptr %5, i32 0, i32 0
  store i32 %1, ptr %10, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %53, %4
  %12 = load i32, ptr %9, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 100000
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %56

15:                                               ; preds = %11
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5sc_dt9sc_signedmLEi(ptr noundef nonnull align 8 dereferenceable(32) %17, i32 noundef %16)
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5sc_dt9sc_signedpLEi(ptr noundef nonnull align 8 dereferenceable(32) %20, i32 noundef %19)
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = load i32, ptr %5, align 4
  %24 = shl i32 %23, 1
  %25 = ashr i32 %24, 1
  %26 = mul nsw i32 %25, %22
  %27 = load i32, ptr %5, align 4
  %28 = and i32 %26, 2147483647
  %29 = and i32 %27, -2147483648
  %30 = or i32 %29, %28
  store i32 %30, ptr %5, align 4
  %31 = shl i32 %28, 1
  %32 = ashr i32 %31, 1
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %5, align 4
  %35 = shl i32 %34, 1
  %36 = ashr i32 %35, 1
  %37 = add nsw i32 %36, %33
  %38 = load i32, ptr %5, align 4
  %39 = and i32 %37, 2147483647
  %40 = and i32 %38, -2147483648
  %41 = or i32 %40, %39
  store i32 %41, ptr %5, align 4
  %42 = shl i32 %39, 1
  %43 = ashr i32 %42, 1
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i32, ptr %5, align 4
  %46 = shl i32 %45, 1
  %47 = ashr i32 %46, 1
  %48 = call noundef zeroext i1 @_ZN5sc_dteqERKNS_9sc_signedEi(ptr noundef nonnull align 8 dereferenceable(32) %44, i32 noundef %47)
  br i1 %48, label %49, label %50

49:                                               ; preds = %15
  br label %51

50:                                               ; preds = %15
  call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 3, ptr noundef @_ZN7sc_core23SC_ID_ASSERTION_FAILED_E, ptr noundef @.str, ptr noundef @.str.2, i32 noundef 73)
  br label %51

51:                                               ; preds = %50, %49
  %52 = phi i32 [ 0, %49 ], [ 0, %50 ]
  br label %53

53:                                               ; preds = %51
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %9, align 4, !tbaa !9
  br label %11, !llvm.loop !11

56:                                               ; preds = %14
  ret void
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5sc_dteqERKNS_9sc_signedEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #2

declare void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

@_ZN7sc_core23SC_ID_ASSERTION_FAILED_E = external constant [0 x i8], align 1
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6crunchRN5sc_dt9sc_signedE5int31ii(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  br label %6

5:                                                ; preds = %15
  ret void

6:                                                ; preds = %4, %15
  %.013 = phi i32 [ 0, %4 ], [ %16, %15 ]
  %.sroa.0.012 = phi i32 [ %1, %4 ], [ %10, %15 ]
  %7 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5sc_dt9sc_signedmLEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %2)
  %8 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5sc_dt9sc_signedpLEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %3)
  %9 = mul i32 %.sroa.0.012, %2
  %10 = add i32 %9, %3
  %11 = shl i32 %10, 1
  %12 = ashr exact i32 %11, 1
  %13 = tail call noundef zeroext i1 @_ZN5sc_dteqERKNS_9sc_signedEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %12)
  br i1 %13, label %15, label %14

14:                                               ; preds = %6
  tail call void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef 3, ptr noundef nonnull @_ZN7sc_core23SC_ID_ASSERTION_FAILED_E, ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 73)
  br label %15

15:                                               ; preds = %6, %14
  %16 = add nuw nsw i32 %.013, 1
  %exitcond.not = icmp eq i32 %16, 100000
  br i1 %exitcond.not, label %5, label %6, !llvm.loop !5
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN5sc_dt9sc_signedmLEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN5sc_dt9sc_signedpLEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5sc_dteqERKNS_9sc_signedEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1

declare void @_ZN7sc_core17sc_report_handler6reportENS_11sc_severityEPKcS3_S3_i(i32 noundef, ptr noundef, ptr noundef, ptr noundef, 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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass