; LLVM IR from ubaldot/defrecs :: stm32f4x/ADC_Readings/application/debug (debug)

; 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.xTASK_STATUS = type { ptr, ptr, i64, i32, i64, i64, i32, ptr, i16 }

@xTaskHandle_1000ms = external global ptr, align 8
@xTaskHandle_200ms = external global ptr, align 8
@xTaskBuitinButtonDeferred = external global ptr, align 8
@xTaskUsart2RxDeferred = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @debug_step(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca %struct.xTASK_STATUS, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr %3) #4
  %13 = load ptr, ptr @xTaskHandle_1000ms, align 8, !tbaa !9
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %17

15:                                               ; preds = %1
  call void @vPortRaiseBASEPRI()
  br label %16

16:                                               ; preds = %16, %15
  br label %16

17:                                               ; preds = %1
  %18 = load ptr, ptr @xTaskHandle_1000ms, align 8, !tbaa !9
  call void @vTaskGetInfo(ptr noundef %18, ptr noundef %3, i64 noundef 1, i32 noundef 5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %19 = getelementptr inbounds %struct.xTASK_STATUS, ptr %3, i32 0, i32 2
  %20 = load i64, ptr %19, align 8, !tbaa !11
  store volatile i64 %20, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %21 = getelementptr inbounds %struct.xTASK_STATUS, ptr %3, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !16
  store volatile i32 %22, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #4
  %23 = getelementptr inbounds %struct.xTASK_STATUS, ptr %3, i32 0, i32 8
  %24 = load i16, ptr %23, align 8, !tbaa !17
  store volatile i16 %24, ptr %6, align 2, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %25 = getelementptr inbounds %struct.xTASK_STATUS, ptr %3, i32 0, i32 4
  %26 = load i64, ptr %25, align 8, !tbaa !19
  store volatile i64 %26, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %27 = load ptr, ptr @xTaskHandle_200ms, align 8, !tbaa !9
  %28 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %27)
  store volatile i64 %28, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %29 = load ptr, ptr @xTaskHandle_1000ms, align 8, !tbaa !9
  %30 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %29)
  store volatile i64 %30, ptr %9, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %31 = load ptr, ptr @xTaskBuitinButtonDeferred, align 8, !tbaa !9
  %32 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %31)
  store volatile i64 %32, ptr %10, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %33 = load ptr, ptr @xTaskUsart2RxDeferred, align 8, !tbaa !9
  %34 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %33)
  store volatile i64 %34, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %3) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @vPortRaiseBASEPRI() #2

declare void @vTaskGetInfo(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #3

declare i64 @uxTaskGetStackHighWaterMark(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 #3 = { "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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 16}
!12 = !{!"xTASK_STATUS", !10, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !13, i64 32, !13, i64 40, !6, i64 48, !10, i64 56, !14, i64 64}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !6, i64 24}
!17 = !{!12, !14, i64 64}
!18 = !{!14, !14, i64 0}
!19 = !{!12, !13, i64 32}


; 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.xTASK_STATUS = type { ptr, ptr, i64, i32, i64, i64, i32, ptr, i16 }

@xTaskHandle_1000ms = external local_unnamed_addr global ptr, align 8
@xTaskHandle_200ms = external local_unnamed_addr global ptr, align 8
@xTaskBuitinButtonDeferred = external local_unnamed_addr global ptr, align 8
@xTaskUsart2RxDeferred = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @debug_step(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca %struct.xTASK_STATUS, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i16, align 2
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %2) #4
  %11 = load ptr, ptr @xTaskHandle_1000ms, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %1
  tail call void @vPortRaiseBASEPRI()
  br label %14

14:                                               ; preds = %14, %13
  br label %14

15:                                               ; preds = %1
  call void @vTaskGetInfo(ptr noundef nonnull %11, ptr noundef nonnull %2, i64 noundef 1, i32 noundef 5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3)
  %16 = getelementptr inbounds i8, ptr %2, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !9
  store volatile i64 %17, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4)
  %18 = getelementptr inbounds i8, ptr %2, i64 24
  %19 = load i32, ptr %18, align 8, !tbaa !15
  store volatile i32 %19, ptr %4, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5)
  %20 = getelementptr inbounds i8, ptr %2, i64 64
  %21 = load i16, ptr %20, align 8, !tbaa !17
  store volatile i16 %21, ptr %5, align 2, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6)
  %22 = getelementptr inbounds i8, ptr %2, i64 32
  %23 = load i64, ptr %22, align 8, !tbaa !19
  store volatile i64 %23, ptr %6, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7)
  %24 = load ptr, ptr @xTaskHandle_200ms, align 8, !tbaa !5
  %25 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %24) #4
  store volatile i64 %25, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8)
  %26 = load ptr, ptr @xTaskHandle_1000ms, align 8, !tbaa !5
  %27 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %26) #4
  store volatile i64 %27, ptr %8, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9)
  %28 = load ptr, ptr @xTaskBuitinButtonDeferred, align 8, !tbaa !5
  %29 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %28) #4
  store volatile i64 %29, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10)
  %30 = load ptr, ptr @xTaskUsart2RxDeferred, align 8, !tbaa !5
  %31 = call i64 @uxTaskGetStackHighWaterMark(ptr noundef %30) #4
  store volatile i64 %31, ptr %10, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3)
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %2) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @vPortRaiseBASEPRI() local_unnamed_addr #2

declare void @vTaskGetInfo(ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

declare i64 @uxTaskGetStackHighWaterMark(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline 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 #3 = { "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 #4 = { 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, !11, i64 16}
!10 = !{!"xTASK_STATUS", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !6, i64 56, !13, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !12, i64 24}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !13, i64 64}
!18 = !{!13, !13, i64 0}
!19 = !{!10, !11, i64 32}


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