; 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"

; 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_DriveVbus(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
  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
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = ptrtoint ptr %7 to i32
  store i32 %8, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store volatile i32 0, ptr %6, align 4, !tbaa !10
  %9 = load i32, ptr %5, align 4, !tbaa !10
  %10 = zext i32 %9 to i64
  %11 = add i64 %10, 1088
  %12 = inttoptr i64 %11 to ptr
  %13 = load volatile i32, ptr %12, align 4, !tbaa !10
  store volatile i32 %13, ptr %6, align 4, !tbaa !10
  %14 = load volatile i32, ptr %6, align 4, !tbaa !10
  %15 = zext i32 %14 to i64
  %16 = and i64 %15, -47
  %17 = trunc i64 %16 to i32
  store volatile i32 %17, ptr %6, align 4, !tbaa !10
  %18 = load volatile i32, ptr %6, align 4, !tbaa !10
  %19 = zext i32 %18 to i64
  %20 = and i64 %19, 4096
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %35

22:                                               ; preds = %2
  %23 = load i8, ptr %4, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %35

26:                                               ; preds = %22
  %27 = load volatile i32, ptr %6, align 4, !tbaa !10
  %28 = zext i32 %27 to i64
  %29 = or i64 4096, %28
  %30 = trunc i64 %29 to i32
  %31 = load i32, ptr %5, align 4, !tbaa !10
  %32 = zext i32 %31 to i64
  %33 = add i64 %32, 1088
  %34 = inttoptr i64 %33 to ptr
  store volatile i32 %30, ptr %34, align 4, !tbaa !10
  br label %35

35:                                               ; preds = %26, %22, %2
  %36 = load volatile i32, ptr %6, align 4, !tbaa !10
  %37 = zext i32 %36 to i64
  %38 = and i64 %37, 4096
  %39 = icmp eq i64 %38, 4096
  br i1 %39, label %40, label %53

40:                                               ; preds = %35
  %41 = load i8, ptr %4, align 1, !tbaa !9
  %42 = zext i8 %41 to i32
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %53

44:                                               ; preds = %40
  %45 = load volatile i32, ptr %6, align 4, !tbaa !10
  %46 = zext i32 %45 to i64
  %47 = and i64 -4097, %46
  %48 = trunc i64 %47 to i32
  %49 = load i32, ptr %5, align 4, !tbaa !10
  %50 = zext i32 %49 to i64
  %51 = add i64 %50, 1088
  %52 = inttoptr i64 %51 to ptr
  store volatile i32 %48, ptr %52, align 4, !tbaa !10
  br label %53

53:                                               ; preds = %44, %40, %35
  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}


; 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_DriveVbus(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)
  store volatile i32 0, ptr %3, align 4, !tbaa !5
  %5 = and i64 %4, 4294967295
  %6 = add nuw nsw i64 %5, 1088
  %7 = inttoptr i64 %6 to ptr
  %8 = load volatile i32, ptr %7, align 4, !tbaa !5
  store volatile i32 %8, ptr %3, align 4, !tbaa !5
  %.0..0..0..0. = load volatile i32, ptr %3, align 4, !tbaa !5
  %9 = and i32 %.0..0..0..0., -47
  store volatile i32 %9, ptr %3, align 4, !tbaa !5
  %.0..0..0..0.6 = load volatile i32, ptr %3, align 4, !tbaa !5
  %10 = and i32 %.0..0..0..0.6, 4096
  %11 = icmp eq i32 %10, 0
  %12 = icmp eq i8 %1, 1
  %or.cond = and i1 %12, %11
  %.0..0..0..0.7 = load volatile i32, ptr %3, align 4, !tbaa !5
  br i1 %or.cond, label %.thread, label %14

.thread:                                          ; preds = %2
  %13 = or i32 %.0..0..0..0.7, 4096
  store volatile i32 %13, ptr %7, align 4, !tbaa !5
  %.0..0..0..0.815 = load volatile i32, ptr %3, align 4, !tbaa !5
  br label %20

14:                                               ; preds = %2
  %15 = and i32 %.0..0..0..0.7, 4096
  %16 = icmp ne i32 %15, 0
  %17 = icmp eq i8 %1, 0
  %or.cond5 = and i1 %17, %16
  br i1 %or.cond5, label %18, label %20

18:                                               ; preds = %14
  %.0..0..0..0.9 = load volatile i32, ptr %3, align 4, !tbaa !5
  %19 = and i32 %.0..0..0..0.9, -4097
  store volatile i32 %19, ptr %7, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %.thread, %18, %14
  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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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