; LLVM IR from gem5/gem5 :: ext/softfloat (s_shortShiftLeftM)

; 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: nounwind uwtable
define dso_local void @softfloat_shortShiftLeftM(i8 noundef zeroext %0, ptr noundef %1, i8 noundef zeroext %2, ptr noundef %3) #0 {
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i8 %0, ptr %5, align 1, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !8
  store i8 %2, ptr %7, align 1, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %14 = load i8, ptr %7, align 1, !tbaa !5
  %15 = zext i8 %14 to i32
  %16 = sub nsw i32 0, %15
  %17 = trunc i32 %16 to i8
  store i8 %17, ptr %9, align 1, !tbaa !5
  %18 = load i8, ptr %5, align 1, !tbaa !5
  %19 = zext i8 %18 to i32
  %20 = sub nsw i32 %19, 1
  store i32 %20, ptr %10, align 4, !tbaa !10
  store i32 0, ptr %11, align 4, !tbaa !10
  %21 = load ptr, ptr %6, align 8, !tbaa !8
  %22 = load i32, ptr %10, align 4, !tbaa !10
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %21, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = load i8, ptr %7, align 1, !tbaa !5
  %27 = zext i8 %26 to i32
  %28 = shl i32 %25, %27
  store i32 %28, ptr %12, align 4, !tbaa !10
  br label %29

29:                                               ; preds = %33, %4
  %30 = load i32, ptr %10, align 4, !tbaa !10
  %31 = load i32, ptr %11, align 4, !tbaa !10
  %32 = icmp ne i32 %30, %31
  br i1 %32, label %33, label %57

33:                                               ; preds = %29
  %34 = load ptr, ptr %6, align 8, !tbaa !8
  %35 = load i32, ptr %10, align 4, !tbaa !10
  %36 = sub i32 %35, 1
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %34, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !10
  store i32 %39, ptr %13, align 4, !tbaa !10
  %40 = load i32, ptr %12, align 4, !tbaa !10
  %41 = load i32, ptr %13, align 4, !tbaa !10
  %42 = load i8, ptr %9, align 1, !tbaa !5
  %43 = zext i8 %42 to i32
  %44 = and i32 %43, 31
  %45 = lshr i32 %41, %44
  %46 = or i32 %40, %45
  %47 = load ptr, ptr %8, align 8, !tbaa !8
  %48 = load i32, ptr %10, align 4, !tbaa !10
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  store i32 %46, ptr %50, align 4, !tbaa !10
  %51 = load i32, ptr %10, align 4, !tbaa !10
  %52 = sub i32 %51, 1
  store i32 %52, ptr %10, align 4, !tbaa !10
  %53 = load i32, ptr %13, align 4, !tbaa !10
  %54 = load i8, ptr %7, align 1, !tbaa !5
  %55 = zext i8 %54 to i32
  %56 = shl i32 %53, %55
  store i32 %56, ptr %12, align 4, !tbaa !10
  br label %29, !llvm.loop !12

57:                                               ; preds = %29
  %58 = load i32, ptr %12, align 4, !tbaa !10
  %59 = load ptr, ptr %8, align 8, !tbaa !8
  %60 = load i32, ptr %10, align 4, !tbaa !10
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds i32, ptr %59, i64 %61
  store i32 %58, ptr %62, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @softfloat_shortShiftLeftM(i8 noundef zeroext %0, ptr nocapture noundef readonly %1, i8 noundef zeroext %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = zext nneg i8 %2 to i32
  %6 = zext i8 %0 to i32
  %7 = add nsw i32 %6, -1
  %8 = zext i32 %7 to i64
  %9 = getelementptr inbounds i32, ptr %1, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %.01920 = shl i32 %10, %5
  %.not21 = icmp eq i32 %7, 0
  br i1 %.not21, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %11 = sub i8 0, %2
  %12 = and i8 %11, 31
  %13 = zext nneg i8 %12 to i32
  %xtraiter = and i64 %8, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %.lr.ph
  %14 = add nsw i64 %8, -1
  %15 = getelementptr inbounds i32, ptr %1, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = lshr i32 %16, %13
  %18 = or i32 %17, %.01920
  %19 = getelementptr inbounds i32, ptr %3, i64 %8
  store i32 %18, ptr %19, align 4, !tbaa !5
  %.019.prol = shl i32 %16, %5
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph
  %.019.lcssa28.unr = phi i32 [ poison, %.lr.ph ], [ %.019.prol, %.prol.loopexit.unr-lcssa ]
  %indvars.iv.unr = phi i64 [ %8, %.lr.ph ], [ %14, %.prol.loopexit.unr-lcssa ]
  %.01923.unr = phi i32 [ %.01920, %.lr.ph ], [ %.019.prol, %.prol.loopexit.unr-lcssa ]
  %20 = icmp eq i32 %7, 1
  br i1 %20, label %._crit_edge, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %indvars.iv = phi i64 [ %27, %.lr.ph.new ], [ %indvars.iv.unr, %.prol.loopexit ]
  %.01923 = phi i32 [ %.019.1, %.lr.ph.new ], [ %.01923.unr, %.prol.loopexit ]
  %21 = add nsw i64 %indvars.iv, -1
  %22 = getelementptr inbounds i32, ptr %1, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = lshr i32 %23, %13
  %25 = or i32 %24, %.01923
  %26 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv
  store i32 %25, ptr %26, align 4, !tbaa !5
  %.019 = shl i32 %23, %5
  %27 = add nsw i64 %indvars.iv, -2
  %28 = getelementptr inbounds i32, ptr %1, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = lshr i32 %29, %13
  %31 = or i32 %30, %.019
  %32 = getelementptr inbounds i32, ptr %3, i64 %21
  store i32 %31, ptr %32, align 4, !tbaa !5
  %.019.1 = shl i32 %29, %5
  %.not.wide.1 = icmp eq i64 %27, 0
  br i1 %.not.wide.1, label %._crit_edge, label %.lr.ph.new, !llvm.loop !9

._crit_edge:                                      ; preds = %.prol.loopexit, %.lr.ph.new, %4
  %.019.lcssa = phi i32 [ %.01920, %4 ], [ %.019.lcssa28.unr, %.prol.loopexit ], [ %.019.1, %.lr.ph.new ]
  store i32 %.019.lcssa, ptr %3, align 4, !tbaa !5
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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