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

; 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.extFloat80M = type { i64, i16 }

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @softfloat_tryPropagateNaNExtF80M(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.extFloat80M, ptr %11, i32 0, i32 1
  %13 = load i16, ptr %12, align 8, !tbaa !9
  %14 = zext i16 %13 to i64
  store i64 %14, ptr %8, align 8, !tbaa !13
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.extFloat80M, ptr %15, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !14
  store i64 %17, ptr %9, align 8, !tbaa !13
  %18 = load i64, ptr %8, align 8, !tbaa !13
  %19 = and i64 %18, 32767
  %20 = icmp eq i64 %19, 32767
  br i1 %20, label %21, label %26

21:                                               ; preds = %3
  %22 = load i64, ptr %9, align 8, !tbaa !13
  %23 = and i64 %22, 9223372036854775807
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  br label %43

26:                                               ; preds = %21, %3
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.extFloat80M, ptr %27, i32 0, i32 1
  %29 = load i16, ptr %28, align 8, !tbaa !9
  %30 = zext i16 %29 to i64
  store i64 %30, ptr %8, align 8, !tbaa !13
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.extFloat80M, ptr %31, i32 0, i32 0
  %33 = load i64, ptr %32, align 8, !tbaa !14
  store i64 %33, ptr %9, align 8, !tbaa !13
  %34 = load i64, ptr %8, align 8, !tbaa !13
  %35 = and i64 %34, 32767
  %36 = icmp eq i64 %35, 32767
  br i1 %36, label %37, label %42

37:                                               ; preds = %26
  %38 = load i64, ptr %9, align 8, !tbaa !13
  %39 = and i64 %38, 9223372036854775807
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  br label %43

42:                                               ; preds = %37, %26
  store i1 false, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %47

43:                                               ; preds = %41, %25
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  call void @softfloat_propagateNaNExtF80M(ptr noundef %44, ptr noundef %45, ptr noundef %46)
  store i1 true, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %47

47:                                               ; preds = %43, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %48 = load i1, ptr %4, align 1
  ret i1 %48
}

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

declare void @softfloat_propagateNaNExtF80M(ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @softfloat_tryPropagateNaNExtF80M(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i16, ptr %4, align 8, !tbaa !5
  %6 = and i16 %5, 32767
  %7 = icmp eq i16 %6, 32767
  br i1 %7, label %8, label %11

8:                                                ; preds = %3
  %9 = load i64, ptr %0, align 8, !tbaa !11
  %10 = and i64 %9, 9223372036854775807
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %11, label %19

11:                                               ; preds = %8, %3
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load i16, ptr %12, align 8, !tbaa !5
  %14 = and i16 %13, 32767
  %15 = icmp eq i16 %14, 32767
  br i1 %15, label %16, label %20

16:                                               ; preds = %11
  %17 = load i64, ptr %1, align 8, !tbaa !11
  %18 = and i64 %17, 9223372036854775807
  %.not11 = icmp eq i64 %18, 0
  br i1 %.not11, label %20, label %19

19:                                               ; preds = %16, %8
  tail call void @softfloat_propagateNaNExtF80M(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2) #2
  br label %20

20:                                               ; preds = %11, %16, %19
  %.0 = phi i1 [ true, %19 ], [ false, %16 ], [ false, %11 ]
  ret i1 %.0
}

declare void @softfloat_propagateNaNExtF80M(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 = { "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 = { 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, !10, i64 8}
!6 = !{!"extFloat80M", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass