; LLVM IR from ubaldot/defrecs :: stm32f4x/Hello_World/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

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

; 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
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %2) #4
  %10 = load ptr, ptr @xTaskHandle_1000ms, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %14

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

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

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