; LLVM IR from gem5/gem5 :: util/m5/src (args)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4Args4packERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPmi(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 8, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = mul i64 %16, 8
  store i64 %17, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #3
  store ptr %19, ptr %10, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load i64, ptr %9, align 8, !tbaa !11
  call void @llvm.memset.p0.i64(ptr align 8 %20, i8 0, i64 %21, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %22) #3
  store i64 %23, ptr %11, align 8, !tbaa !11
  %24 = load i64, ptr %11, align 8, !tbaa !11
  %25 = load i64, ptr %9, align 8, !tbaa !11
  %26 = icmp ugt i64 %24, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %65

28:                                               ; preds = %3
  br label %29

29:                                               ; preds = %61, %28
  %30 = load i64, ptr %11, align 8, !tbaa !11
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %64

32:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %56, %32
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = icmp ult i64 %35, 8
  br i1 %36, label %37, label %40

37:                                               ; preds = %33
  %38 = load i64, ptr %11, align 8, !tbaa !11
  %39 = icmp ne i64 %38, 0
  br label %40

40:                                               ; preds = %37, %33
  %41 = phi i1 [ false, %33 ], [ %39, %37 ]
  br i1 %41, label %43, label %42

42:                                               ; preds = %40
  store i32 4, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %61

43:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = mul nsw i32 %44, 8
  store i32 %45, ptr %14, align 4, !tbaa !9
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i32 1
  store ptr %47, ptr %10, align 8, !tbaa !5
  %48 = load i8, ptr %46, align 1, !tbaa !13
  %49 = zext i8 %48 to i64
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = shl i64 %49, %51
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !11
  %55 = or i64 %54, %52
  store i64 %55, ptr %53, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %56

56:                                               ; preds = %43
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %13, align 4, !tbaa !9
  %59 = load i64, ptr %11, align 8, !tbaa !11
  %60 = add i64 %59, -1
  store i64 %60, ptr %11, align 8, !tbaa !11
  br label %33, !llvm.loop !14

61:                                               ; preds = %42
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds i64, ptr %62, i32 1
  store ptr %63, ptr %6, align 8, !tbaa !5
  br label %29, !llvm.loop !16

64:                                               ; preds = %29
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %65

65:                                               ; preds = %64, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %66 = load i1, ptr %4, align 1
  ret i1 %66
}

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

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"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 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4Args4packERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPmi(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr nocapture noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = sext i32 %2 to i64
  %5 = shl nsw i64 %4, 3
  %6 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  tail call void @llvm.memset.p0.i64(ptr align 8 %1, i8 0, i64 %5, i1 false)
  %7 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %8 = add i64 %7, -1
  %or.cond.not = icmp ult i64 %8, %5
  br i1 %or.cond.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %3, %15
  %.01830 = phi i64 [ %.lcssa, %15 ], [ %7, %3 ]
  %.01929 = phi ptr [ %.lcssa36, %15 ], [ %6, %3 ]
  %.02128 = phi ptr [ %16, %15 ], [ %1, %3 ]
  %9 = add i64 %.01830, -1
  %.021.promoted = load i64, ptr %.02128, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %.01929, i64 1
  %11 = load i8, ptr %.01929, align 1, !tbaa !9
  %12 = zext i8 %11 to i64
  %13 = or i64 %.021.promoted, %12
  store i64 %13, ptr %.02128, align 8, !tbaa !5
  %14 = add i64 %.01830, -1
  %exitcond.not = icmp eq i64 %9, 0
  br i1 %exitcond.not, label %15, label %17, !llvm.loop !10

15:                                               ; preds = %59, %52, %45, %38, %31, %24, %17, %.preheader
  %.lcssa36 = phi ptr [ %10, %.preheader ], [ %18, %17 ], [ %25, %24 ], [ %32, %31 ], [ %39, %38 ], [ %46, %45 ], [ %53, %52 ], [ %60, %59 ]
  %.lcssa = phi i64 [ %14, %.preheader ], [ %23, %17 ], [ %30, %24 ], [ %37, %31 ], [ %44, %38 ], [ %51, %45 ], [ %58, %52 ], [ %65, %59 ]
  %16 = getelementptr inbounds i8, ptr %.02128, i64 8
  %.not = icmp eq i64 %.lcssa, 0
  br i1 %.not, label %.loopexit, label %.preheader, !llvm.loop !12

17:                                               ; preds = %.preheader
  %18 = getelementptr inbounds i8, ptr %.01929, i64 2
  %19 = load i8, ptr %10, align 1, !tbaa !9
  %20 = zext i8 %19 to i64
  %21 = shl nuw nsw i64 %20, 8
  %22 = or i64 %21, %13
  store i64 %22, ptr %.02128, align 8, !tbaa !5
  %23 = add i64 %.01830, -2
  %exitcond.not.1 = icmp eq i64 %9, 1
  br i1 %exitcond.not.1, label %15, label %24, !llvm.loop !10

24:                                               ; preds = %17
  %25 = getelementptr inbounds i8, ptr %.01929, i64 3
  %26 = load i8, ptr %18, align 1, !tbaa !9
  %27 = zext i8 %26 to i64
  %28 = shl nuw nsw i64 %27, 16
  %29 = or i64 %28, %22
  store i64 %29, ptr %.02128, align 8, !tbaa !5
  %30 = add i64 %.01830, -3
  %exitcond.not.2 = icmp eq i64 %9, 2
  br i1 %exitcond.not.2, label %15, label %31, !llvm.loop !10

31:                                               ; preds = %24
  %32 = getelementptr inbounds i8, ptr %.01929, i64 4
  %33 = load i8, ptr %25, align 1, !tbaa !9
  %34 = zext i8 %33 to i64
  %35 = shl nuw nsw i64 %34, 24
  %36 = or i64 %35, %29
  store i64 %36, ptr %.02128, align 8, !tbaa !5
  %37 = add i64 %.01830, -4
  %exitcond.not.3 = icmp eq i64 %9, 3
  br i1 %exitcond.not.3, label %15, label %38, !llvm.loop !10

38:                                               ; preds = %31
  %39 = getelementptr inbounds i8, ptr %.01929, i64 5
  %40 = load i8, ptr %32, align 1, !tbaa !9
  %41 = zext i8 %40 to i64
  %42 = shl nuw nsw i64 %41, 32
  %43 = or i64 %42, %36
  store i64 %43, ptr %.02128, align 8, !tbaa !5
  %44 = add i64 %.01830, -5
  %exitcond.not.4 = icmp eq i64 %9, 4
  br i1 %exitcond.not.4, label %15, label %45, !llvm.loop !10

45:                                               ; preds = %38
  %46 = getelementptr inbounds i8, ptr %.01929, i64 6
  %47 = load i8, ptr %39, align 1, !tbaa !9
  %48 = zext i8 %47 to i64
  %49 = shl nuw nsw i64 %48, 40
  %50 = or i64 %49, %43
  store i64 %50, ptr %.02128, align 8, !tbaa !5
  %51 = add i64 %.01830, -6
  %exitcond.not.5 = icmp eq i64 %9, 5
  br i1 %exitcond.not.5, label %15, label %52, !llvm.loop !10

52:                                               ; preds = %45
  %53 = getelementptr inbounds i8, ptr %.01929, i64 7
  %54 = load i8, ptr %46, align 1, !tbaa !9
  %55 = zext i8 %54 to i64
  %56 = shl nuw nsw i64 %55, 48
  %57 = or i64 %56, %50
  store i64 %57, ptr %.02128, align 8, !tbaa !5
  %58 = add i64 %.01830, -7
  %exitcond.not.6 = icmp eq i64 %9, 6
  br i1 %exitcond.not.6, label %15, label %59, !llvm.loop !10

59:                                               ; preds = %52
  %60 = getelementptr inbounds i8, ptr %.01929, i64 8
  %61 = load i8, ptr %53, align 1, !tbaa !9
  %62 = zext i8 %61 to i64
  %63 = shl nuw i64 %62, 56
  %64 = or i64 %63, %57
  store i64 %64, ptr %.02128, align 8, !tbaa !5
  %65 = add i64 %.01830, -8
  br label %15

.loopexit:                                        ; preds = %15, %3
  %66 = icmp ule i64 %7, %5
  ret i1 %66
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; Effective O3 passes: GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass