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

; 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.MMC_HandleTypeDef = type { ptr, %struct.SDMMC_InitTypeDef, i32, ptr, i32, ptr, i32, i32, i32, i32, %struct.HAL_MMC_CardInfoTypeDef, [4 x i32], [4 x i32], [128 x i32] }
%struct.SDMMC_InitTypeDef = type { i32, i32, i32, i32, i32 }
%struct.HAL_MMC_CardInfoTypeDef = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.HAL_MMC_CardCIDTypeDef = type { i8, i16, i32, i8, i8, i32, i8, i16, i8, i8 }

; Function Attrs: nounwind uwtable
define dso_local i32 @HAL_MMC_GetCardCID(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %5, i32 0, i32 12
  %7 = getelementptr inbounds [4 x i32], ptr %6, i64 0, i64 0
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = and i32 %8, -16777216
  %10 = lshr i32 %9, 24
  %11 = trunc i32 %10 to i8
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %12, i32 0, i32 0
  store volatile i8 %11, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %14, i32 0, i32 12
  %16 = getelementptr inbounds [4 x i32], ptr %15, i64 0, i64 0
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = and i32 %17, 16776960
  %19 = lshr i32 %18, 8
  %20 = trunc i32 %19 to i16
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %21, i32 0, i32 1
  store volatile i16 %20, ptr %22, align 2, !tbaa !14
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %23, i32 0, i32 12
  %25 = getelementptr inbounds [4 x i32], ptr %24, i64 0, i64 0
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = and i32 %26, 255
  %28 = shl i32 %27, 24
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %29, i32 0, i32 12
  %31 = getelementptr inbounds [4 x i32], ptr %30, i64 0, i64 1
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = and i32 %32, -256
  %34 = lshr i32 %33, 8
  %35 = or i32 %28, %34
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %36, i32 0, i32 2
  store volatile i32 %35, ptr %37, align 4, !tbaa !15
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %38, i32 0, i32 12
  %40 = getelementptr inbounds [4 x i32], ptr %39, i64 0, i64 1
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = and i32 %41, 255
  %43 = trunc i32 %42 to i8
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %44, i32 0, i32 3
  store volatile i8 %43, ptr %45, align 4, !tbaa !16
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %46, i32 0, i32 12
  %48 = getelementptr inbounds [4 x i32], ptr %47, i64 0, i64 2
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = and i32 %49, -16777216
  %51 = lshr i32 %50, 24
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %53, i32 0, i32 4
  store volatile i8 %52, ptr %54, align 1, !tbaa !17
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %55, i32 0, i32 12
  %57 = getelementptr inbounds [4 x i32], ptr %56, i64 0, i64 2
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = and i32 %58, 16777215
  %60 = shl i32 %59, 8
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %61, i32 0, i32 12
  %63 = getelementptr inbounds [4 x i32], ptr %62, i64 0, i64 3
  %64 = load i32, ptr %63, align 4, !tbaa !9
  %65 = and i32 %64, -16777216
  %66 = lshr i32 %65, 24
  %67 = or i32 %60, %66
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %68, i32 0, i32 5
  store volatile i32 %67, ptr %69, align 4, !tbaa !18
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %70, i32 0, i32 12
  %72 = getelementptr inbounds [4 x i32], ptr %71, i64 0, i64 3
  %73 = load i32, ptr %72, align 4, !tbaa !9
  %74 = and i32 %73, 15728640
  %75 = lshr i32 %74, 20
  %76 = trunc i32 %75 to i8
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %77, i32 0, i32 6
  store volatile i8 %76, ptr %78, align 4, !tbaa !19
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %79, i32 0, i32 12
  %81 = getelementptr inbounds [4 x i32], ptr %80, i64 0, i64 3
  %82 = load i32, ptr %81, align 4, !tbaa !9
  %83 = and i32 %82, 1048320
  %84 = lshr i32 %83, 8
  %85 = trunc i32 %84 to i16
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %86, i32 0, i32 7
  store volatile i16 %85, ptr %87, align 2, !tbaa !20
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.MMC_HandleTypeDef, ptr %88, i32 0, i32 12
  %90 = getelementptr inbounds [4 x i32], ptr %89, i64 0, i64 3
  %91 = load i32, ptr %90, align 4, !tbaa !9
  %92 = and i32 %91, 254
  %93 = lshr i32 %92, 1
  %94 = trunc i32 %93 to i8
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %95, i32 0, i32 8
  store volatile i8 %94, ptr %96, align 4, !tbaa !21
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.HAL_MMC_CardCIDTypeDef, ptr %97, i32 0, i32 9
  store volatile i8 1, ptr %98, align 1, !tbaa !22
  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, !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, !7, i64 0}
!12 = !{!"", !7, i64 0, !13, i64 2, !10, i64 4, !7, i64 8, !7, i64 9, !10, i64 12, !7, i64 16, !13, i64 18, !7, i64 20, !7, i64 21}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 2}
!15 = !{!12, !10, i64 4}
!16 = !{!12, !7, i64 8}
!17 = !{!12, !7, i64 9}
!18 = !{!12, !10, i64 12}
!19 = !{!12, !7, i64 16}
!20 = !{!12, !13, i64 18}
!21 = !{!12, !7, i64 20}
!22 = !{!12, !7, i64 21}


; 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 memory(argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local noundef i32 @HAL_MMC_GetCardCID(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 116
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = lshr i32 %4, 24
  %6 = trunc nuw i32 %5 to i8
  store volatile i8 %6, ptr %1, align 4, !tbaa !9
  %7 = lshr i32 %4, 8
  %8 = trunc i32 %7 to i16
  %9 = getelementptr inbounds i8, ptr %1, i64 2
  store volatile i16 %8, ptr %9, align 2, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = tail call i32 @llvm.fshl.i32(i32 %4, i32 %11, i32 24)
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  store volatile i32 %12, ptr %13, align 4, !tbaa !13
  %14 = load i32, ptr %10, align 4, !tbaa !5
  %15 = trunc i32 %14 to i8
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  store volatile i8 %15, ptr %16, align 4, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %0, i64 124
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = lshr i32 %18, 24
  %20 = trunc nuw i32 %19 to i8
  %21 = getelementptr inbounds i8, ptr %1, i64 9
  store volatile i8 %20, ptr %21, align 1, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %0, i64 128
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = tail call i32 @llvm.fshl.i32(i32 %18, i32 %23, i32 8)
  %25 = getelementptr inbounds i8, ptr %1, i64 12
  store volatile i32 %24, ptr %25, align 4, !tbaa !16
  %26 = load i32, ptr %22, align 4, !tbaa !5
  %27 = lshr i32 %26, 20
  %28 = trunc i32 %27 to i8
  %29 = and i8 %28, 15
  %30 = getelementptr inbounds i8, ptr %1, i64 16
  store volatile i8 %29, ptr %30, align 4, !tbaa !17
  %31 = lshr i32 %26, 8
  %32 = trunc i32 %31 to i16
  %33 = and i16 %32, 4095
  %34 = getelementptr inbounds i8, ptr %1, i64 18
  store volatile i16 %33, ptr %34, align 2, !tbaa !18
  %35 = trunc i32 %26 to i8
  %36 = lshr i8 %35, 1
  %37 = getelementptr inbounds i8, ptr %1, i64 20
  store volatile i8 %36, ptr %37, align 4, !tbaa !19
  %38 = getelementptr inbounds i8, ptr %1, i64 21
  store volatile i8 1, ptr %38, align 1, !tbaa !20
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.fshl.i32(i32, i32, i32) #1

attributes #0 = { nofree norecurse nounwind memory(argmem: readwrite, inaccessiblemem: readwrite) 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 nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 0}
!10 = !{!"", !7, i64 0, !11, i64 2, !6, i64 4, !7, i64 8, !7, i64 9, !6, i64 12, !7, i64 16, !11, i64 18, !7, i64 20, !7, i64 21}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 2}
!13 = !{!10, !6, i64 4}
!14 = !{!10, !7, i64 8}
!15 = !{!10, !7, i64 9}
!16 = !{!10, !6, i64 12}
!17 = !{!10, !7, i64 16}
!18 = !{!10, !11, i64 18}
!19 = !{!10, !7, i64 20}
!20 = !{!10, !7, i64 21}


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