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

; 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.IRDA_HandleTypeDef = type { ptr, %struct.IRDA_InitTypeDef, ptr, i16, i16, ptr, i16, i16, i16, ptr, ptr, i32, i32, i32, i32 }
%struct.IRDA_InitTypeDef = type { i32, i32, i32, i32, i8, i16, 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(ptr noundef) #0

declare i32 @HAL_DMA_GetError(ptr noundef) #0

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

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

41:                                               ; preds = %28
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %42, i32 0, i32 9
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  %45 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %44, i32 0, i32 10
  store ptr null, ptr %45, align 8, !tbaa !18
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %46, i32 0, i32 9
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = call i32 @HAL_DMA_Abort(ptr noundef %48)
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %61

51:                                               ; preds = %41
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %52, i32 0, i32 9
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = call i32 @HAL_DMA_GetError(ptr noundef %54)
  %56 = icmp eq i32 %55, 32
  br i1 %56, label %57, label %60

57:                                               ; preds = %51
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %58, i32 0, i32 14
  store volatile i32 16, ptr %59, align 4, !tbaa !20
  store i32 3, ptr %2, align 4
  br label %122

60:                                               ; preds = %51
  br label %61

61:                                               ; preds = %60, %41
  br label %62

62:                                               ; preds = %61, %28
  br label %63

63:                                               ; preds = %62, %1
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.USART_TypeDef, ptr %66, i32 0, i32 2
  %68 = load volatile i32, ptr %67, align 4, !tbaa !16
  %69 = zext i32 %68 to i64
  %70 = and i64 %69, 64
  %71 = icmp eq i64 %70, 64
  br i1 %71, label %72, label %107

72:                                               ; preds = %63
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.USART_TypeDef, ptr %75, i32 0, i32 2
  %77 = load volatile i32, ptr %76, align 4, !tbaa !16
  %78 = zext i32 %77 to i64
  %79 = and i64 %78, -65
  %80 = trunc i64 %79 to i32
  store volatile i32 %80, ptr %76, align 4, !tbaa !16
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %81, i32 0, i32 10
  %83 = load ptr, ptr %82, align 8, !tbaa !21
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %106

85:                                               ; preds = %72
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %86, i32 0, i32 10
  %88 = load ptr, ptr %87, align 8, !tbaa !21
  %89 = getelementptr inbounds %struct.__DMA_HandleTypeDef, ptr %88, i32 0, i32 10
  store ptr null, ptr %89, align 8, !tbaa !18
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %90, i32 0, i32 10
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  %93 = call i32 @HAL_DMA_Abort(ptr noundef %92)
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %105

95:                                               ; preds = %85
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %96, i32 0, i32 10
  %98 = load ptr, ptr %97, align 8, !tbaa !21
  %99 = call i32 @HAL_DMA_GetError(ptr noundef %98)
  %100 = icmp eq i32 %99, 32
  br i1 %100, label %101, label %104

101:                                              ; preds = %95
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %102, i32 0, i32 14
  store volatile i32 16, ptr %103, align 4, !tbaa !20
  store i32 3, ptr %2, align 4
  br label %122

104:                                              ; preds = %95
  br label %105

105:                                              ; preds = %104, %85
  br label %106

106:                                              ; preds = %105, %72
  br label %107

107:                                              ; preds = %106, %63
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %108, i32 0, i32 4
  store volatile i16 0, ptr %109, align 2, !tbaa !22
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %110, i32 0, i32 7
  store volatile i16 0, ptr %111, align 2, !tbaa !23
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %112, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.USART_TypeDef, ptr %114, i32 0, i32 8
  store volatile i32 15, ptr %115, align 4, !tbaa !24
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %116, i32 0, i32 12
  store volatile i32 32, ptr %117, align 4, !tbaa !25
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %118, i32 0, i32 13
  store volatile i32 32, ptr %119, align 8, !tbaa !26
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.IRDA_HandleTypeDef, ptr %120, i32 0, i32 14
  store volatile i32 0, ptr %121, align 4, !tbaa !20
  store i32 0, ptr %2, align 4
  br label %122

122:                                              ; preds = %107, %101, %57
  %123 = load i32, ptr %2, align 4
  ret i32 %123
}

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 = !{!"", !6, i64 0, !11, i64 8, !6, i64 32, !13, i64 40, !13, i64 42, !6, i64 48, !13, i64 56, !13, i64 58, !13, i64 60, !6, i64 64, !6, i64 72, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !7, i64 16, !13, i64 18, !12, i64 20}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !12, i64 0}
!15 = !{!"", !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}
!16 = !{!15, !12, i64 8}
!17 = !{!10, !6, i64 64}
!18 = !{!19, !6, i64 112}
!19 = !{!"__DMA_HandleTypeDef", !6, i64 0, !15, 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}
!20 = !{!10, !12, i64 92}
!21 = !{!10, !6, i64 72}
!22 = !{!10, !13, i64 42}
!23 = !{!10, !13, i64 58}
!24 = !{!15, !12, i64 32}
!25 = !{!10, !12, i64 84}
!26 = !{!10, !12, i64 88}


; 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(ptr noundef) local_unnamed_addr #0

declare i32 @HAL_DMA_GetError(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 4) i32 @HAL_IRDA_Abort(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 !13
  %4 = and i32 %3, -481
  store volatile i32 %4, ptr %2, align 4, !tbaa !13
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load volatile i32, ptr %5, align 4, !tbaa !15
  %7 = and i32 %6, -2
  store volatile i32 %7, ptr %5, align 4, !tbaa !15
  %8 = load volatile i32, ptr %5, align 4, !tbaa !15
  %9 = and i32 %8, 128
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %22, label %10

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

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

18:                                               ; preds = %15
  %19 = load ptr, ptr %13, align 8, !tbaa !16
  %20 = tail call i32 @HAL_DMA_GetError(ptr noundef %19) #2
  %21 = icmp eq i32 %20, 32
  br i1 %21, label %46, label %22

22:                                               ; preds = %10, %18, %15, %1
  %23 = load ptr, ptr %0, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load volatile i32, ptr %24, align 4, !tbaa !15
  %26 = and i32 %25, 64
  %.not26 = icmp eq i32 %26, 0
  br i1 %.not26, label %39, label %27

27:                                               ; preds = %22
  %28 = load volatile i32, ptr %24, align 4, !tbaa !15
  %29 = and i32 %28, -65
  store volatile i32 %29, ptr %24, align 4, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %0, i64 72
  %31 = load ptr, ptr %30, align 8, !tbaa !19
  %.not27 = icmp eq ptr %31, null
  br i1 %.not27, label %39, label %32

32:                                               ; preds = %27
  %33 = getelementptr inbounds i8, ptr %31, i64 112
  store ptr null, ptr %33, align 8, !tbaa !17
  %34 = tail call i32 @HAL_DMA_Abort(ptr noundef nonnull %31) #2
  %.not28 = icmp eq i32 %34, 0
  br i1 %.not28, label %39, label %35

35:                                               ; preds = %32
  %36 = load ptr, ptr %30, align 8, !tbaa !19
  %37 = tail call i32 @HAL_DMA_GetError(ptr noundef %36) #2
  %38 = icmp eq i32 %37, 32
  br i1 %38, label %46, label %39

39:                                               ; preds = %27, %35, %32, %22
  %40 = getelementptr inbounds i8, ptr %0, i64 42
  store volatile i16 0, ptr %40, align 2, !tbaa !20
  %41 = getelementptr inbounds i8, ptr %0, i64 58
  store volatile i16 0, ptr %41, align 2, !tbaa !21
  %42 = load ptr, ptr %0, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 32
  store volatile i32 15, ptr %43, align 4, !tbaa !22
  %44 = getelementptr inbounds i8, ptr %0, i64 84
  store volatile i32 32, ptr %44, align 4, !tbaa !23
  %45 = getelementptr inbounds i8, ptr %0, i64 88
  store volatile i32 32, ptr %45, align 8, !tbaa !24
  br label %46

46:                                               ; preds = %35, %18, %39
  %.sink = phi i32 [ 0, %39 ], [ 16, %18 ], [ 16, %35 ]
  %.0 = phi i32 [ 0, %39 ], [ 3, %18 ], [ 3, %35 ]
  %47 = getelementptr inbounds i8, ptr %0, i64 92
  store volatile i32 %.sink, ptr %47, align 4, !tbaa !25
  ret i32 %.0
}

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 = !{!"", !7, i64 0, !10, i64 8, !7, i64 32, !12, i64 40, !12, i64 42, !7, i64 48, !12, i64 56, !12, i64 58, !12, i64 60, !7, i64 64, !7, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92}
!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, !8, i64 16, !12, i64 18, !11, i64 20}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"", !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}
!15 = !{!14, !11, i64 8}
!16 = !{!6, !7, i64 64}
!17 = !{!18, !7, i64 112}
!18 = !{!"__DMA_HandleTypeDef", !7, i64 0, !14, 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}
!19 = !{!6, !7, i64 72}
!20 = !{!6, !12, i64 42}
!21 = !{!6, !12, i64 58}
!22 = !{!14, !11, i64 32}
!23 = !{!6, !11, i64 84}
!24 = !{!6, !11, i64 88}
!25 = !{!6, !11, i64 92}


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