; LLVM IR from ctlst-tech/catpilot :: bsp/mcu/periph/usb/stm32/STM32_USB_Device_Library/Core/Src (usbd_core)

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

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

10:                                               ; preds = %2
  store i32 3, ptr %3, align 4
  br label %35

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %12, i32 0, i32 9
  %14 = load volatile i8, ptr %13, align 4, !tbaa !15
  %15 = zext i8 %14 to i32
  %16 = icmp eq i32 %15, 3
  br i1 %16, label %17, label %34

17:                                               ; preds = %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %18, i32 0, i32 18
  %20 = load ptr, ptr %19, align 8, !tbaa !10
  %21 = getelementptr inbounds %struct._Device_cb, ptr %20, i32 0, i32 8
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %33

24:                                               ; preds = %17
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._USBD_HandleTypeDef, ptr %25, i32 0, i32 18
  %27 = load ptr, ptr %26, align 8, !tbaa !10
  %28 = getelementptr inbounds %struct._Device_cb, ptr %27, i32 0, i32 8
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i8, ptr %5, align 1, !tbaa !9
  %32 = call zeroext i8 %29(ptr noundef %30, i8 noundef zeroext %31)
  br label %33

33:                                               ; preds = %24, %17
  br label %34

34:                                               ; preds = %33, %11
  store i32 0, ptr %3, align 4
  br label %35

35:                                               ; preds = %34, %10
  %36 = load i32, ptr %3, align 4
  ret i32 %36
}

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 704}
!11 = !{!"_USBD_HandleTypeDef", !7, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !7, i64 20, !7, i64 340, !12, i64 660, !12, i64 664, !7, i64 668, !7, i64 669, !7, i64 670, !7, i64 671, !7, i64 672, !12, i64 676, !7, i64 680, !13, i64 682, !6, i64 696, !6, i64 704, !6, i64 712, !6, i64 720, !6, i64 728, !6, i64 736, !6, i64 744}
!12 = !{!"int", !7, i64 0}
!13 = !{!"usb_setup_req", !7, i64 0, !7, i64 1, !14, i64 2, !14, i64 4, !14, i64 6}
!14 = !{!"short", !7, i64 0}
!15 = !{!11, !7, i64 668}
!16 = !{!17, !6, i64 64}
!17 = !{!"_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}


; 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 range(i32 0, 4) i32 @USBD_LL_IsoINIncomplete(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 704
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %15, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 668
  %8 = load volatile i8, ptr %7, align 4, !tbaa !13
  %9 = icmp eq i8 %8, 3
  br i1 %9, label %10, label %15

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %4, i64 64
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %15, label %13

13:                                               ; preds = %10
  %14 = tail call zeroext i8 %12(ptr noundef nonnull %0, i8 noundef zeroext %1) #1
  br label %15

15:                                               ; preds = %6, %13, %10, %2
  %.0 = phi i32 [ 3, %2 ], [ 0, %10 ], [ 0, %13 ], [ 0, %6 ]
  ret i32 %.0
}

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 = { 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, !12, i64 704}
!6 = !{!"_USBD_HandleTypeDef", !7, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !7, i64 20, !7, i64 340, !9, i64 660, !9, i64 664, !7, i64 668, !7, i64 669, !7, i64 670, !7, i64 671, !7, i64 672, !9, i64 676, !7, i64 680, !10, i64 682, !12, i64 696, !12, i64 704, !12, i64 712, !12, i64 720, !12, i64 728, !12, i64 736, !12, i64 744}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"usb_setup_req", !7, i64 0, !7, i64 1, !11, i64 2, !11, i64 4, !11, i64 6}
!11 = !{!"short", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!6, !7, i64 668}
!14 = !{!15, !12, i64 64}
!15 = !{!"_Device_cb", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104}


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