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

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

; 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_SetWindowSize_NoReload(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 %61

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
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = add i32 %31, %34
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %36, i32 0, i32 1
  store i32 %35, ptr %37, align 4, !tbaa !17
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !18
  %42 = add i32 %38, %41
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %43, i32 0, i32 3
  store i32 %42, ptr %44, align 4, !tbaa !19
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %46, i32 0, i32 10
  store i32 %45, ptr %47, align 4, !tbaa !20
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.LTDC_LayerCfgTypeDef, ptr %49, i32 0, i32 11
  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 4
  store volatile i32 1, ptr %55, align 8, !tbaa !15
  br label %56

56:                                               ; preds = %23
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.LTDC_HandleTypeDef, ptr %57, i32 0, i32 3
  store i32 0, ptr %58, align 4, !tbaa !11
  br label %59

59:                                               ; preds = %56
  br label %60

60:                                               ; preds = %59
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %61

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

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 4}
!18 = !{!13, !10, i64 8}
!19 = !{!13, !10, i64 12}
!20 = !{!13, !10, i64 40}
!21 = !{!13, !10, i64 44}


; 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_SetWindowSize_NoReload(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 %22, 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
  %13 = load i32, ptr %12, align 4, !tbaa !14
  %14 = add i32 %13, %1
  %15 = getelementptr inbounds i8, ptr %12, i64 4
  store i32 %14, ptr %15, align 4, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %12, i64 8
  %17 = load i32, ptr %16, align 4, !tbaa !16
  %18 = add i32 %17, %2
  %19 = getelementptr inbounds i8, ptr %12, i64 12
  store i32 %18, ptr %19, align 4, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %12, i64 40
  store i32 %1, ptr %20, align 4, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %12, i64 44
  store i32 %2, ptr %21, align 4, !tbaa !19
  tail call void @LTDC_SetConfig(ptr noundef nonnull %0, ptr noundef nonnull %12, i32 noundef %3)
  store volatile i32 1, ptr %9, align 8, !tbaa !13
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %22

22:                                               ; 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 4}
!16 = !{!10, !11, i64 8}
!17 = !{!10, !11, i64 12}
!18 = !{!10, !11, i64 40}
!19 = !{!10, !11, i64 44}


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