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

; 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.JPEG_HandleTypeDef = type { ptr, %struct.JPEG_ConfTypeDef, ptr, ptr, i32, i32, i32, i32, ptr, ptr, i8, ptr, ptr, ptr, ptr, i32, i32, i32, i32 }
%struct.JPEG_ConfTypeDef = type { i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare hidden void @JPEG_Init_Process(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_JPEG_Decode_IT(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %20, label %14

14:                                               ; preds = %5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %20, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %14, %5
  store i32 1, ptr %6, align 4
  br label %83

21:                                               ; preds = %17
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %23, i32 0, i32 15
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  store i32 2, ptr %6, align 4
  br label %83

28:                                               ; preds = %22
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %29, i32 0, i32 15
  store i32 1, ptr %30, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %28
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %33, i32 0, i32 16
  %35 = load volatile i32, ptr %34, align 4, !tbaa !14
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %77

37:                                               ; preds = %32
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %38, i32 0, i32 16
  store volatile i32 4, ptr %39, align 4, !tbaa !14
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %40, i32 0, i32 18
  %42 = load volatile i32, ptr %41, align 4, !tbaa !15
  %43 = and i32 %42, -16
  store volatile i32 %43, ptr %41, align 4, !tbaa !15
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %44, i32 0, i32 18
  %46 = load volatile i32, ptr %45, align 4, !tbaa !15
  %47 = or i32 %46, 10
  store volatile i32 %47, ptr %45, align 4, !tbaa !15
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %49, i32 0, i32 2
  store ptr %48, ptr %50, align 8, !tbaa !16
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %52, i32 0, i32 3
  store ptr %51, ptr %53, align 8, !tbaa !17
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = urem i64 %57, 4
  %59 = sub i64 %55, %58
  %60 = trunc i64 %59 to i32
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %61, i32 0, i32 6
  store i32 %60, ptr %62, align 8, !tbaa !18
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = urem i64 %66, 4
  %68 = sub i64 %64, %67
  %69 = trunc i64 %68 to i32
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %70, i32 0, i32 7
  store i32 %69, ptr %71, align 4, !tbaa !19
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %72, i32 0, i32 4
  store volatile i32 0, ptr %73, align 8, !tbaa !20
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %74, i32 0, i32 5
  store volatile i32 0, ptr %75, align 4, !tbaa !21
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  call void @JPEG_Init_Process(ptr noundef %76)
  br label %82

77:                                               ; preds = %32
  br label %78

78:                                               ; preds = %77
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %79, i32 0, i32 15
  store i32 0, ptr %80, align 8, !tbaa !11
  br label %81

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

82:                                               ; preds = %37
  store i32 0, ptr %6, align 4
  br label %83

83:                                               ; preds = %82, %81, %27, %20
  %84 = load i32, ptr %6, align 4
  ret i32 %84
}

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 120}
!12 = !{!"", !6, i64 0, !13, i64 8, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !7, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16}
!14 = !{!12, !10, i64 124}
!15 = !{!12, !10, i64 132}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 40}
!18 = !{!12, !10, i64 56}
!19 = !{!12, !10, i64 60}
!20 = !{!12, !10, i64 48}
!21 = !{!12, !10, i64 52}


; 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: nounwind uwtable
declare hidden void @JPEG_Init_Process(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @HAL_JPEG_Decode_IT(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = icmp eq ptr %0, null
  %7 = icmp eq ptr %1, null
  %or.cond = or i1 %6, %7
  %8 = icmp eq ptr %3, null
  %or.cond3 = or i1 %or.cond, %8
  br i1 %or.cond3, label %32, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %32, label %13

13:                                               ; preds = %9
  store i32 1, ptr %10, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 124
  %15 = load volatile i32, ptr %14, align 4, !tbaa !12
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %31

17:                                               ; preds = %13
  store volatile i32 4, ptr %14, align 4, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %0, i64 132
  %19 = load volatile i32, ptr %18, align 4, !tbaa !13
  %20 = and i32 %19, -16
  store volatile i32 %20, ptr %18, align 4, !tbaa !13
  %21 = load volatile i32, ptr %18, align 4, !tbaa !13
  %22 = or i32 %21, 10
  store volatile i32 %22, ptr %18, align 4, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %1, ptr %23, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %3, ptr %24, align 8, !tbaa !15
  %25 = and i32 %2, -4
  %26 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 %25, ptr %26, align 8, !tbaa !16
  %27 = and i32 %4, -4
  %28 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %27, ptr %28, align 4, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  store volatile i32 0, ptr %29, align 8, !tbaa !18
  %30 = getelementptr inbounds i8, ptr %0, i64 52
  store volatile i32 0, ptr %30, align 4, !tbaa !19
  tail call void @JPEG_Init_Process(ptr noundef nonnull %0)
  br label %32

31:                                               ; preds = %13
  store i32 0, ptr %10, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %9, %5, %17, %31
  %.0 = phi i32 [ 0, %17 ], [ 2, %31 ], [ 1, %5 ], [ 2, %9 ]
  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 120}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !7, i64 64, !7, i64 72, !8, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132}
!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 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 124}
!13 = !{!6, !11, i64 132}
!14 = !{!6, !7, i64 32}
!15 = !{!6, !7, i64 40}
!16 = !{!6, !11, i64 56}
!17 = !{!6, !11, i64 60}
!18 = !{!6, !11, i64 48}
!19 = !{!6, !11, i64 52}


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