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

; 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.float32_t = type { i32 }
%union.ui32_f32 = type { i32 }

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @f32_max(i32 %0, i32 %1) #2 {
  %3 = alloca %struct.float32_t, align 4
  %4 = alloca %struct.float32_t, align 4
  %5 = alloca %struct.float32_t, align 4
  %6 = alloca i8, align 1
  %7 = alloca %union.ui32_f32, align 4
  %8 = alloca i32, align 4
  %9 = getelementptr inbounds %struct.float32_t, ptr %4, i32 0, i32 0
  store i32 %0, ptr %9, align 4
  %10 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  store i32 %1, ptr %10, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  %11 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %12 = load i32, ptr %11, align 4
  %13 = getelementptr inbounds %struct.float32_t, ptr %4, i32 0, i32 0
  %14 = load i32, ptr %13, align 4
  %15 = call zeroext i1 @f32_lt_quiet(i32 %12, i32 %14)
  br i1 %15, label %29, label %16

16:                                               ; preds = %2
  %17 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %18 = load i32, ptr %17, align 4
  %19 = getelementptr inbounds %struct.float32_t, ptr %4, i32 0, i32 0
  %20 = load i32, ptr %19, align 4
  %21 = call zeroext i1 @f32_eq(i32 %18, i32 %20)
  br i1 %21, label %22, label %27

22:                                               ; preds = %16
  %23 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = lshr i32 %24, 31
  %26 = icmp ne i32 %25, 0
  br label %27

27:                                               ; preds = %22, %16
  %28 = phi i1 [ false, %16 ], [ %26, %22 ]
  br label %29

29:                                               ; preds = %27, %2
  %30 = phi i1 [ true, %2 ], [ %28, %27 ]
  %31 = zext i1 %30 to i8
  store i8 %31, ptr %6, align 1, !tbaa !10
  %32 = getelementptr inbounds %struct.float32_t, ptr %4, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = xor i32 %33, -1
  %35 = and i32 %34, 2139095040
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %54

37:                                               ; preds = %29
  %38 = getelementptr inbounds %struct.float32_t, ptr %4, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = and i32 %39, 8388607
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %54

42:                                               ; preds = %37
  %43 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = xor i32 %44, -1
  %46 = and i32 %45, 2139095040
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %54

48:                                               ; preds = %42
  %49 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = and i32 %50, 8388607
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 2143289344, ptr %7, align 4, !tbaa !12
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %7, i64 4, i1 false), !tbaa.struct !13
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %71

54:                                               ; preds = %48, %42, %37, %29
  %55 = load i8, ptr %6, align 1, !tbaa !10, !range !15, !noundef !16
  %56 = trunc i8 %55 to i1
  br i1 %56, label %68, label %57

57:                                               ; preds = %54
  %58 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = xor i32 %59, -1
  %61 = and i32 %60, 2139095040
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %69

63:                                               ; preds = %57
  %64 = getelementptr inbounds %struct.float32_t, ptr %5, i32 0, i32 0
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = and i32 %65, 8388607
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %63, %54
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %4, i64 4, i1 false), !tbaa.struct !13
  br label %70

69:                                               ; preds = %63, %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %5, i64 4, i1 false), !tbaa.struct !13
  br label %70

70:                                               ; preds = %69, %68
  store i32 1, ptr %8, align 4
  br label %71

71:                                               ; preds = %70, %53
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  %72 = getelementptr inbounds %struct.float32_t, ptr %3, i32 0, i32 0
  %73 = load i32, ptr %72, align 4
  ret i32 %73
}

declare zeroext i1 @f32_lt_quiet(i32, i32) #3

declare zeroext i1 @f32_eq(i32, i32) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !7, i64 0}
!6 = !{!"", !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{i64 0, i64 4, !14}
!14 = !{!7, !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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 i32 @f32_max(i32 %0, i32 %1) local_unnamed_addr #0 {
  %3 = tail call zeroext i1 @f32_lt_quiet(i32 %1, i32 %0) #2
  br i1 %3, label %9, label %4

4:                                                ; preds = %2
  %5 = tail call zeroext i1 @f32_eq(i32 %1, i32 %0) #2
  %6 = icmp slt i32 %1, 0
  %7 = select i1 %5, i1 %6, i1 false
  %8 = freeze i1 %7
  br label %9

9:                                                ; preds = %4, %2
  %cond.fr = phi i1 [ true, %2 ], [ %8, %4 ]
  %10 = and i32 %0, 2139095040
  %11 = icmp ne i32 %10, 2139095040
  %12 = and i32 %0, 8388607
  %.not = icmp eq i32 %12, 0
  %or.cond.not20.not24 = or i1 %11, %.not
  %13 = and i32 %1, 2139095040
  %14 = icmp ne i32 %13, 2139095040
  %15 = and i32 %1, 8388607
  %.not13 = icmp eq i32 %15, 0
  %16 = or i1 %14, %.not13
  %or.cond17 = select i1 %or.cond.not20.not24, i1 true, i1 %16
  %spec.select = select i1 %16, i32 %1, i32 %0
  %spec.select25 = select i1 %cond.fr, i32 %0, i32 %spec.select
  %.sroa.012.1 = select i1 %or.cond17, i32 %spec.select25, i32 2143289344
  ret i32 %.sroa.012.1
}

declare zeroext i1 @f32_lt_quiet(i32, i32) local_unnamed_addr #1

declare zeroext i1 @f32_eq(i32, i32) 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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass