; LLVM IR from embeddednirvana/A-Rudimentary-RTOS-for-Satellite-Control :: fs (sat_fs)

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

@return_set = external dso_local global 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
declare dso_local zeroext i8 @fs_mount_chip() #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @setup_File_System() #1 {
  %1 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #2
  store i8 0, ptr %1, align 1, !tbaa !5
  %2 = call zeroext i8 @fs_mount_chip()
  %3 = icmp ne i8 %2, 0
  br i1 %3, label %9, label %4

4:                                                ; preds = %0
  %5 = call zeroext i8 @check_filesystem()
  %6 = icmp ne i8 %5, 0
  br i1 %6, label %7, label %8

7:                                                ; preds = %4
  store i8 -1, ptr %1, align 1, !tbaa !5
  br label %8

8:                                                ; preds = %7, %4
  br label %9

9:                                                ; preds = %8, %0
  %10 = call zeroext i8 @setup_fat_mat()
  store i8 %10, ptr @return_set, align 1, !tbaa !5
  %11 = load i8, ptr %1, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #2
  ret i8 %11
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @check_filesystem() #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @setup_fat_mat() #1

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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

@return_set = external dso_local local_unnamed_addr global i8, align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @fs_mount_chip() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 -1, 1) i8 @setup_File_System() local_unnamed_addr #0 {
  %1 = tail call zeroext i8 @fs_mount_chip()
  %.not = icmp eq i8 %1, 0
  br i1 %.not, label %2, label %4

2:                                                ; preds = %0
  %3 = tail call zeroext i8 @check_filesystem()
  %.not1 = icmp ne i8 %3, 0
  %spec.select = sext i1 %.not1 to i8
  br label %4

4:                                                ; preds = %2, %0
  %.0 = phi i8 [ 0, %0 ], [ %spec.select, %2 ]
  %5 = tail call zeroext i8 @setup_fat_mat()
  store i8 %5, ptr @return_set, align 1, !tbaa !5
  ret i8 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @check_filesystem() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @setup_fat_mat() local_unnamed_addr #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass