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

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

; 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 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 #1 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 #2

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z18float_memorychangePfi(ptr noundef %0, i32 noundef %1) #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %union.unionT, align 4
  %8 = alloca %union.unionT, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %12 = load i32, ptr @_ZL7machine, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %66

15:                                               ; preds = %2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %62, %15
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %20, label %65

20:                                               ; preds = %16
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load float, ptr %21, align 4, !tbaa !11
  store float %22, ptr %7, align 4, !tbaa !13
  %23 = load i32, ptr @_ZL7machine, align 4, !tbaa !9
  switch i32 %23, label %49 [
    i32 2, label %24
    i32 3, label %40
  ]

24:                                               ; preds = %20
  %25 = load i32, ptr %7, align 4, !tbaa !13
  %26 = shl i32 %25, 24
  %27 = and i32 %26, -16777216
  %28 = load i32, ptr %7, align 4, !tbaa !13
  %29 = shl i32 %28, 8
  %30 = and i32 %29, 16711680
  %31 = or i32 %27, %30
  %32 = load i32, ptr %7, align 4, !tbaa !13
  %33 = ashr i32 %32, 8
  %34 = and i32 %33, 65280
  %35 = or i32 %31, %34
  %36 = load i32, ptr %7, align 4, !tbaa !13
  %37 = ashr i32 %36, 24
  %38 = and i32 %37, 255
  %39 = or i32 %35, %38
  store i32 %39, ptr %8, align 4, !tbaa !13
  br label %57

40:                                               ; preds = %20
  %41 = load i32, ptr %7, align 4, !tbaa !13
  %42 = shl i32 %41, 8
  %43 = add nsw i32 %42, 256
  %44 = and i32 %43, -16711936
  %45 = load i32, ptr %7, align 4, !tbaa !13
  %46 = ashr i32 %45, 8
  %47 = and i32 %46, 16711935
  %48 = or i32 %44, %47
  store i32 %48, ptr %8, align 4, !tbaa !13
  br label %57

49:                                               ; preds = %20
  %50 = call ptr @__cxa_allocate_exception(i64 48) #3
  %51 = load i32, ptr @_ZL7machine, align 4, !tbaa !9
  invoke void (ptr, ptr, ...) @_ZN9jio_errorC2EPKcz(ptr noundef nonnull align 8 dereferenceable(44) %50, ptr noundef @.str.3, i32 noundef %51)
          to label %52 unwind label %53

52:                                               ; preds = %49
  call void @__cxa_throw(ptr %50, ptr @_ZTI9jio_error, ptr @_ZN7j_errorD2Ev) #4
  unreachable

53:                                               ; preds = %49
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %10, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %11, align 4
  call void @__cxa_free_exception(ptr %50) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %68

57:                                               ; preds = %40, %24
  %58 = load float, ptr %8, align 4, !tbaa !13
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  store float %58, ptr %59, align 4, !tbaa !11
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds float, ptr %60, i32 1
  store ptr %61, ptr %4, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %57
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !14

65:                                               ; preds = %16
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %66

66:                                               ; preds = %65, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %67 = load i32, ptr %3, align 4
  ret i32 %67

68:                                               ; preds = %53
  %69 = load ptr, ptr %10, align 8
  %70 = load i32, ptr %11, align 4
  %71 = insertvalue { ptr, i32 } poison, ptr %69, 0
  %72 = insertvalue { ptr, i32 } %71, i32 %70, 1
  resume { ptr, i32 } %72
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = { nounwind }
attributes #4 = { noreturn }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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

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 #0 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 #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z18float_memorychangePfi(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = load i32, ptr @_ZL7machine, align 4, !tbaa !5
  %4 = icmp ne i32 %3, 1
  %5 = icmp sgt i32 %1, 0
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %2
  %6 = and i32 %3, -2
  %switch = icmp eq i32 %6, 2
  br i1 %switch, label %.lr.ph.split, label %41

