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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_DAC_Start(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %7, i32 0, i32 2
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  store i32 2, ptr %3, align 4
  br label %78

12:                                               ; preds = %6
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %13, i32 0, i32 2
  store i32 1, ptr %14, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %12
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %17, i32 0, i32 1
  store volatile i32 2, ptr %18, align 8, !tbaa !13
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = zext i32 %19 to i64
  %21 = and i64 %20, 16
  %22 = shl i64 1, %21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = getelementptr inbounds %struct.DAC_TypeDef, ptr %25, i32 0, i32 0
  %27 = load volatile i32, ptr %26, align 4, !tbaa !15
  %28 = zext i32 %27 to i64
  %29 = or i64 %28, %22
  %30 = trunc i64 %29 to i32
  store volatile i32 %30, ptr %26, align 4, !tbaa !15
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %52

33:                                               ; preds = %16
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  %37 = getelementptr inbounds %struct.DAC_TypeDef, ptr %36, i32 0, i32 0
  %38 = load volatile i32, ptr %37, align 4, !tbaa !15
  %39 = zext i32 %38 to i64
  %40 = and i64 %39, 62
  %41 = icmp eq i64 %40, 2
  br i1 %41, label %42, label %51

42:                                               ; preds = %33
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds %struct.DAC_TypeDef, ptr %45, i32 0, i32 1
  %47 = load volatile i32, ptr %46, align 4, !tbaa !17
  %48 = zext i32 %47 to i64
  %49 = or i64 %48, 1
  %50 = trunc i64 %49 to i32
  store volatile i32 %50, ptr %46, align 4, !tbaa !17
  br label %51

51:                                               ; preds = %42, %33
  br label %71

52:                                               ; preds = %16
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = getelementptr inbounds %struct.DAC_TypeDef, ptr %55, i32 0, i32 0
  %57 = load volatile i32, ptr %56, align 4, !tbaa !15
  %58 = zext i32 %57 to i64
  %59 = and i64 %58, 4063232
  %60 = icmp eq i64 %59, 131072
  br i1 %60, label %61, label %70

61:                                               ; preds = %52
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = getelementptr inbounds %struct.DAC_TypeDef, ptr %64, i32 0, i32 1
  %66 = load volatile i32, ptr %65, align 4, !tbaa !17
  %67 = zext i32 %66 to i64
  %68 = or i64 %67, 2
  %69 = trunc i64 %68 to i32
  store volatile i32 %69, ptr %65, align 4, !tbaa !17
  br label %70

70:                                               ; preds = %61, %52
  br label %71

71:                                               ; preds = %70, %51
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %72, i32 0, i32 1
  store volatile i32 1, ptr %73, align 8, !tbaa !13
  br label %74

74:                                               ; preds = %71
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.DAC_HandleTypeDef, ptr %75, i32 0, i32 2
  store i32 0, ptr %76, align 4, !tbaa !11
  br label %77

77:                                               ; preds = %74
  store i32 0, ptr %3, align 4
  br label %78

78:                                               ; preds = %77, %11
  %79 = load i32, ptr %3, align 4
  ret i32 %79
}

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

!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 12}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !10, i64 32}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !6, i64 0}
!15 = !{!16, !10, i64 0}
!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, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76}
!17 = !{!16, !10, i64 4}


; 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_DAC_Start(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %25, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store volatile i32 2, ptr %7, align 8, !tbaa !11
  %8 = and i32 %1, 16
  %9 = shl nuw nsw i32 1, %8
  %10 = load ptr, ptr %0, align 8, !tbaa !12
  %11 = load volatile i32, ptr %10, align 4, !tbaa !13
  %12 = or i32 %11, %9
  store volatile i32 %12, ptr %10, align 4, !tbaa !13
  %13 = icmp eq i32 %1, 0
  %14 = load volatile i32, ptr %10, align 4, !tbaa !13
  br i1 %13, label %15, label %18

15:                                               ; preds = %6
  %16 = and i32 %14, 62
  %17 = icmp eq i32 %16, 2
  br i1 %17, label %.sink.split, label %24

18:                                               ; preds = %6
  %19 = and i32 %14, 4063232
  %20 = icmp eq i32 %19, 131072
  br i1 %20, label %.sink.split, label %24

.sink.split:                                      ; preds = %18, %15
  %.sink14 = phi i32 [ 1, %15 ], [ 2, %18 ]
  %21 = getelementptr inbounds i8, ptr %10, i64 4
  %22 = load volatile i32, ptr %21, align 4, !tbaa !15
  %23 = or i32 %22, %.sink14
  store volatile i32 %23, ptr %21, align 4, !tbaa !15
  br label %24

24:                                               ; preds = %.sink.split, %18, %15
  store volatile i32 1, ptr %7, align 8, !tbaa !11
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %2, %24
  %.0 = phi i32 [ 0, %24 ], [ 2, %2 ]
  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, !10, i64 12}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !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, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76}
!15 = !{!14, !10, i64 4}


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