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

; 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._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 }

; 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
define dso_local zeroext i8 @USBH_FindInterface(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3) #1 {
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i8 %1, ptr %7, align 1, !tbaa !9
  store i8 %2, ptr %8, align 1, !tbaa !9
  store i8 %3, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #2
  store i8 0, ptr %12, align 1, !tbaa !9
  store ptr null, ptr %10, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._USBH_HandleTypeDef, ptr %14, i32 0, i32 4
  %16 = getelementptr inbounds %struct.USBH_DeviceTypeDef, ptr %15, i32 0, i32 12
  store ptr %16, ptr %11, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %64, %4
  %18 = load i8, ptr %12, align 1, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = icmp ult i32 %19, 2
  br i1 %20, label %21, label %67

21:                                               ; preds = %17
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._ConfigurationDescriptor, ptr %22, i32 0, i32 8
  %24 = load i8, ptr %12, align 1, !tbaa !9
  %25 = zext i8 %24 to i64
  %26 = getelementptr inbounds [2 x %struct._InterfaceDescriptor], ptr %23, i64 0, i64 %25
  store ptr %26, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._InterfaceDescriptor, ptr %27, i32 0, i32 5
  %29 = load i8, ptr %28, align 1, !tbaa !10
  %30 = zext i8 %29 to i32
  %31 = load i8, ptr %7, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = icmp eq i32 %30, %32
  br i1 %33, label %38, label %34

34:                                               ; preds = %21
  %35 = load i8, ptr %7, align 1, !tbaa !9
  %36 = zext i8 %35 to i32
  %37 = icmp eq i32 %36, 255
  br i1 %37, label %38, label %64

38:                                               ; preds = %34, %21
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._InterfaceDescriptor, ptr %39, i32 0, i32 6
  %41 = load i8, ptr %40, align 2, !tbaa !12
  %42 = zext i8 %41 to i32
  %43 = load i8, ptr %8, align 1, !tbaa !9
  %44 = zext i8 %43 to i32
  %45 = icmp eq i32 %42, %44
  br i1 %45, label %50, label %46

46:                                               ; preds = %38
  %47 = load i8, ptr %8, align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = icmp eq i32 %48, 255
  br i1 %49, label %50, label %64

50:                                               ; preds = %46, %38
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._InterfaceDescriptor, ptr %51, i32 0, i32 7
  %53 = load i8, ptr %52, align 1, !tbaa !13
  %54 = zext i8 %53 to i32
  %55 = load i8, ptr %9, align 1, !tbaa !9
  %56 = zext i8 %55 to i32
  %57 = icmp eq i32 %54, %56
  br i1 %57, label %62, label %58

58:                                               ; preds = %50
  %59 = load i8, ptr %9, align 1, !tbaa !9
  %60 = zext i8 %59 to i32
  %61 = icmp eq i32 %60, 255
  br i1 %61, label %62, label %64

62:                                               ; preds = %58, %50
  %63 = load i8, ptr %12, align 1, !tbaa !9
  store i8 %63, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %68

64:                                               ; preds = %58, %46, %34
  %65 = load i8, ptr %12, align 1, !tbaa !9
  %66 = add i8 %65, 1
  store i8 %66, ptr %12, align 1, !tbaa !9
  br label %17, !llvm.loop !14

67:                                               ; preds = %17
  store i8 -1, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %68

68:                                               ; preds = %67, %62
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %69 = load i8, ptr %5, align 1
  ret i8 %69
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 5}
!11 = !{!"_InterfaceDescriptor", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 10}
!12 = !{!11, !7, i64 6}
!13 = !{!11, !7, i64 7}
!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local zeroext i8 @USBH_FindInterface(ptr nocapture noundef readonly %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = icmp eq i8 %1, -1
  %6 = icmp eq i8 %2, -1
  %7 = icmp eq i8 %3, -1
  br i1 %5, label %.split.us, label %.split

.split.us:                                        ; preds = %4
  br i1 %6, label %.split.us.split.us, label %.split.us.split

.split.us.split.us:                               ; preds = %.split.us
  br i1 %7, label %.split26.us, label %.split.us.split.us.split.preheader

.split.us.split.us.split.preheader:               ; preds = %.split.us.split.us
  %invariant.gep47 = getelementptr inbounds i8, ptr %0, i64 869
  %8 = load i8, ptr %invariant.gep47, align 1, !tbaa !5
  %9 = icmp eq i8 %8, %3
  br i1 %9, label %.split26.us, label %.split.us.split.us.split.1

.split.us.split.us.split.1:                       ; preds = %.split.us.split.us.split.preheader
  %gep48.1 = getelementptr inbounds i8, ptr %0, i64 895
  %10 = load i8, ptr %gep48.1, align 1, !tbaa !5
  %11 = icmp eq i8 %10, %3
  %spec.select = select i1 %11, i8 1, i8 -1
  br label %.split26.us

.split.us.split:                                  ; preds = %.split.us
  %invariant.gep45 = getelementptr inbounds i8, ptr %0, i64 868
  %12 = load i8, ptr %invariant.gep45, align 2, !tbaa !9
  %13 = icmp eq i8 %12, %2
  br i1 %7, label %.split.us.split.split.us, label %.split.us.split.split.preheader

.split.us.split.split.preheader:                  ; preds = %.split.us.split
  br i1 %13, label %17, label %.split.us.split.split.1

.split.us.split.split.us:                         ; preds = %.split.us.split
  br i1 %13, label %.split26.us, label %14

14:                                               ; preds = %.split.us.split.split.us
  %gep46.1 = getelementptr inbounds i8, ptr %0, i64 894
  %15 = load i8, ptr %gep46.1, align 2, !tbaa !9
  %16 = icmp eq i8 %15, %2
  %spec.select69 = select i1 %16, i8 1, i8 -1
  br label %.split26.us

17:                                               ; preds = %.split.us.split.split.preheader
  %18 = getelementptr inbounds i8, ptr %0, i64 869
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp eq i8 %19, %3
  br i1 %20, label %.split26.us, label %.split.us.split.split.1

.split.us.split.split.1:                          ; preds = %17, %.split.us.split.split.preheader
  %21 = getelementptr inbounds i8, ptr %0, i64 894
  %22 = load i8, ptr %21, align 2, !tbaa !9
  %23 = icmp eq i8 %22, %2
  br i1 %23, label %24, label %28

24:                                               ; preds = %.split.us.split.split.1
  %25 = getelementptr inbounds i8, ptr %0, i64 895
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %27 = icmp eq i8 %26, %3
  br i1 %27, label %.split26.us, label %28

28:                                               ; preds = %24, %.split.us.split.split.1
  br label %.split26.us

.split:                                           ; preds = %4
  %invariant.gep = getelementptr inbounds i8, ptr %0, i64 867
  %29 = load i8, ptr %invariant.gep, align 1, !tbaa !10
  %30 = icmp eq i8 %29, %1
  br i1 %6, label %.split.split.us, label %.split.split

.split.split.us:                                  ; preds = %.split
  br i1 %7, label %.split.split.us.split.us, label %.split.split.us.split.preheader

.split.split.us.split.preheader:                  ; preds = %.split.split.us
  br i1 %30, label %34, label %.split.split.us.split.1

.split.split.us.split.us:                         ; preds = %.split.split.us
  br i1 %30, label %.split26.us, label %31

31:                                               ; preds = %.split.split.us.split.us
  %gep.1 = getelementptr inbounds i8, ptr %0, i64 893
  %32 = load i8, ptr %gep.1, align 1, !tbaa !10
  %33 = icmp eq i8 %32, %1
  %spec.select70 = select i1 %33, i8 1, i8 -1
  br label %.split26.us

34:                                               ; preds = %.split.split.us.split.preheader
  %35 = getelementptr inbounds i8, ptr %0, i64 869
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = icmp eq i8 %36, %3
  br i1 %37, label %.split26.us, label %.split.split.us.split.1

.split.split.us.split.1:                          ; preds = %34, %.split.split.us.split.preheader
  %38 = getelementptr inbounds i8, ptr %0, i64 893
  %39 = load i8, ptr %38, align 1, !tbaa !10
  %40 = icmp eq i8 %39, %1
  br i1 %40, label %41, label %45

41:                                               ; preds = %.split.split.us.split.1
  %42 = getelementptr inbounds i8, ptr %0, i64 895
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = icmp eq i8 %43, %3
  br i1 %44, label %.split26.us, label %45

45:                                               ; preds = %41, %.split.split.us.split.1
  br label %.split26.us

.split.split:                                     ; preds = %.split
  br i1 %7, label %.split.split.split.us.preheader, label %.split.split.split.preheader

.split.split.split.preheader:                     ; preds = %.split.split
  br i1 %30, label %58, label %.split.split.split.1

.split.split.split.us.preheader:                  ; preds = %.split.split
  br i1 %30, label %46, label %.split.split.split.us.1

46:                                               ; preds = %.split.split.split.us.preheader
  %47 = getelementptr inbounds i8, ptr %0, i64 868
  %48 = load i8, ptr %47, align 2, !tbaa !9
  %49 = icmp eq i8 %48, %2
  br i1 %49, label %.split26.us, label %.split.split.split.us.1

.split.split.split.us.1:                          ; preds = %46, %.split.split.split.us.preheader
  %50 = getelementptr inbounds i8, ptr %0, i64 893
  %51 = load i8, ptr %50, align 1, !tbaa !10
  %52 = icmp eq i8 %51, %1
  br i1 %52, label %53, label %57

53:                                               ; preds = %.split.split.split.us.1
  %54 = getelementptr inbounds i8, ptr %0, i64 894
  %55 = load i8, ptr %54, align 2, !tbaa !9
  %56 = icmp eq i8 %55, %2
  br i1 %56, label %.split26.us, label %57

57:                                               ; preds = %53, %.split.split.split.us.1
  br label %.split26.us

58:                                               ; preds = %.split.split.split.preheader
  %59 = getelementptr inbounds i8, ptr %0, i64 868
  %60 = load i8, ptr %59, align 2, !tbaa !9
  %61 = icmp eq i8 %60, %2
  br i1 %61, label %62, label %.split.split.split.1

62:                                               ; preds = %58
  %63 = getelementptr inbounds i8, ptr %0, i64 869
  %64 = load i8, ptr %63, align 1, !tbaa !5
  %65 = icmp eq i8 %64, %3
  br i1 %65, label %.split26.us, label %.split.split.split.1

.split.split.split.1:                             ; preds = %62, %58, %.split.split.split.preheader
  %66 = getelementptr inbounds i8, ptr %0, i64 893
  %67 = load i8, ptr %66, align 1, !tbaa !10
  %68 = icmp eq i8 %67, %1
  br i1 %68, label %69, label %77

69:                                               ; preds = %.split.split.split.1
  %70 = getelementptr inbounds i8, ptr %0, i64 894
  %71 = load i8, ptr %70, align 2, !tbaa !9
  %72 = icmp eq i8 %71, %2
  br i1 %72, label %73, label %77

73:                                               ; preds = %69
  %74 = getelementptr inbounds i8, ptr %0, i64 895
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = icmp eq i8 %75, %3
  br i1 %76, label %.split26.us, label %77

77:                                               ; preds = %73, %69, %.split.split.split.1
  br label %.split26.us

.split26.us:                                      ; preds = %31, %14, %.split.us.split.us.split.1, %62, %73, %77, %46, %53, %57, %34, %41, %45, %.split.split.us.split.us, %17, %24, %28, %.split.us.split.split.us, %.split.us.split.us.split.preheader, %.split.us.split.us
  %.us-phi = phi i8 [ 0, %.split.us.split.us ], [ 0, %.split.us.split.us.split.preheader ], [ 0, %.split.us.split.split.us ], [ 0, %17 ], [ 1, %24 ], [ -1, %28 ], [ 0, %.split.split.us.split.us ], [ 0, %34 ], [ 1, %41 ], [ -1, %45 ], [ 0, %46 ], [ 1, %53 ], [ -1, %57 ], [ 0, %62 ], [ 1, %73 ], [ -1, %77 ], [ %spec.select, %.split.us.split.us.split.1 ], [ %spec.select69, %14 ], [ %spec.select70, %31 ]
  ret i8 %.us-phi
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 7}
!6 = !{!"_InterfaceDescriptor", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 10}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!6, !7, i64 6}
!10 = !{!6, !7, i64 5}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass