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

; 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 }
%struct.JPEG_TypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, i32, i32, [2 x i32], [16 x i32], [16 x i32], [16 x i32], [16 x i32], [16 x i32], [32 x i32], [84 x i32], [103 x i32], i32, [88 x i32], [88 x i32], [8 x i32], [8 x i32] }

@HAL_JPEG_Init.JPEG_LUM_QuantTable = external hidden constant [64 x i8], align 16
@HAL_JPEG_Init.JPEG_CHROM_QuantTable = external hidden constant [64 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_JPEG_Init(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store i32 1, ptr %2, align 4
  br label %107

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

12:                                               ; preds = %7
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %13, i32 0, i32 15
  store i32 0, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void @HAL_JPEG_MspInit(ptr noundef %15)
  br label %16

16:                                               ; preds = %12, %7
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %17, i32 0, i32 16
  store volatile i32 2, ptr %18, align 4, !tbaa !9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %21, i32 0, i32 9
  %23 = load volatile i32, ptr %22, align 4, !tbaa !15
  %24 = zext i32 %23 to i64
  %25 = or i64 %24, 1
  %26 = trunc i64 %25 to i32
  store volatile i32 %26, ptr %22, align 4, !tbaa !15
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %29, i32 0, i32 0
  %31 = load volatile i32, ptr %30, align 4, !tbaa !17
  %32 = zext i32 %31 to i64
  %33 = and i64 %32, -2
  %34 = trunc i64 %33 to i32
  store volatile i32 %34, ptr %30, align 4, !tbaa !17
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %37, i32 0, i32 9
  %39 = load volatile i32, ptr %38, align 4, !tbaa !15
  %40 = and i32 %39, -127
  %41 = zext i32 %40 to i64
  %42 = or i64 %41, 0
  %43 = trunc i64 %42 to i32
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %46, i32 0, i32 9
  store volatile i32 %43, ptr %47, align 4, !tbaa !15
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %50, i32 0, i32 9
  %52 = load volatile i32, ptr %51, align 4, !tbaa !15
  %53 = zext i32 %52 to i64
  %54 = or i64 %53, 8192
  %55 = trunc i64 %54 to i32
  store volatile i32 %55, ptr %51, align 4, !tbaa !15
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %58, i32 0, i32 9
  %60 = load volatile i32, ptr %59, align 4, !tbaa !15
  %61 = zext i32 %60 to i64
  %62 = or i64 %61, 16384
  %63 = trunc i64 %62 to i32
  store volatile i32 %63, ptr %59, align 4, !tbaa !15
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %66, i32 0, i32 11
  %68 = load volatile i32, ptr %67, align 4, !tbaa !18
  %69 = or i32 %68, 96
  store volatile i32 %69, ptr %67, align 4, !tbaa !18
  %70 = zext i32 ptrtoint (ptr @HAL_JPEG_Init.JPEG_LUM_QuantTable to i32) to i64
  %71 = inttoptr i64 %70 to ptr
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %72, i32 0, i32 11
  store ptr %71, ptr %73, align 8, !tbaa !19
  %74 = zext i32 ptrtoint (ptr @HAL_JPEG_Init.JPEG_CHROM_QuantTable to i32) to i64
  %75 = inttoptr i64 %74 to ptr
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %76, i32 0, i32 12
  store ptr %75, ptr %77, align 8, !tbaa !20
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %78, i32 0, i32 13
  store ptr null, ptr %79, align 8, !tbaa !21
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %80, i32 0, i32 14
  store ptr null, ptr %81, align 8, !tbaa !22
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = call i32 @JPEG_Set_HuffEnc_Mem(ptr noundef %82)
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %88

85:                                               ; preds = %16
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %86, i32 0, i32 17
  store volatile i32 1, ptr %87, align 8, !tbaa !23
  store i32 1, ptr %2, align 4
  br label %107

88:                                               ; preds = %16
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !14
  %92 = getelementptr inbounds %struct.JPEG_TypeDef, ptr %91, i32 0, i32 1
  %93 = load volatile i32, ptr %92, align 4, !tbaa !24
  %94 = zext i32 %93 to i64
  %95 = or i64 %94, 256
  %96 = trunc i64 %95 to i32
  store volatile i32 %96, ptr %92, align 4, !tbaa !24
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %97, i32 0, i32 4
  store volatile i32 0, ptr %98, align 8, !tbaa !25
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %99, i32 0, i32 5
  store volatile i32 0, ptr %100, align 4, !tbaa !26
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %101, i32 0, i32 16
  store volatile i32 1, ptr %102, align 4, !tbaa !9
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %103, i32 0, i32 17
  store volatile i32 0, ptr %104, align 8, !tbaa !23
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.JPEG_HandleTypeDef, ptr %105, i32 0, i32 18
  store volatile i32 0, ptr %106, align 4, !tbaa !27
  store i32 0, ptr %2, align 4
  br label %107

107:                                              ; preds = %88, %85, %6
  %108 = load i32, ptr %2, align 4
  ret i32 %108
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_JPEG_MspInit(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @JPEG_Set_HuffEnc_Mem(ptr noundef) #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 124}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !6, i64 64, !6, i64 72, !7, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !12, i64 124, !12, i64 128, !12, i64 132}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 120}
!14 = !{!10, !6, i64 0}
!15 = !{!16, !12, i64 48}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !7, i64 32, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !7, i64 72, !7, i64 80, !7, i64 144, !7, i64 208, !7, i64 272, !7, i64 336, !7, i64 400, !7, i64 528, !7, i64 864, !12, i64 1276, !7, i64 1280, !7, i64 1632, !7, i64 1984, !7, i64 2016}
!17 = !{!16, !12, i64 0}
!18 = !{!16, !12, i64 56}
!19 = !{!10, !6, i64 88}
!20 = !{!10, !6, i64 96}
!21 = !{!10, !6, i64 104}
!22 = !{!10, !6, i64 112}
!23 = !{!10, !12, i64 128}
!24 = !{!16, !12, i64 4}
!25 = !{!10, !12, i64 48}
!26 = !{!10, !12, i64 52}
!27 = !{!10, !12, i64 132}


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

@HAL_JPEG_Init.JPEG_LUM_QuantTable = external hidden constant [64 x i8], align 16
@HAL_JPEG_Init.JPEG_CHROM_QuantTable = external hidden constant [64 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @HAL_JPEG_Init(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %44, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 124
  %5 = load volatile i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  store i32 0, ptr %8, align 8, !tbaa !12
  tail call void @HAL_JPEG_MspInit(ptr noundef nonnull %0)
  br label %9

9:                                                ; preds = %7, %3
  store volatile i32 2, ptr %4, align 4, !tbaa !5
  %10 = load ptr, ptr %0, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %10, i64 48
  %12 = load volatile i32, ptr %11, align 4, !tbaa !14
  %13 = or i32 %12, 1
  store volatile i32 %13, ptr %11, align 4, !tbaa !14
  %14 = load volatile i32, ptr %10, align 4, !tbaa !16
  %15 = and i32 %14, -2
  store volatile i32 %15, ptr %10, align 4, !tbaa !16
  %16 = load volatile i32, ptr %11, align 4, !tbaa !14
  %17 = and i32 %16, -127
  store volatile i32 %17, ptr %11, align 4, !tbaa !14
  %18 = load volatile i32, ptr %11, align 4, !tbaa !14
  %19 = or i32 %18, 8192
  store volatile i32 %19, ptr %11, align 4, !tbaa !14
  %20 = load volatile i32, ptr %11, align 4, !tbaa !14
  %21 = or i32 %20, 16384
  store volatile i32 %21, ptr %11, align 4, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %10, i64 56
  %23 = load volatile i32, ptr %22, align 4, !tbaa !17
  %24 = or i32 %23, 96
  store volatile i32 %24, ptr %22, align 4, !tbaa !17
  %25 = zext i32 ptrtoint (ptr @HAL_JPEG_Init.JPEG_LUM_QuantTable to i32) to i64
  %26 = inttoptr i64 %25 to ptr
  %27 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %26, ptr %27, align 8, !tbaa !18
  %28 = zext i32 ptrtoint (ptr @HAL_JPEG_Init.JPEG_CHROM_QuantTable to i32) to i64
  %29 = inttoptr i64 %28 to ptr
  %30 = getelementptr inbounds i8, ptr %0, i64 96
  store ptr %29, ptr %30, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %31, i8 0, i64 16, i1 false)
  %32 = tail call i32 @JPEG_Set_HuffEnc_Mem(ptr noundef nonnull %0)
  %.not = icmp eq i32 %32, 0
  br i1 %.not, label %35, label %33

33:                                               ; preds = %9
  %34 = getelementptr inbounds i8, ptr %0, i64 128
  store volatile i32 1, ptr %34, align 8, !tbaa !20
  br label %44

35:                                               ; preds = %9
  %36 = load ptr, ptr %0, align 8, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %36, i64 4
  %38 = load volatile i32, ptr %37, align 4, !tbaa !21
  %39 = or i32 %38, 256
  store volatile i32 %39, ptr %37, align 4, !tbaa !21
  %40 = getelementptr inbounds i8, ptr %0, i64 48
  store volatile i32 0, ptr %40, align 8, !tbaa !22
  %41 = getelementptr inbounds i8, ptr %0, i64 52
  store volatile i32 0, ptr %41, align 4, !tbaa !23
  store volatile i32 1, ptr %4, align 4, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %0, i64 128
  store volatile i32 0, ptr %42, align 8, !tbaa !20
  %43 = getelementptr inbounds i8, ptr %0, i64 132
  store volatile i32 0, ptr %43, align 4, !tbaa !24
  br label %44

44:                                               ; preds = %1, %35, %33
  %.0 = phi i32 [ 1, %33 ], [ 0, %35 ], [ 1, %1 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local void @HAL_JPEG_MspInit(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 124}
!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 120}
!13 = !{!6, !7, i64 0}
!14 = !{!15, !11, i64 48}
!15 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !8, i64 32, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !8, i64 72, !8, i64 80, !8, i64 144, !8, i64 208, !8, i64 272, !8, i64 336, !8, i64 400, !8, i64 528, !8, i64 864, !11, i64 1276, !8, i64 1280, !8, i64 1632, !8, i64 1984, !8, i64 2016}
!16 = !{!15, !11, i64 0}
!17 = !{!15, !11, i64 56}
!18 = !{!6, !7, i64 88}
!19 = !{!6, !7, i64 96}
!20 = !{!6, !11, i64 128}
!21 = !{!15, !11, i64 4}
!22 = !{!6, !11, i64 48}
!23 = !{!6, !11, i64 52}
!24 = !{!6, !11, i64 132}


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