; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Drivers/STM32H7xx_HAL_Driver/Src (usb)

; 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.USB_OTG_INEndpointTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USB_OTG_OUTEndpointTypeDef = type { i32, i32, i32, i32, i32, i32, [2 x i32] }
%struct.USB_OTG_DeviceTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [15 x i32], 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @USB_FlushTxFifo(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @USB_FlushRxFifo(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @USB_StopDevice(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = ptrtoint ptr %8 to i32
  store i32 %9, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %32, %1
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp ult i32 %11, 15
  br i1 %12, label %13, label %35

13:                                               ; preds = %10
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = add i64 %15, 2304
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = mul i64 %18, 32
  %20 = add i64 %16, %19
  %21 = inttoptr i64 %20 to ptr
  %22 = getelementptr inbounds %struct.USB_OTG_INEndpointTypeDef, ptr %21, i32 0, i32 2
  store volatile i32 64383, ptr %22, align 4, !tbaa !11
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = add i64 %24, 2816
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = mul i64 %27, 32
  %29 = add i64 %25, %28
  %30 = inttoptr i64 %29 to ptr
  %31 = getelementptr inbounds %struct.USB_OTG_OUTEndpointTypeDef, ptr %30, i32 0, i32 2
  store volatile i32 64383, ptr %31, align 4, !tbaa !13
  br label %32

32:                                               ; preds = %13
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = add i32 %33, 1
  store i32 %34, ptr %6, align 4, !tbaa !9
  br label %10, !llvm.loop !15

35:                                               ; preds = %10
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = add i64 %37, 2048
  %39 = inttoptr i64 %38 to ptr
  %40 = getelementptr inbounds %struct.USB_OTG_DeviceTypeDef, ptr %39, i32 0, i32 4
  store volatile i32 0, ptr %40, align 4, !tbaa !17
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = add i64 %42, 2048
  %44 = inttoptr i64 %43 to ptr
  %45 = getelementptr inbounds %struct.USB_OTG_DeviceTypeDef, ptr %44, i32 0, i32 5
  store volatile i32 0, ptr %45, align 4, !tbaa !19
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = add i64 %47, 2048
  %49 = inttoptr i64 %48 to ptr
  %50 = getelementptr inbounds %struct.USB_OTG_DeviceTypeDef, ptr %49, i32 0, i32 7
  store volatile i32 0, ptr %50, align 4, !tbaa !20
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = call i32 @USB_FlushRxFifo(ptr noundef %51)
  store i32 %52, ptr %4, align 4, !tbaa !9
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %35
  %56 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %56, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %66

57:                                               ; preds = %35
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = call i32 @USB_FlushTxFifo(ptr noundef %58, i32 noundef 16)
  store i32 %59, ptr %4, align 4, !tbaa !9
  %60 = load i32, ptr %4, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %57
  %63 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %63, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %66

64:                                               ; preds = %57
  %65 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %65, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %66

66:                                               ; preds = %64, %62, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %67 = load i32, ptr %2, align 4
  ret i32 %67
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!14, !10, i64 8}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !10, i64 16}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !7, i64 72, !10, i64 132}
!19 = !{!18, !10, i64 20}
!20 = !{!18, !10, i64 28}


; 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
declare dso_local i32 @USB_FlushTxFifo(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @USB_FlushRxFifo(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @USB_StopDevice(ptr noundef %0) local_unnamed_addr #0 {
  %2 = ptrtoint ptr %0 to i64
  %3 = and i64 %2, 4294967295
  %4 = add nuw nsw i64 %3, 2304
  %5 = inttoptr i64 %4 to ptr
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  store volatile i32 64383, ptr %6, align 4, !tbaa !5
  %7 = add nuw nsw i64 %3, 2816
  %8 = inttoptr i64 %7 to ptr
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  store volatile i32 64383, ptr %9, align 4, !tbaa !10
  %10 = add nuw nsw i64 %3, 2336
  %11 = inttoptr i64 %10 to ptr
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  store volatile i32 64383, ptr %12, align 4, !tbaa !5
  %13 = add nuw nsw i64 %3, 2848
  %14 = inttoptr i64 %13 to ptr
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  store volatile i32 64383, ptr %15, align 4, !tbaa !10
  %16 = add nuw nsw i64 %3, 2368
  %17 = inttoptr i64 %16 to ptr
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  store volatile i32 64383, ptr %18, align 4, !tbaa !5
  %19 = add nuw nsw i64 %3, 2880
  %20 = inttoptr i64 %19 to ptr
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  store volatile i32 64383, ptr %21, align 4, !tbaa !10
  %22 = add nuw nsw i64 %3, 2400
  %23 = inttoptr i64 %22 to ptr
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  store volatile i32 64383, ptr %24, align 4, !tbaa !5
  %25 = add nuw nsw i64 %3, 2912
  %26 = inttoptr i64 %25 to ptr
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  store volatile i32 64383, ptr %27, align 4, !tbaa !10
  %28 = add nuw nsw i64 %3, 2432
  %29 = inttoptr i64 %28 to ptr
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  store volatile i32 64383, ptr %30, align 4, !tbaa !5
  %31 = add nuw nsw i64 %3, 2944
  %32 = inttoptr i64 %31 to ptr
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  store volatile i32 64383, ptr %33, align 4, !tbaa !10
  %34 = add nuw nsw i64 %3, 2464
  %35 = inttoptr i64 %34 to ptr
  %36 = getelementptr inbounds i8, ptr %35, i64 8
  store volatile i32 64383, ptr %36, align 4, !tbaa !5
  %37 = add nuw nsw i64 %3, 2976
  %38 = inttoptr i64 %37 to ptr
  %39 = getelementptr inbounds i8, ptr %38, i64 8
  store volatile i32 64383, ptr %39, align 4, !tbaa !10
  %40 = add nuw nsw i64 %3, 2496
  %41 = inttoptr i64 %40 to ptr
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  store volatile i32 64383, ptr %42, align 4, !tbaa !5
  %43 = add nuw nsw i64 %3, 3008
  %44 = inttoptr i64 %43 to ptr
  %45 = getelementptr inbounds i8, ptr %44, i64 8
  store volatile i32 64383, ptr %45, align 4, !tbaa !10
  %46 = add nuw nsw i64 %3, 2528
  %47 = inttoptr i64 %46 to ptr
  %48 = getelementptr inbounds i8, ptr %47, i64 8
  store volatile i32 64383, ptr %48, align 4, !tbaa !5
  %49 = add nuw nsw i64 %3, 3040
  %50 = inttoptr i64 %49 to ptr
  %51 = getelementptr inbounds i8, ptr %50, i64 8
  store volatile i32 64383, ptr %51, align 4, !tbaa !10
  %52 = add nuw nsw i64 %3, 2560
  %53 = inttoptr i64 %52 to ptr
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  store volatile i32 64383, ptr %54, align 4, !tbaa !5
  %55 = add nuw nsw i64 %3, 3072
  %56 = inttoptr i64 %55 to ptr
  %57 = getelementptr inbounds i8, ptr %56, i64 8
  store volatile i32 64383, ptr %57, align 4, !tbaa !10
  %58 = add nuw nsw i64 %3, 2592
  %59 = inttoptr i64 %58 to ptr
  %60 = getelementptr inbounds i8, ptr %59, i64 8
  store volatile i32 64383, ptr %60, align 4, !tbaa !5
  %61 = add nuw nsw i64 %3, 3104
  %62 = inttoptr i64 %61 to ptr
  %63 = getelementptr inbounds i8, ptr %62, i64 8
  store volatile i32 64383, ptr %63, align 4, !tbaa !10
  %64 = add nuw nsw i64 %3, 2624
  %65 = inttoptr i64 %64 to ptr
  %66 = getelementptr inbounds i8, ptr %65, i64 8
  store volatile i32 64383, ptr %66, align 4, !tbaa !5
  %67 = add nuw nsw i64 %3, 3136
  %68 = inttoptr i64 %67 to ptr
  %69 = getelementptr inbounds i8, ptr %68, i64 8
  store volatile i32 64383, ptr %69, align 4, !tbaa !10
  %70 = add nuw nsw i64 %3, 2656
  %71 = inttoptr i64 %70 to ptr
  %72 = getelementptr inbounds i8, ptr %71, i64 8
  store volatile i32 64383, ptr %72, align 4, !tbaa !5
  %73 = add nuw nsw i64 %3, 3168
  %74 = inttoptr i64 %73 to ptr
  %75 = getelementptr inbounds i8, ptr %74, i64 8
  store volatile i32 64383, ptr %75, align 4, !tbaa !10
  %76 = add nuw nsw i64 %3, 2688
  %77 = inttoptr i64 %76 to ptr
  %78 = getelementptr inbounds i8, ptr %77, i64 8
  store volatile i32 64383, ptr %78, align 4, !tbaa !5
  %79 = add nuw nsw i64 %3, 3200
  %80 = inttoptr i64 %79 to ptr
  %81 = getelementptr inbounds i8, ptr %80, i64 8
  store volatile i32 64383, ptr %81, align 4, !tbaa !10
  %82 = add nuw nsw i64 %3, 2720
  %83 = inttoptr i64 %82 to ptr
  %84 = getelementptr inbounds i8, ptr %83, i64 8
  store volatile i32 64383, ptr %84, align 4, !tbaa !5
  %85 = add nuw nsw i64 %3, 3232
  %86 = inttoptr i64 %85 to ptr
  %87 = getelementptr inbounds i8, ptr %86, i64 8
  store volatile i32 64383, ptr %87, align 4, !tbaa !10
  %88 = add nuw nsw i64 %3, 2752
  %89 = inttoptr i64 %88 to ptr
  %90 = getelementptr inbounds i8, ptr %89, i64 8
  store volatile i32 64383, ptr %90, align 4, !tbaa !5
  %91 = add nuw nsw i64 %3, 3264
  %92 = inttoptr i64 %91 to ptr
  %93 = getelementptr inbounds i8, ptr %92, i64 8
  store volatile i32 64383, ptr %93, align 4, !tbaa !10
  %94 = add nuw nsw i64 %3, 2048
  %95 = inttoptr i64 %94 to ptr
  %96 = getelementptr inbounds i8, ptr %95, i64 16
  store volatile i32 0, ptr %96, align 4, !tbaa !12
  %97 = getelementptr inbounds i8, ptr %95, i64 20
  store volatile i32 0, ptr %97, align 4, !tbaa !14
  %98 = getelementptr inbounds i8, ptr %95, i64 28
  store volatile i32 0, ptr %98, align 4, !tbaa !15
  %99 = tail call i32 @USB_FlushRxFifo(ptr noundef %0)
  %.not = icmp eq i32 %99, 0
  br i1 %.not, label %100, label %102

100:                                              ; preds = %1
  %101 = tail call i32 @USB_FlushTxFifo(ptr noundef %0, i32 noundef 16)
  br label %102

102:                                              ; preds = %100, %1
  %.017 = phi i32 [ %99, %1 ], [ %101, %100 ]
  ret i32 %.017
}

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

!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 8}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24}
!12 = !{!13, !7, i64 16}
!13 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !8, i64 72, !7, i64 132}
!14 = !{!13, !7, i64 20}
!15 = !{!13, !7, i64 28}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass