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

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

@softfloat_approxRecip_1k0s = external constant [16 x i16], align 16
@softfloat_approxRecip_1k1s = external constant [16 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @softfloat_approxRecip32_1(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = lshr i32 %9, 27
  %11 = and i32 %10, 15
  store i32 %11, ptr %3, align 4, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = lshr i32 %12, 11
  %14 = trunc i32 %13 to i16
  store i16 %14, ptr %4, align 2, !tbaa !9
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [16 x i16], ptr @softfloat_approxRecip_1k0s, i64 0, i64 %16
  %18 = load i16, ptr %17, align 2, !tbaa !9
  %19 = zext i16 %18 to i64
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [16 x i16], ptr @softfloat_approxRecip_1k1s, i64 0, i64 %21
  %23 = load i16, ptr %22, align 2, !tbaa !9
  %24 = zext i16 %23 to i64
  %25 = load i16, ptr %4, align 2, !tbaa !9
  %26 = zext i16 %25 to i64
  %27 = mul i64 %24, %26
  %28 = lshr i64 %27, 20
  %29 = sub i64 %19, %28
  %30 = trunc i64 %29 to i16
  store i16 %30, ptr %5, align 2, !tbaa !9
  %31 = load i16, ptr %5, align 2, !tbaa !9
  %32 = zext i16 %31 to i64
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = mul i64 %32, %34
  %36 = lshr i64 %35, 7
  %37 = xor i64 %36, -1
  %38 = trunc i64 %37 to i32
  store i32 %38, ptr %6, align 4, !tbaa !5
  %39 = load i16, ptr %5, align 2, !tbaa !9
  %40 = zext i16 %39 to i64
  %41 = shl i64 %40, 16
  %42 = load i16, ptr %5, align 2, !tbaa !9
  %43 = zext i16 %42 to i64
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = zext i32 %44 to i64
  %46 = mul i64 %43, %45
  %47 = lshr i64 %46, 24
  %48 = add i64 %41, %47
  store i64 %48, ptr %7, align 8, !tbaa !11
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = zext i32 %49 to i64
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  %53 = mul i64 %50, %52
  %54 = lshr i64 %53, 32
  %55 = trunc i64 %54 to i32
  store i32 %55, ptr %8, align 4, !tbaa !5
  %56 = load i64, ptr %7, align 8, !tbaa !11
  %57 = trunc i64 %56 to i32
  %58 = zext i32 %57 to i64
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = zext i32 %59 to i64
  %61 = mul i64 %58, %60
  %62 = lshr i64 %61, 48
  %63 = load i64, ptr %7, align 8, !tbaa !11
  %64 = add i64 %63, %62
  store i64 %64, ptr %7, align 8, !tbaa !11
  %65 = load i64, ptr %7, align 8, !tbaa !11
  %66 = trunc i64 %65 to i32
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %66
}

; 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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"

@softfloat_approxRecip_1k0s = external local_unnamed_addr constant [16 x i16], align 16
@softfloat_approxRecip_1k1s = external local_unnamed_addr constant [16 x i16], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @softfloat_approxRecip32_1(i32 noundef %0) local_unnamed_addr #0 {
  %2 = lshr i32 %0, 27
  %3 = and i32 %2, 15
  %4 = lshr i32 %0, 11
  %5 = zext nneg i32 %3 to i64
  %6 = getelementptr inbounds [16 x i16], ptr @softfloat_approxRecip_1k0s, i64 0, i64 %5
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %8 = getelementptr inbounds [16 x i16], ptr @softfloat_approxRecip_1k1s, i64 0, i64 %5
  %9 = load i16, ptr %8, align 2, !tbaa !5
  %10 = zext i16 %9 to i32
  %11 = and i32 %4, 65535
  %12 = mul nuw i32 %11, %10
  %13 = lshr i32 %12, 20
  %14 = trunc nuw nsw i32 %13 to i16
  %15 = sub i16 %7, %14
  %16 = zext i16 %15 to i64
  %17 = zext i32 %0 to i64
  %18 = mul nuw nsw i64 %16, %17
  %19 = lshr i64 %18, 7
  %20 = shl nuw nsw i64 %16, 16
  %21 = and i64 %19, 4294967295
  %22 = xor i64 %21, 4294967295
  %23 = mul nuw nsw i64 %22, %16
  %24 = lshr i64 %23, 24
  %25 = add nuw nsw i64 %24, %20
  %26 = mul nuw i64 %22, %22
  %27 = lshr i64 %26, 32
  %28 = and i64 %25, 4294967295
  %29 = mul nuw i64 %28, %27
  %30 = lshr i64 %29, 48
  %31 = add nuw nsw i64 %30, %25
  %32 = trunc i64 %31 to i32
  ret i32 %32
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass