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

; 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.DCMI_HandleTypeDef = type { ptr, %struct.DCMI_InitTypeDef, i32, i32, i32, i32, i32, i32, ptr, i32 }
%struct.DCMI_InitTypeDef = type { i32, i32, i32, i32, i32, i32, %struct.DCMI_CodesInitTypeDef, i32, i32, i32, i32, i32 }
%struct.DCMI_CodesInitTypeDef = type { i8, i8, i8, i8 }
%struct.DCMI_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

12:                                               ; preds = %5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %13, i32 0, i32 2
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  store i32 2, ptr %6, align 4
  br label %47

18:                                               ; preds = %12
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %19, i32 0, i32 2
  store i32 1, ptr %20, align 8, !tbaa !11
  br label %21

21:                                               ; preds = %18
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %23, i32 0, i32 3
  store volatile i32 2, ptr %24, align 4, !tbaa !15
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = load i32, ptr %11, align 4, !tbaa !9
  %27 = shl i32 %26, 16
  %28 = or i32 %25, %27
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = getelementptr inbounds %struct.DCMI_TypeDef, ptr %31, i32 0, i32 9
  store volatile i32 %28, ptr %32, align 4, !tbaa !17
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = shl i32 %34, 16
  %36 = or i32 %33, %35
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = getelementptr inbounds %struct.DCMI_TypeDef, ptr %39, i32 0, i32 8
  store volatile i32 %36, ptr %40, align 4, !tbaa !19
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %41, i32 0, i32 3
  store volatile i32 1, ptr %42, align 4, !tbaa !15
  br label %43

43:                                               ; preds = %22
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.DCMI_HandleTypeDef, ptr %44, i32 0, i32 2
  store i32 0, ptr %45, align 8, !tbaa !11
  br label %46

46:                                               ; preds = %43
  store i32 0, ptr %6, align 4
  br label %47

47:                                               ; preds = %46, %17
  %48 = load i32, ptr %6, align 4
  ret i32 %48
}

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 56}
!12 = !{!"", !6, i64 0, !13, i64 8, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !6, i64 80, !10, i64 88}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !14, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44}
!14 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!15 = !{!12, !10, i64 60}
!16 = !{!12, !6, i64 0}
!17 = !{!18, !10, i64 36}
!18 = !{!"", !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}
!19 = !{!18, !10, i64 32}


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

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 60
  store volatile i32 2, ptr %10, align 4, !tbaa !13
  %11 = shl i32 %4, 16
  %12 = or i32 %11, %3
  %13 = load ptr, ptr %0, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %13, i64 36
  store volatile i32 %12, ptr %14, align 4, !tbaa !15
  %15 = shl i32 %2, 16
  %16 = or i32 %15, %1
  %17 = getelementptr inbounds i8, ptr %13, i64 32
  store volatile i32 %16, ptr %17, align 4, !tbaa !17
  store volatile i32 1, ptr %10, align 4, !tbaa !13
  store i32 0, ptr %6, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %5, %9
  %.0 = phi i32 [ 0, %9 ], [ 2, %5 ]
  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 56}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !7, i64 80, !11, i64 88}
!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, !12, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!13 = !{!6, !11, i64 60}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !11, i64 36}
!16 = !{!"", !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}
!17 = !{!16, !11, i64 32}


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