; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_ArgsParser (isWhitespace__)

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

@top_____abandonFn__ = external dso_local thread_local global ptr, align 8

; 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 speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

; 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 @ArgsParser__isWhitespaceChar__(i8 noundef signext) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @ArgsParser__isWhitespace__(ptr %0, i32 %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca %struct.string__, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 0
  store ptr %0, ptr %9, align 8
  %10 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 1
  store i32 %1, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %42, %2
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = getelementptr inbounds %struct.string__, ptr %4, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %16, label %43

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr %4, ptr %6, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %17 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %17, ptr %7, align 4, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !12
  %20 = getelementptr inbounds %struct.string__, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = icmp ult i32 %18, %21
  br i1 %22, label %26, label %23

23:                                               ; preds = %16
  %24 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  call void %25(i32 noundef -3)
  br label %26

26:                                               ; preds = %23, %16
  %27 = load ptr, ptr %6, align 8, !tbaa !12
  %28 = getelementptr inbounds %struct.string__, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !14
  %34 = call zeroext i8 @ArgsParser__isWhitespaceChar__(i8 noundef signext %33)
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %37, label %36

36:                                               ; preds = %26
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %40

37:                                               ; preds = %26
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %5, align 4, !tbaa !5
  store i32 0, ptr %8, align 4
  br label %40

40:                                               ; preds = %37, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %41 = load i32, ptr %8, align 4
  switch i32 %41, label %44 [
    i32 0, label %42
  ]

42:                                               ; preds = %40
  br label %11, !llvm.loop !15

43:                                               ; preds = %11
  store i32 0, ptr %8, align 4
  br label %44

44:                                               ; preds = %43, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %45 = load i32, ptr %8, align 4
  switch i32 %45, label %49 [
    i32 0, label %46
    i32 1, label %47
  ]

46:                                               ; preds = %44
  store i8 1, ptr %3, align 1
  br label %47

47:                                               ; preds = %46, %44
  %48 = load i8, ptr %3, align 1
  ret i8 %48

49:                                               ; preds = %44
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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, !6, i64 8}
!10 = !{!"", !11, i64 0, !6, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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: nounwind uwtable
declare dso_local zeroext i8 @ArgsParser__isWhitespaceChar__(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @ArgsParser__isWhitespace__(ptr nocapture readonly %0, i32 %1) local_unnamed_addr #0 {
  %smax = tail call i32 @llvm.smax.i32(i32 %1, i32 0)
  %wide.trip.count = zext nneg i32 %smax to i64
  br label %3

3:                                                ; preds = %4, %2
  %indvars.iv = phi i64 [ %indvars.iv.next, %4 ], [ 0, %2 ]
  %exitcond = icmp eq i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond, label %8, label %4

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = tail call zeroext i8 @ArgsParser__isWhitespaceChar__(i8 noundef signext %6)
  %.not.not = icmp eq i8 %7, 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %.not.not, label %8, label %3, !llvm.loop !8

8:                                                ; preds = %3, %4
  %9 = sext i32 %1 to i64
  %.not = icmp sge i64 %indvars.iv, %9
  %spec.select = zext i1 %.not to i8
  ret i8 %spec.select
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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 speculatable willreturn memory(none) }

!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"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyCFGPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass