; 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_CfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USB_OTG_GlobalTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [39 x i32], i32, [15 x i32] }

; Function Attrs: nounwind uwtable
define dso_local i32 @USB_CoreInit(ptr noundef %0, ptr noundef byval(%struct.USB_OTG_CfgTypeDef) align 8 %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %5 = getelementptr inbounds %struct.USB_OTG_CfgTypeDef, ptr %1, i32 0, i32 5
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %40

8:                                                ; preds = %2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %9, i32 0, i32 13
  %11 = load volatile i32, ptr %10, align 4, !tbaa !12
  %12 = zext i32 %11 to i64
  %13 = and i64 %12, -65537
  %14 = trunc i64 %13 to i32
  store volatile i32 %14, ptr %10, align 4, !tbaa !12
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %15, i32 0, i32 3
  %17 = load volatile i32, ptr %16, align 4, !tbaa !14
  %18 = zext i32 %17 to i64
  %19 = and i64 %18, -4325441
  %20 = trunc i64 %19 to i32
  store volatile i32 %20, ptr %16, align 4, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %21, i32 0, i32 3
  %23 = load volatile i32, ptr %22, align 4, !tbaa !14
  %24 = zext i32 %23 to i64
  %25 = and i64 %24, -3145729
  %26 = trunc i64 %25 to i32
  store volatile i32 %26, ptr %22, align 4, !tbaa !14
  %27 = getelementptr inbounds %struct.USB_OTG_CfgTypeDef, ptr %1, i32 0, i32 12
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %37

30:                                               ; preds = %8
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %31, i32 0, i32 3
  %33 = load volatile i32, ptr %32, align 4, !tbaa !14
  %34 = zext i32 %33 to i64
  %35 = or i64 %34, 1048576
  %36 = trunc i64 %35 to i32
  store volatile i32 %36, ptr %32, align 4, !tbaa !14
  br label %37

37:                                               ; preds = %30, %8
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call i32 @USB_CoreReset(ptr noundef %38)
  store i32 %39, ptr %4, align 4, !tbaa !16
  br label %67

40:                                               ; preds = %2
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %41, i32 0, i32 3
  %43 = load volatile i32, ptr %42, align 4, !tbaa !14
  %44 = zext i32 %43 to i64
  %45 = or i64 %44, 64
  %46 = trunc i64 %45 to i32
  store volatile i32 %46, ptr %42, align 4, !tbaa !14
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = call i32 @USB_CoreReset(ptr noundef %47)
  store i32 %48, ptr %4, align 4, !tbaa !16
  %49 = getelementptr inbounds %struct.USB_OTG_CfgTypeDef, ptr %1, i32 0, i32 9
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %59

52:                                               ; preds = %40
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %53, i32 0, i32 13
  %55 = load volatile i32, ptr %54, align 4, !tbaa !12
  %56 = zext i32 %55 to i64
  %57 = or i64 %56, 65536
  %58 = trunc i64 %57 to i32
  store volatile i32 %58, ptr %54, align 4, !tbaa !12
  br label %66

59:                                               ; preds = %40
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %60, i32 0, i32 13
  %62 = load volatile i32, ptr %61, align 4, !tbaa !12
  %63 = zext i32 %62 to i64
  %64 = and i64 %63, -65537
  %65 = trunc i64 %64 to i32
  store volatile i32 %65, ptr %61, align 4, !tbaa !12
  br label %66

66:                                               ; preds = %59, %52
  br label %67

67:                                               ; preds = %66, %37
  %68 = getelementptr inbounds %struct.USB_OTG_CfgTypeDef, ptr %1, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !18
  %70 = icmp eq i32 %69, 1
  br i1 %70, label %71, label %84

71:                                               ; preds = %67
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %72, i32 0, i32 2
  %74 = load volatile i32, ptr %73, align 4, !tbaa !19
  %75 = zext i32 %74 to i64
  %76 = or i64 %75, 8
  %77 = trunc i64 %76 to i32
  store volatile i32 %77, ptr %73, align 4, !tbaa !19
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.USB_OTG_GlobalTypeDef, ptr %78, i32 0, i32 2
  %80 = load volatile i32, ptr %79, align 4, !tbaa !19
  %81 = zext i32 %80 to i64
  %82 = or i64 %81, 32
  %83 = trunc i64 %82 to i32
  store volatile i32 %83, ptr %79, align 4, !tbaa !19
  br label %84

84:                                               ; preds = %71, %67
  %85 = load i32, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  ret i32 %85
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @USB_CoreReset(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 20}
!10 = !{!"", !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}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 56}
!13 = !{!"", !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, !7, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !7, i64 100, !11, i64 256, !7, i64 260}
!14 = !{!13, !11, i64 12}
!15 = !{!10, !11, i64 48}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 36}
!18 = !{!10, !11, i64 12}
!19 = !{!13, !11, i64 8}


; 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.USB_OTG_CfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @USB_CoreInit(ptr noundef %0, ptr nocapture noundef readonly byval(%struct.USB_OTG_CfgTypeDef) align 8 %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 20
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %6, label %23

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = load volatile i32, ptr %7, align 4, !tbaa !10
  %9 = and i32 %8, -65537
  store volatile i32 %9, ptr %7, align 4, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load volatile i32, ptr %10, align 4, !tbaa !12
  %12 = and i32 %11, -4325441
  store volatile i32 %12, ptr %10, align 4, !tbaa !12
  %13 = load volatile i32, ptr %10, align 4, !tbaa !12
  %14 = and i32 %13, -3145729
  store volatile i32 %14, ptr %10, align 4, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %1, i64 48
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %21

18:                                               ; preds = %6
  %19 = load volatile i32, ptr %10, align 4, !tbaa !12
  %20 = or i32 %19, 1048576
  store volatile i32 %20, ptr %10, align 4, !tbaa !12
  br label %21

21:                                               ; preds = %18, %6
  %22 = tail call i32 @USB_CoreReset(ptr noundef nonnull %0)
  br label %37

23:                                               ; preds = %2
  %24 = getelementptr inbounds i8, ptr %0, i64 12
  %25 = load volatile i32, ptr %24, align 4, !tbaa !12
  %26 = or i32 %25, 64
  store volatile i32 %26, ptr %24, align 4, !tbaa !12
  %27 = tail call i32 @USB_CoreReset(ptr noundef %0)
  %28 = getelementptr inbounds i8, ptr %1, i64 36
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = icmp eq i32 %29, 0
  %31 = getelementptr inbounds i8, ptr %0, i64 56
  %32 = load volatile i32, ptr %31, align 4, !tbaa !10
  br i1 %30, label %33, label %35

33:                                               ; preds = %23
  %34 = or i32 %32, 65536
  store volatile i32 %34, ptr %31, align 4, !tbaa !10
  br label %37

35:                                               ; preds = %23
  %36 = and i32 %32, -65537
  store volatile i32 %36, ptr %31, align 4, !tbaa !10
  br label %37

37:                                               ; preds = %33, %35, %21
  %.0 = phi i32 [ %22, %21 ], [ %27, %33 ], [ %27, %35 ]
  %38 = getelementptr inbounds i8, ptr %1, i64 12
  %39 = load i32, ptr %38, align 4, !tbaa !15
  %40 = icmp eq i32 %39, 1
  br i1 %40, label %41, label %47

41:                                               ; preds = %37
  %42 = getelementptr inbounds i8, ptr %0, i64 8
  %43 = load volatile i32, ptr %42, align 4, !tbaa !16
  %44 = or i32 %43, 8
  store volatile i32 %44, ptr %42, align 4, !tbaa !16
  %45 = load volatile i32, ptr %42, align 4, !tbaa !16
  %46 = or i32 %45, 32
  store volatile i32 %46, ptr %42, align 4, !tbaa !16
  br label %47

47:                                               ; preds = %41, %37
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @USB_CoreReset(ptr noundef) local_unnamed_addr #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" }

!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 20}
!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, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 56}
!11 = !{!"", !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, !8, i64 48, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !8, i64 100, !7, i64 256, !8, i64 260}
!12 = !{!11, !7, i64 12}
!13 = !{!6, !7, i64 48}
!14 = !{!6, !7, i64 36}
!15 = !{!6, !7, i64 12}
!16 = !{!11, !7, i64 8}


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