; LLVM IR from marcinbor85/microshell :: src/src (ush)

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

; 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 zeroext i1 @ush_service(ptr noundef %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  store i8 0, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call zeroext i1 @ush_reset_service(ptr noundef %6)
  %8 = zext i1 %7 to i32
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

11:                                               ; preds = %1
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call zeroext i1 @ush_prompt_service(ptr noundef %12)
  %14 = zext i1 %13 to i32
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

17:                                               ; preds = %11
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = call zeroext i1 @ush_read_service(ptr noundef %18, ptr noundef %4)
  %20 = zext i1 %19 to i32
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %17
  %23 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %24 = trunc i8 %23 to i1
  store i1 %24, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

25:                                               ; preds = %17
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call zeroext i1 @ush_autocomp_service(ptr noundef %26)
  %28 = zext i1 %27 to i32
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

31:                                               ; preds = %25
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call zeroext i1 @ush_parse_service(ptr noundef %32)
  %34 = zext i1 %33 to i32
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

37:                                               ; preds = %31
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call zeroext i1 @ush_write_service(ptr noundef %38)
  %40 = zext i1 %39 to i32
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

43:                                               ; preds = %37
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = call zeroext i1 @ush_process_service(ptr noundef %44)
  %46 = zext i1 %45 to i32
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

49:                                               ; preds = %43
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %50

50:                                               ; preds = %49, %48, %42, %36, %30, %22, %16, %10
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %51 = load i1, ptr %2, align 1
  ret i1 %51
}

declare zeroext i1 @ush_reset_service(ptr noundef) #2

declare zeroext i1 @ush_prompt_service(ptr noundef) #2

declare zeroext i1 @ush_read_service(ptr noundef, ptr noundef) #2

declare zeroext i1 @ush_autocomp_service(ptr noundef) #2

declare zeroext i1 @ush_parse_service(ptr noundef) #2

declare zeroext i1 @ush_write_service(ptr noundef) #2

declare zeroext i1 @ush_process_service(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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


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

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

; Function Attrs: mustprogress 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 zeroext i1 @ush_service(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #3
  store i8 0, ptr %2, align 1, !tbaa !5
  %3 = tail call zeroext i1 @ush_reset_service(ptr noundef %0) #3
  br i1 %3, label %19, label %4

4:                                                ; preds = %1
  %5 = tail call zeroext i1 @ush_prompt_service(ptr noundef %0) #3
  br i1 %5, label %19, label %6

6:                                                ; preds = %4
  %7 = call zeroext i1 @ush_read_service(ptr noundef %0, ptr noundef nonnull %2) #3
  br i1 %7, label %8, label %11

8:                                                ; preds = %6
  %9 = load i8, ptr %2, align 1, !tbaa !5, !range !9, !noundef !10
  %10 = trunc nuw i8 %9 to i1
  br label %19

11:                                               ; preds = %6
  %12 = call zeroext i1 @ush_autocomp_service(ptr noundef %0) #3
  br i1 %12, label %19, label %13

13:                                               ; preds = %11
  %14 = call zeroext i1 @ush_parse_service(ptr noundef %0) #3
  br i1 %14, label %19, label %15

15:                                               ; preds = %13
  %16 = call zeroext i1 @ush_write_service(ptr noundef %0) #3
  br i1 %16, label %19, label %17

17:                                               ; preds = %15
  %18 = call zeroext i1 @ush_process_service(ptr noundef %0) #3
  br label %19

19:                                               ; preds = %17, %15, %13, %11, %4, %1, %8
  %.0 = phi i1 [ %10, %8 ], [ true, %1 ], [ true, %4 ], [ true, %11 ], [ true, %13 ], [ true, %15 ], [ %18, %17 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #3
  ret i1 %.0
}

declare zeroext i1 @ush_reset_service(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ush_prompt_service(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ush_read_service(ptr noundef, ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ush_autocomp_service(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ush_parse_service(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ush_write_service(ptr noundef) local_unnamed_addr #2

declare zeroext i1 @ush_process_service(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}


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