; LLVM IR from ctlst-tech/catpilot :: bsp/mcu/periph/can/stm32 (can)

; 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.can_t = type { [32 x i8], [32 x i8], %struct.FDCAN_HandleTypeDef, ptr, ptr, i32, i32, i32, i32, i32, i32, %struct.can_private_t }
%struct.FDCAN_HandleTypeDef = type { ptr, ptr, %struct.FDCAN_InitTypeDef, %struct.FDCAN_MsgRamAddressTypeDef, i32, i32, i32, i32 }
%struct.FDCAN_InitTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.FDCAN_MsgRamAddressTypeDef = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.can_private_t = type { i32, i32, ptr, ptr, ptr, ptr, i32, i8, i32, [32 x ptr], ptr, ptr }
%struct.can_header_t = type { i32, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1

; 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
define dso_local void @can_print_info(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = call i32 (ptr, ...) @printf_(ptr noundef @.str.6)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.can_t, ptr %9, i32 0, i32 11
  %11 = getelementptr inbounds %struct.can_private_t, ptr %10, i32 0, i32 6
  %12 = load i32, ptr %11, align 8, !tbaa !9
  switch i32 %12, label %17 [
    i32 0, label %13
    i32 2, label %13
    i32 1, label %15
  ]

13:                                               ; preds = %3, %3
  %14 = call i32 (ptr, ...) @printf_(ptr noundef @.str.7)
  br label %19

15:                                               ; preds = %3
  %16 = call i32 (ptr, ...) @printf_(ptr noundef @.str.8)
  br label %19

17:                                               ; preds = %3
  %18 = call i32 (ptr, ...) @printf_(ptr noundef @.str.9)
  br label %19

19:                                               ; preds = %17, %15, %13
  %20 = call i32 (ptr, ...) @printf_(ptr noundef @.str.10)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.can_t, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds [32 x i8], ptr %22, i64 0, i64 0
  %24 = call i32 (ptr, ...) @printf_(ptr noundef @.str.1, ptr noundef %23)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.can_header_t, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = call i32 (ptr, ...) @printf_(ptr noundef @.str.11, i32 noundef %27)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.can_header_t, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !19
  %32 = call i32 (ptr, ...) @printf_(ptr noundef @.str.12, i32 noundef %31)
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.can_header_t, ptr %33, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !20
  %36 = call i32 (ptr, ...) @printf_(ptr noundef @.str.13, i32 noundef %35)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.can_header_t, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 4, !tbaa !20
  %40 = call i32 (ptr, ...) @printf_(ptr noundef @.str.14, i32 noundef %39)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !21
  br label %41

41:                                               ; preds = %56, %19
  %42 = load i32, ptr %7, align 4, !tbaa !21
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.can_header_t, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %44, align 4, !tbaa !20
  %46 = icmp ult i32 %42, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %59

48:                                               ; preds = %41
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !21
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %49, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !22
  %54 = zext i8 %53 to i32
  %55 = call i32 (ptr, ...) @printf_(ptr noundef @.str.15, i32 noundef %54)
  br label %56

56:                                               ; preds = %48
  %57 = load i32, ptr %7, align 4, !tbaa !21
  %58 = add i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !21
  br label %41, !llvm.loop !23

59:                                               ; preds = %47
  %60 = call i32 (ptr, ...) @printf_(ptr noundef @.str.16)
  ret void
}

declare i32 @printf_(ptr noundef, ...) #2

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 = { "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 #3 = { 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, !13, i64 328}
!10 = !{!"", !7, i64 0, !7, i64 32, !11, i64 64, !6, i64 248, !6, i64 256, !13, i64 264, !13, i64 268, !13, i64 272, !13, i64 276, !13, i64 280, !13, i64 284, !15, i64 288}
!11 = !{!"", !6, i64 0, !6, i64 8, !12, i64 16, !14, i64 124, !13, i64 164, !13, i64 168, !13, i64 172, !13, i64 176}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84, !13, i64 88, !13, i64 92, !13, i64 96, !13, i64 100, !13, i64 104}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36}
!15 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !16, i64 44, !13, i64 48, !7, i64 56, !6, i64 312, !6, i64 320}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!18, !13, i64 0}
!18 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8}
!19 = !{!18, !13, i64 4}
!20 = !{!18, !13, i64 8}
!21 = !{!13, !13, i64 0}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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

@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@switch.table.can_print_info = private unnamed_addr constant [3 x ptr] [ptr @.str.7, ptr @.str.8, ptr @.str.7], align 8

; Function Attrs: nounwind uwtable
define dso_local void @can_print_info(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.6) #2
  %5 = getelementptr inbounds i8, ptr %0, i64 328
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp ult i32 %6, 3
  br i1 %7, label %switch.lookup, label %9

switch.lookup:                                    ; preds = %3
  %8 = zext nneg i32 %6 to i64
  %switch.gep = getelementptr inbounds [3 x ptr], ptr @switch.table.can_print_info, i64 0, i64 %8
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %9

9:                                                ; preds = %3, %switch.lookup
  %.str.9.sink = phi ptr [ %switch.load, %switch.lookup ], [ @.str.9, %3 ]
  %10 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull %.str.9.sink) #2
  %11 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.10) #2
  %12 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.1, ptr noundef nonnull %0) #2
  %13 = load i32, ptr %1, align 4, !tbaa !16
  %14 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.11, i32 noundef %13) #2
  %15 = getelementptr inbounds i8, ptr %1, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !18
  %17 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.12, i32 noundef %16) #2
  %18 = getelementptr inbounds i8, ptr %1, i64 8
  %19 = load i32, ptr %18, align 4, !tbaa !19
  %20 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.13, i32 noundef %19) #2
  %21 = load i32, ptr %18, align 4, !tbaa !19
  %22 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.14, i32 noundef %21) #2
  %23 = load i32, ptr %18, align 4, !tbaa !19
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %9
  %24 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.16) #2
  ret void

.lr.ph:                                           ; preds = %9, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %9 ]
  %25 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  %26 = load i8, ptr %25, align 1, !tbaa !20
  %27 = zext i8 %26 to i32
  %28 = tail call i32 (ptr, ...) @printf_(ptr noundef nonnull @.str.15, i32 noundef %27) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr %18, align 4, !tbaa !19
  %30 = zext i32 %29 to i64
  %31 = icmp ult i64 %indvars.iv.next, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !21
}

declare i32 @printf_(ptr noundef, ...) local_unnamed_addr #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 = { "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, !12, i64 328}
!6 = !{!"", !7, i64 0, !7, i64 32, !9, i64 64, !10, i64 248, !10, i64 256, !12, i64 264, !12, i64 268, !12, i64 272, !12, i64 276, !12, i64 280, !12, i64 284, !14, i64 288}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"", !10, i64 0, !10, i64 8, !11, i64 16, !13, i64 124, !12, i64 164, !12, i64 168, !12, i64 172, !12, i64 176}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36}
!14 = !{!"", !12, i64 0, !12, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !12, i64 40, !15, i64 44, !12, i64 48, !7, i64 56, !10, i64 312, !10, i64 320}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!18 = !{!17, !12, i64 4}
!19 = !{!17, !12, i64 8}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass