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

; 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 }
%struct.__DMA_HandleTypeDef = type { ptr, %struct.DMA_InitTypeDef, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i32, ptr, ptr, i32 }
%struct.DMA_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

declare i32 @HAL_DMA_Abort_IT(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_UART_AbortTransmit_IT(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %3, i32 0, i32 0
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.USART_TypeDef, ptr %5, i32 0, i32 0
  %7 = load volatile i32, ptr %6, align 4, !tbaa !15
  %8 = zext i32 %7 to i64
  %9 = and i64 %8, -193
  %10 = trunc i64 %9 to i32
  store volatile i32 %10, ptr %6, align 4, !tbaa !15
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.USART_TypeDef, ptr %13, i32 0, i32 2
  %15 = load volatile i32, ptr %14, align 4, !tbaa !17
  %16 = zext i32 %15 to i64
  %17 = and i64 %16, -8388609
  %18 = trunc i64 %17 to i32
  store volatile i32 %18, ptr %14, align 4, !tbaa !17
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.USART_TypeDef, ptr %21, i32 0, i32 2
  %23 = load volatile i32, ptr %22, align 4, !tbaa !17
  %24 = zext i32 %23 to i64
  %25 = and i64 %24, 128
  %26 = icmp eq i64 %25, 128
  br i1 %26, label %27, label %69

27:                                               ; preds = %1
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.USART_TypeDef, ptr %30, i32 0, i32 2
  %32 = load volatile i32, ptr %31, align 4, !tbaa !17
  %33 = zext i32 %32 to i64
  %34 = and i64 %33, -129
  %35 = trunc i64 %34 to i32
  store volatile i32 %35, ptr %31, align 4, !tbaa !17
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %36, i32 0, i32 15
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %60

40:                                               ; preds = %27
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %41, i32 0, i32 15
  %43 = load ptr, ptr %42, align 8, !tbaa !18
  %44 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %43, i32 0, i32 10
  store ptr @UART_DMATxOnlyAbortCallback, ptr %44, align 8, !tbaa !19
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %45, i32 0, i32 15
  %47 = load ptr, ptr %46, align 8, !tbaa !18
  %48 = call i32 @HAL_DMA_Abort_IT(ptr noundef %47)
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %59

50:                                               ; preds = %40
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %51, i32 0, i32 15
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  %54 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %53, i32 0, i32 10
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %56, i32 0, i32 15
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  call void %55(ptr noundef %58)
  br label %59

59:                                               ; preds = %50, %40
  br label %68

60:                                               ; preds = %27
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %61, i32 0, i32 5
  store volatile i16 0, ptr %62, align 2, !tbaa !21
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %63, i32 0, i32 14
  store ptr null, ptr %64, align 8, !tbaa !22
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %65, i32 0, i32 18
  store volatile i32 32, ptr %66, align 4, !tbaa !23
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_UART_AbortTransmitCpltCallback(ptr noundef %67)
  br label %68

68:                                               ; preds = %60, %59
  br label %90

69:                                               ; preds = %1
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %70, i32 0, i32 5
  store volatile i16 0, ptr %71, align 2, !tbaa !21
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %72, i32 0, i32 14
  store ptr null, ptr %73, align 8, !tbaa !22
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %74, i32 0, i32 10
  %76 = load i32, ptr %75, align 8, !tbaa !24
  %77 = zext i32 %76 to i64
  %78 = icmp eq i64 %77, 536870912
  br i1 %78, label %79, label %86

79:                                               ; preds = %69
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.USART_TypeDef, ptr %82, i32 0, i32 6
  %84 = load volatile i32, ptr %83, align 4, !tbaa !25
  %85 = or i32 %84, 16
  store volatile i32 %85, ptr %83, align 4, !tbaa !25
  br label %86

86:                                               ; preds = %79, %69
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.__UART_HandleTypeDef, ptr %87, i32 0, i32 18
  store volatile i32 32, ptr %88, align 4, !tbaa !23
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  call void @HAL_UART_AbortTransmitCpltCallback(ptr noundef %89)
  br label %90

90:                                               ; preds = %86, %68
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden void @UART_DMATxOnlyAbortCallback(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_UART_AbortTransmitCpltCallback(ptr noundef) #1

attributes #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!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 = !{!16, !12, i64 0}
!16 = !{!"", !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}
!17 = !{!16, !12, i64 8}
!18 = !{!10, !6, i64 144}
!19 = !{!20, !6, i64 112}
!20 = !{!"__DMA_HandleTypeDef", !6, i64 0, !16, i64 8, !12, i64 56, !12, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !12, i64 124, !12, i64 128, !6, i64 136, !6, i64 144, !12, i64 152, !6, i64 160, !6, i64 168, !12, i64 176}
!21 = !{!10, !14, i64 98}
!22 = !{!10, !6, i64 136}
!23 = !{!10, !12, i64 164}
!24 = !{!10, !12, i64 120}
!25 = !{!16, !12, i64 24}


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

declare i32 @HAL_DMA_Abort_IT(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @HAL_UART_AbortTransmit_IT(ptr noundef %0) local_unnamed_addr #1 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = load volatile i32, ptr %2, align 4, !tbaa !14
  %4 = and i32 %3, -193
  store volatile i32 %4, ptr %2, align 4, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load volatile i32, ptr %5, align 4, !tbaa !16
  %7 = and i32 %6, -8388609
  store volatile i32 %7, ptr %5, align 4, !tbaa !16
  %8 = load volatile i32, ptr %5, align 4, !tbaa !16
  %9 = and i32 %8, 128
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %26, label %10

10:                                               ; preds = %1
  %11 = load volatile i32, ptr %5, align 4, !tbaa !16
  %12 = and i32 %11, -129
  store volatile i32 %12, ptr %5, align 4, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 144
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %.not19 = icmp eq ptr %14, null
  br i1 %.not19, label %22, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %14, i64 112
  store ptr @UART_DMATxOnlyAbortCallback, ptr %16, align 8, !tbaa !18
  %17 = tail call i32 @HAL_DMA_Abort_IT(ptr noundef nonnull %14) #2
  %.not20 = icmp eq i32 %17, 0
  br i1 %.not20, label %38, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr %13, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %19, i64 112
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  tail call void %21(ptr noundef %19) #2
  br label %38

22:                                               ; preds = %10
  %23 = getelementptr inbounds i8, ptr %0, i64 98
  store volatile i16 0, ptr %23, align 2, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr null, ptr %24, align 8, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %0, i64 164
  store volatile i32 32, ptr %25, align 4, !tbaa !22
  tail call void @HAL_UART_AbortTransmitCpltCallback(ptr noundef nonnull %0)
  br label %38

26:                                               ; preds = %1
  %27 = getelementptr inbounds i8, ptr %0, i64 98
  store volatile i16 0, ptr %27, align 2, !tbaa !20
  %28 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr null, ptr %28, align 8, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %0, i64 120
  %30 = load i32, ptr %29, align 8, !tbaa !23
  %31 = icmp eq i32 %30, 536870912
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = getelementptr inbounds i8, ptr %2, i64 24
  %34 = load volatile i32, ptr %33, align 4, !tbaa !24
  %35 = or i32 %34, 16
  store volatile i32 %35, ptr %33, align 4, !tbaa !24
  br label %36

36:                                               ; preds = %32, %26
  %37 = getelementptr inbounds i8, ptr %0, i64 164
  store volatile i32 32, ptr %37, align 4, !tbaa !22
  tail call void @HAL_UART_AbortTransmitCpltCallback(ptr noundef nonnull %0)
  br label %38

38:                                               ; preds = %22, %18, %15, %36
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden void @UART_DMATxOnlyAbortCallback(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_UART_AbortTransmitCpltCallback(ptr noundef) local_unnamed_addr #1

attributes #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 = { 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, !7, i64 0}
!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 = !{!15, !11, i64 0}
!15 = !{!"", !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}
!16 = !{!15, !11, i64 8}
!17 = !{!6, !7, i64 144}
!18 = !{!19, !7, i64 112}
!19 = !{!"__DMA_HandleTypeDef", !7, i64 0, !15, i64 8, !11, i64 56, !11, i64 60, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 124, !11, i64 128, !7, i64 136, !7, i64 144, !11, i64 152, !7, i64 160, !7, i64 168, !11, i64 176}
!20 = !{!6, !13, i64 98}
!21 = !{!6, !7, i64 136}
!22 = !{!6, !11, i64 164}
!23 = !{!6, !11, i64 120}
!24 = !{!15, !11, i64 24}


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