; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Drivers/STM32H7xx_HAL_Driver/Src (EnableWakeUpPin)

; 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.PWREx_WakeupPinTypeDef = type { i32, i32, i32 }
%struct.PWR_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.EXTI_TypeDef = type { i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], i32, i32, i32, i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, 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 void @HAL_PWREx_EnableWakeUpPin(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 196608, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = call i32 @__RBIT(i32 noundef %14)
  %16 = call i32 @llvm.ctlz.i32(i32 %15, i1 true)
  %17 = add i32 %16, 8
  %18 = and i32 %17, 31
  %19 = shl i32 %11, %18
  %20 = or i32 %8, %19
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %21, i32 0, i32 2
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = call i32 @__RBIT(i32 noundef %26)
  %28 = call i32 @llvm.ctlz.i32(i32 %27, i1 true)
  %29 = mul i32 %28, 2
  %30 = add i32 %29, 16
  %31 = and i32 %30, 31
  %32 = shl i32 %23, %31
  %33 = or i32 %20, %32
  store i32 %33, ptr %3, align 4, !tbaa !9
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = zext i32 %36 to i64
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = call i32 @__RBIT(i32 noundef %40)
  %42 = call i32 @llvm.ctlz.i32(i32 %41, i1 true)
  %43 = and i32 %42, 31
  %44 = zext i32 %43 to i64
  %45 = shl i64 256, %44
  %46 = or i64 %37, %45
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 4, !tbaa !11
  %50 = call i32 @__RBIT(i32 noundef %49)
  %51 = call i32 @llvm.ctlz.i32(i32 %50, i1 true)
  %52 = mul i32 %51, 2
  %53 = and i32 %52, 31
  %54 = shl i32 196608, %53
  %55 = zext i32 %54 to i64
  %56 = or i64 %46, %55
  %57 = trunc i64 %56 to i32
  store i32 %57, ptr %4, align 4, !tbaa !9
  %58 = load volatile i32, ptr getelementptr inbounds (%struct.PWR_TypeDef, ptr inttoptr (i64 1476544512 to ptr), i32 0, i32 10), align 4, !tbaa !15
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = xor i32 %59, -1
  %61 = and i32 %58, %60
  %62 = load i32, ptr %3, align 4, !tbaa !9
  %63 = or i32 %61, %62
  store volatile i32 %63, ptr getelementptr inbounds (%struct.PWR_TypeDef, ptr inttoptr (i64 1476544512 to ptr), i32 0, i32 10), align 4, !tbaa !15
  %64 = load volatile i32, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 25), align 4, !tbaa !17
  %65 = and i32 %64, -528482305
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.PWREx_WakeupPinTypeDef, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = shl i32 %68, 23
  %70 = or i32 %65, %69
  store volatile i32 %70, ptr getelementptr inbounds (%struct.EXTI_TypeDef, ptr inttoptr (i64 1476395008 to ptr), i32 0, i32 25), align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__RBIT(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctlz.i32(i32, i1 immarg) #3

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 = { alwaysinline 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!16, !10, i64 40}
!16 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40}
!17 = !{!18, !10, i64 144}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !7, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !7, i64 88, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168}


; 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 void @HAL_PWREx_EnableWakeUpPin(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !10
  %5 = tail call i32 @__RBIT(i32 noundef %2)
  %6 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %5, i1 true)
  %7 = add nuw nsw i32 %6, 8
  %8 = and i32 %7, 31
  %9 = shl i32 %4, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = load i32, ptr %0, align 4, !tbaa !5
  %13 = tail call i32 @__RBIT(i32 noundef %12)
  %14 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %13, i1 true)
  %15 = shl nuw nsw i32 %14, 1
  %16 = and i32 %15, 30
  %17 = xor i32 %16, 16
  %18 = shl i32 %11, %17
  %19 = load i32, ptr %0, align 4, !tbaa !5
  %20 = tail call i32 @__RBIT(i32 noundef %19)
  %21 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %20, i1 true)
  %22 = shl i32 256, %21
  %23 = load i32, ptr %0, align 4, !tbaa !5
  %24 = tail call i32 @__RBIT(i32 noundef %23)
  %25 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %24, i1 true)
  %26 = shl nuw nsw i32 %25, 1
  %27 = and i32 %26, 30
  %28 = shl i32 196608, %27
  %29 = or i32 %22, %28
  %30 = or i32 %29, %19
  %31 = load volatile i32, ptr inttoptr (i64 1476544552 to ptr), align 8, !tbaa !12
  %32 = xor i32 %30, -1
  %33 = and i32 %31, %32
  %34 = or i32 %9, %18
  %35 = or i32 %34, %33
  %36 = or i32 %35, %2
  store volatile i32 %36, ptr inttoptr (i64 1476544552 to ptr), align 8, !tbaa !12
  %37 = load volatile i32, ptr inttoptr (i64 1476395152 to ptr), align 16, !tbaa !14
  %38 = and i32 %37, -528482305
  %39 = load i32, ptr %0, align 4, !tbaa !5
  %40 = shl i32 %39, 23
  %41 = or i32 %40, %38
  store volatile i32 %41, ptr inttoptr (i64 1476395152 to ptr), align 16, !tbaa !14
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__RBIT(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctlz.i32(i32, i1 immarg) #2

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 = { alwaysinline 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 8}
!12 = !{!13, !7, i64 40}
!13 = !{!"", !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}
!14 = !{!15, !7, i64 144}
!15 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !8, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !8, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !8, i64 88, !7, i64 128, !7, i64 132, !7, i64 136, !7, i64 140, !7, i64 144, !7, i64 148, !7, i64 152, !7, i64 156, !7, i64 160, !7, i64 164, !7, i64 168}


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