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

; 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.3 = external hidden unnamed_addr constant [32 x i8], align 1
@_ZTI9jio_error = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.5 = external hidden unnamed_addr constant [61 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

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9jio_errorC2EPKcz(ptr noundef nonnull align 8 dereferenceable(44), ptr noundef, ...) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZN7j_errorD2Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr)

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

11:                                               ; preds = %2
  %12 = load float, ptr %5, align 4, !tbaa !11
  store float %12, ptr %6, align 4, !tbaa !11
  br label %51

13:                                               ; preds = %2
  %14 = load i32, ptr %5, align 4, !tbaa !11
  %15 = shl i32 %14, 24
  %16 = and i32 %15, -16777216
  %17 = load i32, ptr %5, align 4, !tbaa !11
  %18 = shl i32 %17, 8
  %19 = and i32 %18, 16711680
  %20 = or i32 %16, %19
  %21 = load i32, ptr %5, align 4, !tbaa !11
  %22 = ashr i32 %21, 8
  %23 = and i32 %22, 65280
  %24 = or i32 %20, %23
  %25 = load i32, ptr %5, align 4, !tbaa !11
  %26 = ashr i32 %25, 24
  %27 = and i32 %26, 255
  %28 = or i32 %24, %27
  store i32 %28, ptr %6, align 4, !tbaa !11
  br label %51

29:                                               ; preds = %2
  %30 = load i32, ptr %5, align 4, !tbaa !11
  %31 = shl i32 %30, 8
  %32 = and i32 %31, -16711936
  %33 = load i32, ptr %5, align 4, !tbaa !11
  %34 = ashr i32 %33, 8
  %35 = and i32 %34, 16711935
  %36 = or i32 %32, %35
  %37 = load i32, ptr %5, align 4, !tbaa !11
  %38 = and i32 %37, 65280
  %39 = icmp ne i32 %38, 0
  %40 = zext i1 %39 to i64
  %41 = select i1 %39, i32 1, i32 0
  %42 = sub i32 %36, %41
  store i32 %42, ptr %6, align 4, !tbaa !11
  br label %51

43:                                               ; preds = %2
  %44 = call ptr @__cxa_allocate_exception(i64 48) #5
  %45 = load i32, ptr @_ZL7machine, align 4, !tbaa !12
  invoke void (ptr, ptr, ...) @_ZN9jio_errorC2EPKcz(ptr noundef nonnull align 8 dereferenceable(44) %44, ptr noundef @.str.3, i32 noundef %45)
          to label %46 unwind label %47

46:                                               ; preds = %43
  call void @__cxa_throw(ptr %44, ptr @_ZTI9jio_error, ptr @_ZN7j_errorD2Ev) #6
  unreachable

47:                                               ; preds = %43
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %7, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %8, align 4
  call void @__cxa_free_exception(ptr %44) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %59

51:                                               ; preds = %29, %13, %11
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = call i64 @fwrite(ptr noundef %6, i64 noundef 4, i64 noundef 1, ptr noundef %52)
  %54 = icmp ne i64 %53, 1
  br i1 %54, label %55, label %58

55:                                               ; preds = %51
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.5) #5
  call void @exit(i32 noundef -1) #7
  unreachable

58:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void

59:                                               ; preds = %47
  %60 = load ptr, ptr %7, align 8
  %61 = load i32, ptr %8, align 4
  %62 = insertvalue { ptr, i32 } poison, ptr %60, 0
  %63 = insertvalue { ptr, i32 } %62, i32 %61, 1
  resume { ptr, i32 } %63
}

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

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 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 = { "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 #5 = { nounwind }
attributes #6 = { noreturn }
attributes #7 = { 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"

%union.unionT = type { float }

@_ZL7machine = external hidden local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [32 x i8], align 1
@_ZTI9jio_error = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.5 = external hidden unnamed_addr constant [61 x i8], align 1

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

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

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

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

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9jio_errorC2EPKcz(ptr noundef nonnull align 8 dereferenceable(44), ptr noundef, ...) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZN7j_errorD2Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local void @_Z11write_floatP8_IO_FILEf(ptr nocapture noundef %0, float noundef %1) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca %union.unionT, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #6
  %4 = load i32, ptr @_ZL7machine, align 4, !tbaa !5
  switch i32 %4, label %18 [
    i32 1, label %5
    i32 2, label %6
    i32 3, label %9
  ]

5:                                                ; preds = %2
  store float %1, ptr %3, align 4, !tbaa !9
  br label %24

6:                                                ; preds = %2
  %7 = bitcast float %1 to i32
  %8 = tail call i32 @llvm.bswap.i32(i32 %7)
  store i32 %8, ptr %3, align 4, !tbaa !9
  br label %24

9:                                                ; preds = %2
  %10 = bitcast float %1 to i32
  %11 = shl i32 %10, 8
  %12 = and i32 %11, -16711936
  %13 = lshr i32 %10, 8
  %14 = and i32 %13, 16711935
  %15 = or disjoint i32 %12, %14
  %16 = and i32 %10, 65280
  %.not = icmp ne i32 %16, 0
  %.neg = sext i1 %.not to i32
  %17 = add i32 %15, %.neg
  store i32 %17, ptr %3, align 4, !tbaa !9
  br label %24

18:                                               ; preds = %2
  %19 = tail call ptr @__cxa_allocate_exception(i64 48) #6
  %20 = load i32, ptr @_ZL7machine, align 4, !tbaa !5
  invoke void (ptr, ptr, ...) @_ZN9jio_errorC2EPKcz(ptr noundef nonnull align 8 dereferenceable(44) %19, ptr noundef nonnull @.str.3, i32 noundef %20)
          to label %21 unwind label %22

21:                                               ; preds = %18
  tail call void @__cxa_throw(ptr nonnull %19, ptr nonnull @_ZTI9jio_error, ptr nonnull @_ZN7j_errorD2Ev) #7
  unreachable

22:                                               ; preds = %18
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  resume { ptr, i32 } %23

24:                                               ; preds = %9, %6, %5
  %25 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 1, ptr noundef %0)
  %.not9 = icmp eq i64 %25, 1
  br i1 %.not9, label %29, label %26

26:                                               ; preds = %24
  %27 = load ptr, ptr @stderr, align 8, !tbaa !10
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.5) #8
  tail call void @exit(i32 noundef -1) #9
  unreachable

29:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #6
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { noreturn }
attributes #8 = { cold nounwind }
attributes #9 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}


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