; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Middlewares/ST/STM32_USB_Device_Library/Core/Src (Reset)

; 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._USBD_HandleTypeDef = type { i8, i32, i32, i32, i32, [15 x %struct.USBD_EndpointTypeDef], [15 x %struct.USBD_EndpointTypeDef], i32, i32, i8, i8, i8, i8, i8, i32, %struct.usb_setup_req, ptr, ptr, ptr, ptr, ptr }
%struct.USBD_EndpointTypeDef = type { i32, i32, i32, i32, i32 }
%struct.usb_setup_req = type { i8, i8, i16, i16, i16 }
%struct._Device_cb = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @USBD_LL_Reset(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = call i32 @USBD_LL_OpenEP(ptr noundef %3, i8 noundef zeroext 0, i8 noundef zeroext 0, i16 noundef zeroext 64)
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %5, i32 0, i32 6
  %7 = getelementptr inbounds [15 x %struct.USBD_EndpointTypeDef], ptr %6, i64 0, i64 0
  %8 = getelementptr inbounds %struct.USBD_EndpointTypeDef, ptr %7, i32 0, i32 1
  store i32 1, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %9, i32 0, i32 6
  %11 = getelementptr inbounds [15 x %struct.USBD_EndpointTypeDef], ptr %10, i64 0, i64 0
  %12 = getelementptr inbounds %struct.USBD_EndpointTypeDef, ptr %11, i32 0, i32 4
  store i32 64, ptr %12, align 8, !tbaa !12
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call i32 @USBD_LL_OpenEP(ptr noundef %13, i8 noundef zeroext -128, i8 noundef zeroext 0, i16 noundef zeroext 64)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %15, i32 0, i32 5
  %17 = getelementptr inbounds [15 x %struct.USBD_EndpointTypeDef], ptr %16, i64 0, i64 0
  %18 = getelementptr inbounds %struct.USBD_EndpointTypeDef, ptr %17, i32 0, i32 1
  store i32 1, ptr %18, align 4, !tbaa !9
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %19, i32 0, i32 5
  %21 = getelementptr inbounds [15 x %struct.USBD_EndpointTypeDef], ptr %20, i64 0, i64 0
  %22 = getelementptr inbounds %struct.USBD_EndpointTypeDef, ptr %21, i32 0, i32 4
  store i32 64, ptr %22, align 4, !tbaa !12
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %23, i32 0, i32 9
  store i8 1, ptr %24, align 4, !tbaa !13
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %25, i32 0, i32 7
  store i32 0, ptr %26, align 4, !tbaa !17
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %27, i32 0, i32 1
  store i32 0, ptr %28, align 4, !tbaa !18
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %29, i32 0, i32 14
  store i32 0, ptr %30, align 4, !tbaa !19
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %31, i32 0, i32 18
  %33 = load ptr, ptr %32, align 8, !tbaa !20
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %47

35:                                               ; preds = %1
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %36, i32 0, i32 17
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  %39 = getelementptr inbounds %struct._Device_cb, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !22
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !18
  %45 = trunc i32 %44 to i8
  %46 = call zeroext i8 %40(ptr noundef %41, i8 noundef zeroext %45)
  br label %47

47:                                               ; preds = %35, %1
  ret i32 0
}

declare i32 @USBD_LL_OpenEP(ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) #1

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" }
attributes #1 = { "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, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 16}
!13 = !{!14, !7, i64 628}
!14 = !{!"_USBD_HandleTypeDef", !7, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !7, i64 20, !7, i64 320, !11, i64 620, !11, i64 624, !7, i64 628, !7, i64 629, !7, i64 630, !7, i64 631, !7, i64 632, !11, i64 636, !15, i64 640, !6, i64 648, !6, i64 656, !6, i64 664, !6, i64 672, !6, i64 680}
!15 = !{!"usb_setup_req", !7, i64 0, !7, i64 1, !16, i64 2, !16, i64 4, !16, i64 6}
!16 = !{!"short", !7, i64 0}
!17 = !{!14, !11, i64 620}
!18 = !{!14, !11, i64 4}
!19 = !{!14, !11, i64 636}
!20 = !{!14, !6, i64 664}
!21 = !{!14, !6, i64 656}
!22 = !{!23, !6, i64 8}
!23 = !{!"_Device_cb", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112}


; 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
define dso_local noundef i32 @USBD_LL_Reset(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @USBD_LL_OpenEP(ptr noundef %0, i8 noundef zeroext 0, i8 noundef zeroext 0, i16 noundef zeroext 64) #2
  %3 = getelementptr inbounds i8, ptr %0, i64 324
  store i32 1, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 336
  store i32 64, ptr %4, align 8, !tbaa !10
  %5 = tail call i32 @USBD_LL_OpenEP(ptr noundef %0, i8 noundef zeroext -128, i8 noundef zeroext 0, i16 noundef zeroext 64) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 1, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 64, ptr %7, align 4, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %0, i64 628
  store i8 1, ptr %8, align 4, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 620
  store i32 0, ptr %9, align 4, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %10, align 4, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %0, i64 636
  store i32 0, ptr %11, align 4, !tbaa !18
  %12 = getelementptr inbounds i8, ptr %0, i64 664
  %13 = load ptr, ptr %12, align 8, !tbaa !19
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %20, label %14

14:                                               ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 656
  %16 = load ptr, ptr %15, align 8, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !21
  %19 = tail call zeroext i8 %18(ptr noundef nonnull %0, i8 noundef zeroext 0) #2
  br label %20

20:                                               ; preds = %14, %1
  ret i32 0
}

declare i32 @USBD_LL_OpenEP(ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

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" }
attributes #1 = { "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, !7, i64 4}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!12, !8, i64 628}
!12 = !{!"_USBD_HandleTypeDef", !8, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !8, i64 20, !8, i64 320, !7, i64 620, !7, i64 624, !8, i64 628, !8, i64 629, !8, i64 630, !8, i64 631, !8, i64 632, !7, i64 636, !13, i64 640, !15, i64 648, !15, i64 656, !15, i64 664, !15, i64 672, !15, i64 680}
!13 = !{!"usb_setup_req", !8, i64 0, !8, i64 1, !14, i64 2, !14, i64 4, !14, i64 6}
!14 = !{!"short", !8, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!12, !7, i64 620}
!17 = !{!12, !7, i64 4}
!18 = !{!12, !7, i64 636}
!19 = !{!12, !15, i64 664}
!20 = !{!12, !15, i64 656}
!21 = !{!22, !15, i64 8}
!22 = !{!"_Device_cb", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112}


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