; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/src/usbh (usbh_conf)

; 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.HCD_HandleTypeDef = type { ptr, %struct.USB_OTG_CfgTypeDef, [16 x %struct.USB_OTG_HCTypeDef], i32, i32, i32, ptr }
%struct.USB_OTG_CfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USB_OTG_HCTypeDef = type { i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, ptr, i32, i32, i8, i8, i32, i32, i32, i32 }
%struct._USBH_HandleTypeDef = type { i32, i32, i32, %struct.USBH_CtrlTypeDef, %struct.USBH_DeviceTypeDef, [1 x ptr], ptr, i32, [16 x i32], i32, i32, i8, ptr, ptr }
%struct.USBH_CtrlTypeDef = type { i8, i8, i8, ptr, i16, i16, %union._USB_Setup, i32, i8 }
%union._USB_Setup = type { [2 x i32] }
%struct.USBH_DeviceTypeDef = type { [256 x i8], [512 x i8], i8, i8, i8, i8, i8, i8, i8, i8, i8, %struct._DeviceDescriptor, %struct._ConfigurationDescriptor }
%struct._DeviceDescriptor = type { i8, i8, i16, i8, i8, i8, i8, i16, i16, i16, i8, i8, i8, i8 }
%struct._ConfigurationDescriptor = type { i8, i8, i16, i8, i8, i8, i8, i8, [2 x %struct._InterfaceDescriptor] }
%struct._InterfaceDescriptor = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, [2 x %struct._EndpointDescriptor] }
%struct._EndpointDescriptor = type { i8, i8, i8, i8, i16, i8 }

@hhcd_USB_OTG_HS = external dso_local global %struct.HCD_HandleTypeDef, align 8

declare void @Error_Handler() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @USBH_LL_Init(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct._USBH_HandleTypeDef, ptr %3, i32 0, i32 11
  %5 = load i8, ptr %4, align 4, !tbaa !9
  %6 = zext i8 %5 to i32
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %18

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %9, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 6), align 8, !tbaa !17
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._USBH_HandleTypeDef, ptr %10, i32 0, i32 12
  store ptr @hhcd_USB_OTG_HS, ptr %11, align 8, !tbaa !20
  store ptr inttoptr (i64 1074003968 to ptr), ptr @hhcd_USB_OTG_HS, align 8, !tbaa !21
  store i32 16, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 1), align 4, !tbaa !22
  store i32 1, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 2), align 8, !tbaa !23
  store i32 1, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 3), align 4, !tbaa !24
  store i32 2, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 5), align 4, !tbaa !25
  store i32 0, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 6), align 8, !tbaa !26
  store i32 0, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 7), align 4, !tbaa !27
  store i32 0, ptr getelementptr inbounds (%struct.USB_OTG_CfgTypeDef, ptr getelementptr inbounds (%struct.HCD_HandleTypeDef, ptr @hhcd_USB_OTG_HS, i32 0, i32 1), i32 0, i32 12), align 8, !tbaa !28
  %12 = call i32 @HAL_HCD_Init(ptr noundef @hhcd_USB_OTG_HS)
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %8
  call void @Error_Handler()
  br label %15

15:                                               ; preds = %14, %8
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = call i32 @HAL_HCD_GetCurrentFrame(ptr noundef @hhcd_USB_OTG_HS)
  call void @USBH_LL_SetTimer(ptr noundef %16, i32 noundef %17)
  br label %18

18:                                               ; preds = %15, %1
  ret i32 0
}

declare i32 @HAL_HCD_Init(ptr noundef) #0

declare void @USBH_LL_SetTimer(ptr noundef, i32 noundef) #0

declare i32 @HAL_HCD_GetCurrentFrame(ptr noundef) #0

attributes #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 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 1012}
!10 = !{!"_USBH_HandleTypeDef", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !14, i64 56, !7, i64 920, !6, i64 928, !11, i64 936, !7, i64 940, !11, i64 1004, !11, i64 1008, !7, i64 1012, !6, i64 1016, !6, i64 1024}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !6, i64 8, !13, i64 16, !13, i64 18, !7, i64 20, !11, i64 28, !7, i64 32}
!13 = !{!"short", !7, i64 0}
!14 = !{!"", !7, i64 0, !7, i64 256, !7, i64 768, !7, i64 769, !7, i64 770, !7, i64 771, !7, i64 772, !7, i64 773, !7, i64 774, !7, i64 775, !7, i64 776, !15, i64 778, !16, i64 796}
!15 = !{!"_DeviceDescriptor", !7, i64 0, !7, i64 1, !13, i64 2, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17}
!16 = !{!"_ConfigurationDescriptor", !7, i64 0, !7, i64 1, !13, i64 2, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 10}
!17 = !{!18, !6, i64 976}
!18 = !{!"", !6, i64 0, !19, i64 8, !7, i64 64, !11, i64 960, !11, i64 964, !11, i64 968, !6, i64 976}
!19 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48}
!20 = !{!10, !6, i64 1016}
!21 = !{!18, !6, i64 0}
!22 = !{!18, !11, i64 12}
!23 = !{!18, !11, i64 16}
!24 = !{!18, !11, i64 20}
!25 = !{!18, !11, i64 28}
!26 = !{!18, !11, i64 32}
!27 = !{!18, !11, i64 36}
!28 = !{!18, !11, i64 56}


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

%struct.HCD_HandleTypeDef = type { ptr, %struct.USB_OTG_CfgTypeDef, [16 x %struct.USB_OTG_HCTypeDef], i32, i32, i32, ptr }
%struct.USB_OTG_CfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USB_OTG_HCTypeDef = type { i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, ptr, i32, i32, i8, i8, i32, i32, i32, i32 }

@hhcd_USB_OTG_HS = external dso_local global %struct.HCD_HandleTypeDef, align 8

declare void @Error_Handler() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @USBH_LL_Init(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 1012
  %3 = load i8, ptr %2, align 4, !tbaa !5
  %4 = icmp eq i8 %3, 0
  br i1 %4, label %5, label %11

5:                                                ; preds = %1
  store ptr %0, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 976), align 8, !tbaa !16
  %6 = getelementptr inbounds i8, ptr %0, i64 1016
  store ptr @hhcd_USB_OTG_HS, ptr %6, align 8, !tbaa !19
  store ptr inttoptr (i64 1074003968 to ptr), ptr @hhcd_USB_OTG_HS, align 8, !tbaa !20
  store i32 16, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 12), align 4, !tbaa !21
  store i32 1, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 16), align 8, !tbaa !22
  store i32 1, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 20), align 4, !tbaa !23
  store i32 2, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 28), align 4, !tbaa !24
  store i32 0, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 32), align 8, !tbaa !25
  store i32 0, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 36), align 4, !tbaa !26
  store i32 0, ptr getelementptr inbounds (i8, ptr @hhcd_USB_OTG_HS, i64 56), align 8, !tbaa !27
  %7 = tail call i32 @HAL_HCD_Init(ptr noundef nonnull @hhcd_USB_OTG_HS) #2
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %9, label %8

8:                                                ; preds = %5
  tail call void @Error_Handler() #2
  br label %9

9:                                                ; preds = %8, %5
  %10 = tail call i32 @HAL_HCD_GetCurrentFrame(ptr noundef nonnull @hhcd_USB_OTG_HS) #2
  tail call void @USBH_LL_SetTimer(ptr noundef nonnull %0, i32 noundef %10) #2
  br label %11

11:                                               ; preds = %9, %1
  ret i32 0
}

declare i32 @HAL_HCD_Init(ptr noundef) local_unnamed_addr #0

declare void @USBH_LL_SetTimer(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @HAL_HCD_GetCurrentFrame(ptr noundef) local_unnamed_addr #0

attributes #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 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, !8, i64 1012}
!6 = !{!"_USBH_HandleTypeDef", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !13, i64 56, !8, i64 920, !11, i64 928, !7, i64 936, !8, i64 940, !7, i64 1004, !7, i64 1008, !8, i64 1012, !11, i64 1016, !11, i64 1024}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !11, i64 8, !12, i64 16, !12, i64 18, !8, i64 20, !7, i64 28, !8, i64 32}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"", !8, i64 0, !8, i64 256, !8, i64 768, !8, i64 769, !8, i64 770, !8, i64 771, !8, i64 772, !8, i64 773, !8, i64 774, !8, i64 775, !8, i64 776, !14, i64 778, !15, i64 796}
!14 = !{!"_DeviceDescriptor", !8, i64 0, !8, i64 1, !12, i64 2, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !12, i64 8, !12, i64 10, !12, i64 12, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 17}
!15 = !{!"_ConfigurationDescriptor", !8, i64 0, !8, i64 1, !12, i64 2, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !8, i64 8, !8, i64 10}
!16 = !{!17, !11, i64 976}
!17 = !{!"", !11, i64 0, !18, i64 8, !8, i64 64, !7, i64 960, !7, i64 964, !7, i64 968, !11, i64 976}
!18 = !{!"", !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}
!19 = !{!6, !11, i64 1016}
!20 = !{!17, !11, i64 0}
!21 = !{!17, !7, i64 12}
!22 = !{!17, !7, i64 16}
!23 = !{!17, !7, i64 20}
!24 = !{!17, !7, i64 28}
!25 = !{!17, !7, i64 32}
!26 = !{!17, !7, i64 36}
!27 = !{!17, !7, i64 56}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass