; 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_HostChannelTypeDef = type { i32, i32, i32, i32, i32, i32, [2 x i32] }

; 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 i32 @USB_DoPing(ptr noundef %0, i8 noundef zeroext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = ptrtoint ptr %9 to i32
  store i32 %10, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %11 = load i8, ptr %4, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  store i32 %12, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 1, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %13 = load i32, ptr %7, align 4, !tbaa !10
  %14 = shl i32 %13, 19
  %15 = zext i32 %14 to i64
  %16 = and i64 %15, 536346624
  %17 = or i64 %16, 2147483648
  %18 = trunc i64 %17 to i32
  %19 = load i32, ptr %5, align 4, !tbaa !10
  %20 = zext i32 %19 to i64
  %21 = add i64 %20, 1280
  %22 = load i32, ptr %6, align 4, !tbaa !10
  %23 = zext i32 %22 to i64
  %24 = mul i64 %23, 32
  %25 = add i64 %21, %24
  %26 = inttoptr i64 %25 to ptr
  %27 = getelementptr inbounds %struct.USB_OTG_HostChannelTypeDef, ptr %26, i32 0, i32 4
  store volatile i32 %18, ptr %27, align 4, !tbaa !12
  %28 = load i32, ptr %5, align 4, !tbaa !10
  %29 = zext i32 %28 to i64
  %30 = add i64 %29, 1280
  %31 = load i32, ptr %6, align 4, !tbaa !10
  %32 = zext i32 %31 to i64
  %33 = mul i64 %32, 32
  %34 = add i64 %30, %33
  %35 = inttoptr i64 %34 to ptr
  %36 = getelementptr inbounds %struct.USB_OTG_HostChannelTypeDef, ptr %35, i32 0, i32 0
  %37 = load volatile i32, ptr %36, align 4, !tbaa !14
  store volatile i32 %37, ptr %8, align 4, !tbaa !10
  %38 = load volatile i32, ptr %8, align 4, !tbaa !10
  %39 = zext i32 %38 to i64
  %40 = and i64 %39, -1073741825
  %41 = trunc i64 %40 to i32
  store volatile i32 %41, ptr %8, align 4, !tbaa !10
  %42 = load volatile i32, ptr %8, align 4, !tbaa !10
  %43 = zext i32 %42 to i64
  %44 = or i64 %43, 2147483648
  %45 = trunc i64 %44 to i32
  store volatile i32 %45, ptr %8, align 4, !tbaa !10
  %46 = load volatile i32, ptr %8, align 4, !tbaa !10
  %47 = load i32, ptr %5, align 4, !tbaa !10
  %48 = zext i32 %47 to i64
  %49 = add i64 %48, 1280
  %50 = load i32, ptr %6, align 4, !tbaa !10
  %51 = zext i32 %50 to i64
  %52 = mul i64 %51, 32
  %53 = add i64 %49, %52
  %54 = inttoptr i64 %53 to ptr
  %55 = getelementptr inbounds %struct.USB_OTG_HostChannelTypeDef, ptr %54, i32 0, i32 0
  store volatile i32 %46, ptr %55, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 0
}

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, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !7, i64 24}
!14 = !{!13, !11, i64 0}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nofree norecurse nounwind uwtable
define dso_local noundef i32 @USB_DoPing(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = ptrtoint ptr %0 to i64
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3)
  %5 = and i64 %4, 4294967295
  %6 = add nuw nsw i64 %5, 1280
  %7 = zext i8 %1 to i64
  %8 = shl nuw nsw i64 %7, 5
  %9 = add nuw nsw i64 %6, %8
  %10 = inttoptr i64 %9 to ptr
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store volatile i32 -2146959360, ptr %11, align 4, !tbaa !5
  %12 = load volatile i32, ptr %10, align 4, !tbaa !10
  store volatile i32 %12, ptr %3, align 4, !tbaa !11
  %.0..0..0..0. = load volatile i32, ptr %3, align 4, !tbaa !11
  %13 = and i32 %.0..0..0..0., -1073741825
  store volatile i32 %13, ptr %3, align 4, !tbaa !11
  %.0..0..0..0.1 = load volatile i32, ptr %3, align 4, !tbaa !11
  %14 = or i32 %.0..0..0..0.1, -2147483648
  store volatile i32 %14, ptr %3, align 4, !tbaa !11
  %.0..0..0..0.2 = load volatile i32, ptr %3, align 4, !tbaa !11
  store volatile i32 %.0..0..0..0.2, ptr %10, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3)
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree norecurse 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 16}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}


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