.lr.ph.split:                                     ; preds = %.lr.ph
  %cond = icmp eq i32 %3, 2
  %7 = zext nneg i32 %1 to i64
  %min.iters.check28 = icmp ult i32 %1, 8
  br i1 %cond, label %.lr.ph.split.split.us.preheader, label %.lr.ph.split.split.preheader

.lr.ph.split.split.preheader:                     ; preds = %.lr.ph.split
  br i1 %min.iters.check28, label %.lr.ph.split.split.preheader46, label %vector.ph

.lr.ph.split.split.preheader46:                   ; preds = %middle.block, %.lr.ph.split.split.preheader
  %.01417.ph = phi ptr [ %0, %.lr.ph.split.split.preheader ], [ %ind.end, %middle.block ]
  %.01516.ph = phi i32 [ 0, %.lr.ph.split.split.preheader ], [ %ind.end22, %middle.block ]
  br label %.lr.ph.split.split

vector.ph:                                        ; preds = %.lr.ph.split.split.preheader
  %n.vec = and i64 %7, 2147483640
  %8 = shl nuw nsw i64 %n.vec, 2
  %ind.end = getelementptr i8, ptr %0, i64 %8
  %ind.end22 = trunc nuw nsw i64 %n.vec to i32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 2
  %next.gep = getelementptr i8, ptr %0, i64 %offset.idx
  %9 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <4 x i32>, ptr %next.gep, align 4, !tbaa !9
  %wide.load25 = load <4 x i32>, ptr %9, align 4, !tbaa !9
  %10 = shl <4 x i32> %wide.load, <i32 8, i32 8, i32 8, i32 8>
  %11 = shl <4 x i32> %wide.load25, <i32 8, i32 8, i32 8, i32 8>
  %12 = add nsw <4 x i32> %10, <i32 256, i32 256, i32 256, i32 256>
  %13 = add nsw <4 x i32> %11, <i32 256, i32 256, i32 256, i32 256>
  %14 = and <4 x i32> %12, <i32 -16711936, i32 -16711936, i32 -16711936, i32 -16711936>
  %15 = and <4 x i32> %13, <i32 -16711936, i32 -16711936, i32 -16711936, i32 -16711936>
  %16 = lshr <4 x i32> %wide.load, <i32 8, i32 8, i32 8, i32 8>
  %17 = lshr <4 x i32> %wide.load25, <i32 8, i32 8, i32 8, i32 8>
  %18 = and <4 x i32> %16, <i32 16711935, i32 16711935, i32 16711935, i32 16711935>
  %19 = and <4 x i32> %17, <i32 16711935, i32 16711935, i32 16711935, i32 16711935>
  %20 = or disjoint <4 x i32> %14, %18
  %21 = or disjoint <4 x i32> %15, %19
  store <4 x i32> %20, ptr %next.gep, align 4, !tbaa !9
  store <4 x i32> %21, ptr %9, align 4, !tbaa !9
  %index.next = add nuw i64 %index, 8
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %7
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.split.split.preheader46

.lr.ph.split.split.us.preheader:                  ; preds = %.lr.ph.split
  br i1 %min.iters.check28, label %.lr.ph.split.split.us.preheader45, label %vector.ph29

vector.ph29:                                      ; preds = %.lr.ph.split.split.us.preheader
  %n.vec31 = and i64 %7, 2147483640
  %23 = shl nuw nsw i64 %n.vec31, 2
  %ind.end32 = getelementptr i8, ptr %0, i64 %23
  %ind.end34 = trunc nuw nsw i64 %n.vec31 to i32
  br label %vector.body36

vector.body36:                                    ; preds = %vector.body36, %vector.ph29
  %index37 = phi i64 [ 0, %vector.ph29 ], [ %index.next43, %vector.body36 ]
  %offset.idx38 = shl i64 %index37, 2
  %next.gep39 = getelementptr i8, ptr %0, i64 %offset.idx38
  %24 = getelementptr i8, ptr %next.gep39, i64 16
  %wide.load41 = load <4 x i32>, ptr %next.gep39, align 4, !tbaa !9
  %wide.load42 = load <4 x i32>, ptr %24, align 4, !tbaa !9
  %25 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %wide.load41)
  %26 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %wide.load42)
  store <4 x i32> %25, ptr %next.gep39, align 4, !tbaa !9
  store <4 x i32> %26, ptr %24, align 4, !tbaa !9
  %index.next43 = add nuw i64 %index37, 8
  %27 = icmp eq i64 %index.next43, %n.vec31
  br i1 %27, label %middle.block26, label %vector.body36, !llvm.loop !15

middle.block26:                                   ; preds = %vector.body36
  %cmp.n44 = icmp eq i64 %n.vec31, %7
  br i1 %cmp.n44, label %.loopexit, label %.lr.ph.split.split.us.preheader45

.lr.ph.split.split.us.preheader45:                ; preds = %middle.block26, %.lr.ph.split.split.us.preheader
  %.01417.us.ph = phi ptr [ %0, %.lr.ph.split.split.us.preheader ], [ %ind.end32, %middle.block26 ]
  %.01516.us.ph = phi i32 [ 0, %.lr.ph.split.split.us.preheader ], [ %ind.end34, %middle.block26 ]
  br label %.lr.ph.split.split.us

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split.split.us.preheader45, %.lr.ph.split.split.us
  %.01417.us = phi ptr [ %30, %.lr.ph.split.split.us ], [ %.01417.us.ph, %.lr.ph.split.split.us.preheader45 ]
  %.01516.us = phi i32 [ %31, %.lr.ph.split.split.us ], [ %.01516.us.ph, %.lr.ph.split.split.us.preheader45 ]
  %28 = load i32, ptr %.01417.us, align 4, !tbaa !9
  %29 = tail call i32 @llvm.bswap.i32(i32 %28)
  store i32 %29, ptr %.01417.us, align 4, !tbaa !9
  %30 = getelementptr inbounds i8, ptr %.01417.us, i64 4
  %31 = add nuw nsw i32 %.01516.us, 1
  %exitcond19.not = icmp eq i32 %31, %1
  br i1 %exitcond19.not, label %.loopexit, label %.lr.ph.split.split.us, !llvm.loop !16

.lr.ph.split.split:                               ; preds = %.lr.ph.split.split.preheader46, %.lr.ph.split.split
  %.01417 = phi ptr [ %39, %.lr.ph.split.split ], [ %.01417.ph, %.lr.ph.split.split.preheader46 ]
  %.01516 = phi i32 [ %40, %.lr.ph.split.split ], [ %.01516.ph, %.lr.ph.split.split.preheader46 ]
  %32 = load i32, ptr %.01417, align 4, !tbaa !9
  %33 = shl i32 %32, 8
  %34 = add nsw i32 %33, 256
  %35 = and i32 %34, -16711936
  %36 = lshr i32 %32, 8
  %37 = and i32 %36, 16711935
  %38 = or disjoint i32 %35, %37
  store i32 %38, ptr %.01417, align 4, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %.01417, i64 4
  %40 = add nuw nsw i32 %.01516, 1
  %exitcond.not = icmp eq i32 %40, %1
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph.split.split, !llvm.loop !17

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

44:                                               ; preds = %41
  tail call void @__cxa_throw(ptr nonnull %42, ptr nonnull @_ZTI9jio_error, ptr nonnull @_ZN7j_errorD2Ev) #4
  unreachable

45:                                               ; preds = %41
  %46 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %42) #3
  resume { ptr, i32 } %46

.loopexit:                                        ; preds = %.lr.ph.split.split, %.lr.ph.split.split.us, %middle.block, %middle.block26, %2
  ret i32 0
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>) #2

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind }
attributes #4 = { noreturn }

!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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !13, !14}
!16 = distinct !{!16, !12, !14, !13}
!17 = distinct !{!17, !12, !14, !13}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass