; LLVM IR from kkumatani/distant_speech_recognition :: btk20_src/common/mach_ind_io.ll (Z12change_floatPf)

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

%union.unionT = type { float }

@_ZL7machine = external hidden global i32, align 4
@stderr = external global ptr, align 8
@.str.16 = external hidden unnamed_addr constant [45 x i8], align 1

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z12change_floatPf(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca %union.unionT, align 4
  %4 = alloca %union.unionT, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = load float, ptr %5, align 4, !tbaa !9
  store float %6, ptr %4, align 4, !tbaa !11
  store float %6, ptr %3, align 4, !tbaa !11
  %7 = load i32, ptr @_ZL7machine, align 4, !tbaa !12
  switch i32 %7, label %33 [
    i32 1, label %37
    i32 2, label %8
    i32 3, label %24
  ]

8:                                                ; preds = %1
  %9 = load i32, ptr %3, align 4, !tbaa !11
  %10 = shl i32 %9, 24
  %11 = and i32 %10, -16777216
  %12 = load i32, ptr %3, align 4, !tbaa !11
  %13 = shl i32 %12, 8
  %14 = and i32 %13, 16711680
  %15 = or i32 %11, %14
  %16 = load i32, ptr %3, align 4, !tbaa !11
  %17 = ashr i32 %16, 8
  %18 = and i32 %17, 65280
  %19 = or i32 %15, %18
  %20 = load i32, ptr %3, align 4, !tbaa !11
  %21 = ashr i32 %20, 24
  %22 = and i32 %21, 255
  %23 = or i32 %19, %22
  store i32 %23, ptr %4, align 4, !tbaa !11
  br label %37

24:                                               ; preds = %1
  %25 = load i32, ptr %3, align 4, !tbaa !11
  %26 = shl i32 %25, 8
  %27 = add nsw i32 %26, 256
  %28 = and i32 %27, -16711936
  %29 = load i32, ptr %3, align 4, !tbaa !11
  %30 = ashr i32 %29, 8
  %31 = and i32 %30, 16711935
  %32 = or i32 %28, %31
  store i32 %32, ptr %4, align 4, !tbaa !11
  br label %37

33:                                               ; preds = %1
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = load i32, ptr @_ZL7machine, align 4, !tbaa !12
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.16, i32 noundef %35) #4
  call void @exit(i32 noundef -1) #5
  unreachable

37:                                               ; preds = %24, %8, %1
  %38 = load float, ptr %4, align 4, !tbaa !11
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  store float %38, ptr %39, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { noreturn nounwind "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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"float", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !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"

@_ZL7machine = external hidden local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.16 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z12change_floatPf(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = load float, ptr %0, align 4, !tbaa !5
  %3 = load i32, ptr @_ZL7machine, align 4, !tbaa !9
  switch i32 %3, label %17 [
    i32 1, label %20
    i32 2, label %4
    i32 3, label %8
  ]

4:                                                ; preds = %1
  %5 = bitcast float %2 to i32
  %6 = tail call i32 @llvm.bswap.i32(i32 %5)
  %7 = bitcast i32 %6 to float
  br label %20

8:                                                ; preds = %1
  %9 = bitcast float %2 to i32
  %10 = shl i32 %9, 8
  %11 = add nsw i32 %10, 256
  %12 = and i32 %11, -16711936
  %13 = lshr i32 %9, 8
  %14 = and i32 %13, 16711935
  %15 = or disjoint i32 %12, %14
  %16 = bitcast i32 %15 to float
  br label %20

17:                                               ; preds = %1
  %18 = load ptr, ptr @stderr, align 8, !tbaa !11
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.16, i32 noundef %3) #4
  tail call void @exit(i32 noundef -1) #5
  unreachable

20:                                               ; preds = %8, %4, %1
  %.sroa.0.0 = phi float [ %16, %8 ], [ %7, %4 ], [ %2, %1 ]
  store float %.sroa.0.0, ptr %0, align 4, !tbaa !5
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.bswap.i32(i32) #3

attributes #0 = { nofree nounwind "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 = { noreturn nounwind "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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { cold nounwind }
attributes #5 = { noreturn 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 = !{!"float", !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 = !{!"any pointer", !7, i64 0}


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