; LLVM IR from carlk3/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico :: examples/command_line/tests (app4-IO_module_function_checker)

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

@__func__.lliot = external hidden unnamed_addr constant [6 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [98 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @test_diskio(i8 noundef zeroext, i32 noundef, ptr noundef, i32 noundef) #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @lliot(i64 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i64 %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 2048, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %8 = load i64, ptr %5, align 8, !tbaa !5
  %9 = call noalias ptr @malloc(i64 noundef %8) #6
  store ptr %9, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %15, label %12

12:                                               ; preds = %1
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = call i32 (ptr, i32, ptr, ...) @error_message_printf(ptr noundef @__func__.lliot, i32 noundef 340, ptr noundef @.str.27, i64 noundef %13)
  store i32 100, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %32

15:                                               ; preds = %1
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %17 = trunc i64 %16 to i8
  %18 = load ptr, ptr %6, align 8, !tbaa !9
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %20 = trunc i64 %19 to i32
  %21 = call i32 @test_diskio(i8 noundef zeroext %17, i32 noundef 3, ptr noundef %18, i32 noundef %20)
  store i32 %21, ptr %4, align 4, !tbaa !11
  %22 = load i32, ptr %4, align 4, !tbaa !11
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %15
  %25 = load i32, ptr %4, align 4, !tbaa !11
  %26 = call i32 (ptr, i32, ptr, ...) @error_message_printf(ptr noundef @__func__.lliot, i32 noundef 348, ptr noundef @.str.28, i32 noundef %25)
  br label %29

27:                                               ; preds = %15
  %28 = call i32 (ptr, ...) @info_message_printf(ptr noundef @.str.29)
  br label %29

29:                                               ; preds = %27, %24
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %30) #5
  %31 = load i32, ptr %4, align 4, !tbaa !11
  store i32 %31, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %32

32:                                               ; preds = %29, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %33 = load i32, ptr %2, align 4
  ret i32 %33
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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 = { "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 allocsize(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 #4 = { nounwind "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"long", !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, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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

@__func__.lliot = external hidden unnamed_addr constant [6 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [98 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @test_diskio(i8 noundef zeroext, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @info_message_printf(ptr noundef, ...) local_unnamed_addr #1

declare i32 @error_message_printf(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @lliot(i64 noundef %0) local_unnamed_addr #0 {
  %2 = tail call noalias dereferenceable_or_null(2048) ptr @malloc(i64 noundef 2048) #4
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %3, label %5

3:                                                ; preds = %1
  %4 = tail call i32 (ptr, i32, ptr, ...) @error_message_printf(ptr noundef nonnull @__func__.lliot, i32 noundef 340, ptr noundef nonnull @.str.27, i64 noundef 2048) #5
  br label %13

5:                                                ; preds = %1
  %6 = trunc i64 %0 to i8
  %7 = tail call i32 @test_diskio(i8 noundef zeroext %6, i32 noundef 3, ptr noundef nonnull %2, i32 noundef 2048)
  %.not12 = icmp eq i32 %7, 0
  br i1 %.not12, label %10, label %8

8:                                                ; preds = %5
  %9 = tail call i32 (ptr, i32, ptr, ...) @error_message_printf(ptr noundef nonnull @__func__.lliot, i32 noundef 348, ptr noundef nonnull @.str.28, i32 noundef %7) #5
  br label %12

10:                                               ; preds = %5
  %11 = tail call i32 (ptr, ...) @info_message_printf(ptr noundef nonnull @.str.29) #5
  br label %12

12:                                               ; preds = %10, %8
  tail call void @free(ptr noundef nonnull %2) #5
  br label %13

13:                                               ; preds = %12, %3
  %.0 = phi i32 [ %7, %12 ], [ 100, %3 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }
attributes #5 = { 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)"}


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