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

; 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.LTDC_HandleTypeDef = type { ptr, %struct.LTDC_InitTypeDef, [2 x %struct.LTDC_LayerCfgTypeDef], i32, i32, i32 }
%struct.LTDC_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.LTDC_ColorTypeDef }
%struct.LTDC_ColorTypeDef = type { i8, i8, i8, i8 }
%struct.LTDC_LayerCfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.LTDC_ColorTypeDef }
%struct.LTDC_TypeDef = type { [2 x i32], i32, i32, i32, i32, i32, [2 x i32], i32, [1 x i32], i32, [1 x 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
declare hidden void @LTDC_SetConfig(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_LTDC_SetWindowPosition(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  br label %12

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

17:                                               ; preds = %12
  store i32 2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %65

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

21:                                               ; preds = %18
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.LTDC_HandleTypeDef, ptr %24, i32 0, i32 4
  store volatile i32 2, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.LTDC_HandleTypeDef, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [2 x %struct.LTDC_LayerCfgTypeDef], ptr %27, i64 0, i64 %29
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %32, i32 0, i32 0
  store i32 %31, ptr %33, align 4, !tbaa !16
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %35, i32 0, i32 10
  %37 = load i32, ptr %36, align 4, !tbaa !17
  %38 = add i32 %34, %37
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %39, i32 0, i32 1
  store i32 %38, ptr %40, align 4, !tbaa !18
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %42, i32 0, i32 2
  store i32 %41, ptr %43, align 4, !tbaa !19
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %45, i32 0, i32 11
  %47 = load i32, ptr %46, align 4, !tbaa !20
  %48 = add i32 %44, %47
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %49, i32 0, i32 3
  store i32 %48, ptr %50, align 4, !tbaa !21
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !9
  call void @LTDC_SetConfig(ptr noundef %51, ptr noundef %52, i32 noundef %53)
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.LTDC_HandleTypeDef, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !22
  %57 = getelementptr inbounds %struct.LTDC_TypeDef, ptr %56, i32 0, i32 7
  store volatile i32 1, ptr %57, align 4, !tbaa !23
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.LTDC_HandleTypeDef, ptr %58, i32 0, i32 4
  store volatile i32 1, ptr %59, align 8, !tbaa !15
  br label %60

60:                                               ; preds = %23
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.LTDC_HandleTypeDef, ptr %61, i32 0, i32 3
  store i32 0, ptr %62, align 4, !tbaa !11
  br label %63

63:                                               ; preds = %60
  br label %64

64:                                               ; preds = %63
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %65

65:                                               ; preds = %64, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %66 = load i32, ptr %5, align 4
  ret i32 %66
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 164}
!12 = !{!"", !6, i64 0, !13, i64 8, !7, i64 60, !10, i64 164, !10, i64 168, !10, i64 172}
!13 = !{!"", !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, !14, i64 48}
!14 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!15 = !{!12, !10, i64 168}
!16 = !{!13, !10, i64 0}
!17 = !{!13, !10, i64 40}
!18 = !{!13, !10, i64 4}
!19 = !{!13, !10, i64 8}
!20 = !{!13, !10, i64 44}
!21 = !{!13, !10, i64 12}
!22 = !{!12, !6, i64 0}
!23 = !{!24, !10, i64 36}
!24 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !10, i64 36, !7, i64 40, !10, i64 44, !7, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72}


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

%struct.LTDC_LayerCfgTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.LTDC_ColorTypeDef }
%struct.LTDC_ColorTypeDef = type { i8, i8, i8, i8 }

; Function Attrs: nounwind uwtable
declare hidden void @LTDC_SetConfig(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_LTDC_SetWindowPosition(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 164
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %24, label %8

8:                                                ; preds = %4
  store i32 1, ptr %5, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 168
  store volatile i32 2, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 60
  %11 = zext i32 %3 to i64
  %12 = getelementptr inbounds [2 x %struct.LTDC_LayerCfgTypeDef], ptr %10, i64 0, i64 %11
  store i32 %1, ptr %12, align 4, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %12, i64 40
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %15 = add i32 %14, %1
  %16 = getelementptr inbounds i8, ptr %12, i64 4
  store i32 %15, ptr %16, align 4, !tbaa !16
  %17 = getelementptr inbounds i8, ptr %12, i64 8
  store i32 %2, ptr %17, align 4, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %12, i64 44
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = add i32 %19, %2
  %21 = getelementptr inbounds i8, ptr %12, i64 12
  store i32 %20, ptr %21, align 4, !tbaa !19
  tail call void @LTDC_SetConfig(ptr noundef nonnull %0, ptr noundef nonnull %12, i32 noundef %3)
  %22 = load ptr, ptr %0, align 8, !tbaa !20
  %23 = getelementptr inbounds i8, ptr %22, i64 36
  store volatile i32 1, ptr %23, align 4, !tbaa !21
  store volatile i32 1, ptr %9, align 8, !tbaa !13
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %4, %8
  %.0 = phi i32 [ 0, %8 ], [ 2, %4 ]
  ret i32 %.0
}

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, !11, i64 164}
!6 = !{!"", !7, i64 0, !10, i64 8, !8, i64 60, !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, i64 36, !11, i64 40, !11, i64 44, !12, i64 48}
!11 = !{!"int", !8, i64 0}
!12 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!13 = !{!6, !11, i64 168}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !11, i64 40}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !11, i64 44}
!19 = !{!10, !11, i64 12}
!20 = !{!6, !7, i64 0}
!21 = !{!22, !11, i64 36}
!22 = !{!"", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !8, i64 28, !11, i64 36, !8, i64 40, !11, i64 44, !8, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72}


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