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

; 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.__UART_HandleTypeDef = type { ptr, %struct.UART_InitTypeDef, %struct.UART_AdvFeatureInitTypeDef, ptr, i16, i16, ptr, i16, i16, i16, i32, i16, i16, ptr, ptr, ptr, ptr, i32, i32, i32, i32 }
%struct.UART_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.UART_AdvFeatureInitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.USART_TypeDef = type { 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 i32 @HAL_UART_DMAPause(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %7, i32 0, i32 18
  %9 = load volatile i32, ptr %8, align 4, !tbaa !9
  store i32 %9, ptr %4, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %10, i32 0, i32 19
  %12 = load volatile i32, ptr %11, align 8, !tbaa !16
  store i32 %12, ptr %5, align 4, !tbaa !15
  br label %13

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %14, i32 0, i32 17
  %16 = load i32, ptr %15, align 8, !tbaa !17
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  store i32 2, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %88

19:                                               ; preds = %13
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %20, i32 0, i32 17
  store i32 1, ptr %21, align 8, !tbaa !17
  br label %22

22:                                               ; preds = %19
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = getelementptr inbounds %struct.USART_TypeDef, ptr %27, i32 0, i32 2
  %29 = load volatile i32, ptr %28, align 4, !tbaa !19
  %30 = zext i32 %29 to i64
  %31 = and i64 %30, 128
  %32 = icmp eq i64 %31, 128
  br i1 %32, label %33, label %45

33:                                               ; preds = %24
  %34 = load i32, ptr %4, align 4, !tbaa !15
  %35 = icmp eq i32 %34, 33
  br i1 %35, label %36, label %45

36:                                               ; preds = %33
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !18
  %40 = getelementptr inbounds %struct.USART_TypeDef, ptr %39, i32 0, i32 2
  %41 = load volatile i32, ptr %40, align 4, !tbaa !19
  %42 = zext i32 %41 to i64
  %43 = and i64 %42, -129
  %44 = trunc i64 %43 to i32
  store volatile i32 %44, ptr %40, align 4, !tbaa !19
  br label %45

45:                                               ; preds = %36, %33, %24
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !18
  %49 = getelementptr inbounds %struct.USART_TypeDef, ptr %48, i32 0, i32 2
  %50 = load volatile i32, ptr %49, align 4, !tbaa !19
  %51 = zext i32 %50 to i64
  %52 = and i64 %51, 64
  %53 = icmp eq i64 %52, 64
  br i1 %53, label %54, label %82

54:                                               ; preds = %45
  %55 = load i32, ptr %5, align 4, !tbaa !15
  %56 = icmp eq i32 %55, 34
  br i1 %56, label %57, label %82

57:                                               ; preds = %54
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !18
  %61 = getelementptr inbounds %struct.USART_TypeDef, ptr %60, i32 0, i32 0
  %62 = load volatile i32, ptr %61, align 4, !tbaa !21
  %63 = zext i32 %62 to i64
  %64 = and i64 %63, -257
  %65 = trunc i64 %64 to i32
  store volatile i32 %65, ptr %61, align 4, !tbaa !21
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %66, i32 0, i32 0
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = getelementptr inbounds %struct.USART_TypeDef, ptr %68, i32 0, i32 2
  %70 = load volatile i32, ptr %69, align 4, !tbaa !19
  %71 = zext i32 %70 to i64
  %72 = and i64 %71, -2
  %73 = trunc i64 %72 to i32
  store volatile i32 %73, ptr %69, align 4, !tbaa !19
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !18
  %77 = getelementptr inbounds %struct.USART_TypeDef, ptr %76, i32 0, i32 2
  %78 = load volatile i32, ptr %77, align 4, !tbaa !19
  %79 = zext i32 %78 to i64
  %80 = and i64 %79, -65
  %81 = trunc i64 %80 to i32
  store volatile i32 %81, ptr %77, align 4, !tbaa !19
  br label %82

82:                                               ; preds = %57, %54, %45
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %84, i32 0, i32 17
  store i32 0, ptr %85, align 8, !tbaa !17
  br label %86

86:                                               ; preds = %83
  br label %87

87:                                               ; preds = %86
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %88

88:                                               ; preds = %87, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %89 = load i32, ptr %2, align 4
  ret i32 %89
}

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 = !{!10, !12, i64 164}
!10 = !{!"__UART_HandleTypeDef", !6, i64 0, !11, i64 8, !13, i64 44, !6, i64 88, !14, i64 96, !14, i64 98, !6, i64 104, !14, i64 112, !14, i64 114, !14, i64 116, !12, i64 120, !14, i64 124, !14, i64 126, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !12, i64 160, !12, i64 164, !12, i64 168, !12, i64 172}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !12, i64 168}
!17 = !{!10, !12, i64 160}
!18 = !{!10, !6, i64 0}
!19 = !{!20, !12, i64 8}
!20 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44}
!21 = !{!20, !12, 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: nofree norecurse nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_UART_DMAPause(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 164
  %3 = load volatile i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 168
  %5 = load volatile i32, ptr %4, align 8, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %0, i64 160
  %7 = load i32, ptr %6, align 8, !tbaa !15
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %32, label %9

9:                                                ; preds = %1
  %10 = load ptr, ptr %0, align 8, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load volatile i32, ptr %11, align 4, !tbaa !17
  %13 = and i32 %12, 128
  %14 = icmp ne i32 %13, 0
  %15 = icmp eq i32 %3, 33
  %or.cond = select i1 %14, i1 %15, i1 false
  br i1 %or.cond, label %16, label %19

16:                                               ; preds = %9
  %17 = load volatile i32, ptr %11, align 4, !tbaa !17
  %18 = and i32 %17, -129
  store volatile i32 %18, ptr %11, align 4, !tbaa !17
  br label %19

19:                                               ; preds = %16, %9
  %20 = load volatile i32, ptr %11, align 4, !tbaa !17
  %21 = and i32 %20, 64
  %22 = icmp ne i32 %21, 0
  %23 = icmp eq i32 %5, 34
  %or.cond3 = select i1 %22, i1 %23, i1 false
  br i1 %or.cond3, label %24, label %31

24:                                               ; preds = %19
  %25 = load volatile i32, ptr %10, align 4, !tbaa !19
  %26 = and i32 %25, -257
  store volatile i32 %26, ptr %10, align 4, !tbaa !19
  %27 = load volatile i32, ptr %11, align 4, !tbaa !17
  %28 = and i32 %27, -2
  store volatile i32 %28, ptr %11, align 4, !tbaa !17
  %29 = load volatile i32, ptr %11, align 4, !tbaa !17
  %30 = and i32 %29, -65
  store volatile i32 %30, ptr %11, align 4, !tbaa !17
  br label %31

31:                                               ; preds = %19, %24
  store i32 0, ptr %6, align 8, !tbaa !15
  br label %32

32:                                               ; preds = %1, %31
  %.0 = phi i32 [ 0, %31 ], [ 2, %1 ]
  ret i32 %.0
}

attributes #0 = { 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, !11, i64 164}
!6 = !{!"__UART_HandleTypeDef", !7, i64 0, !10, i64 8, !12, i64 44, !7, i64 88, !13, i64 96, !13, i64 98, !7, i64 104, !13, i64 112, !13, i64 114, !13, i64 116, !11, i64 120, !13, i64 124, !13, i64 126, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!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 = !{!"int", !8, i64 0}
!12 = !{!"", !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}
!13 = !{!"short", !8, i64 0}
!14 = !{!6, !11, i64 168}
!15 = !{!6, !11, i64 160}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !11, i64 8}
!18 = !{!"", !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}
!19 = !{!18, !11, i64 0}


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