; LLVM IR from jingweizhanghuai/Morn :: src/util (morn_string)

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

@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@__FUNCTION__.mHelp = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x 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 willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strspn(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @mHelp(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [2048 x i8], align 16
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 2048, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = call i64 @strlen(ptr noundef %11) #6
  store i64 %12, ptr %7, align 8, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call noalias ptr @fopen(ptr noundef %13, ptr noundef @.str.4)
  store ptr %14, ptr %5, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %54, %2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call i32 @feof(ptr noundef %16) #5
  %18 = icmp ne i32 %17, 0
  %19 = xor i1 %18, true
  br i1 %19, label %20, label %55

20:                                               ; preds = %15
  br label %21

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %22 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call ptr @fgets(ptr noundef %22, i32 noundef 2048, ptr noundef %23)
  %25 = icmp eq ptr %24, null
  %26 = zext i1 %25 to i32
  store i32 %26, ptr %8, align 4, !tbaa !11
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = load i32, ptr %8, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %30, i32 noundef -1, ptr noundef @.str.1, i32 noundef 404, ptr noundef @__FUNCTION__.mHelp, ptr noundef @.str.5)
  br label %31

31:                                               ; preds = %29, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  %34 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %35 = load i8, ptr %34, align 16, !tbaa !13
  %36 = sext i8 %35 to i32
  %37 = icmp eq i32 %36, 91
  br i1 %37, label %38, label %54

38:                                               ; preds = %33
  %39 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call i64 @strspn(ptr noundef %40, ptr noundef %41) #6
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = icmp uge i64 %42, %43
  br i1 %44, label %45, label %53

45:                                               ; preds = %38
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = add i64 %46, 1
  %48 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !13
  %50 = sext i8 %49 to i32
  %51 = icmp eq i32 %50, 93
  br i1 %51, label %52, label %53

52:                                               ; preds = %45
  br label %55

53:                                               ; preds = %45, %38
  br label %54

54:                                               ; preds = %53, %33
  br label %15, !llvm.loop !14

55:                                               ; preds = %52, %15
  br label %56

56:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %57 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = call ptr @fgets(ptr noundef %57, i32 noundef 2048, ptr noundef %58)
  %60 = icmp eq ptr %59, null
  %61 = zext i1 %60 to i32
  store i32 %61, ptr %9, align 4, !tbaa !11
  %62 = load i32, ptr %9, align 4, !tbaa !11
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %56
  %65 = load i32, ptr %9, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %65, i32 noundef -1, ptr noundef @.str.1, i32 noundef 412, ptr noundef @__FUNCTION__.mHelp, ptr noundef @.str.5)
  br label %66

66:                                               ; preds = %64, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %96, %68
  %70 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %71 = load i8, ptr %70, align 16, !tbaa !13
  %72 = sext i8 %71 to i32
  %73 = icmp ne i32 %72, 91
  br i1 %73, label %74, label %79

74:                                               ; preds = %69
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = call i32 @feof(ptr noundef %75) #5
  %77 = icmp ne i32 %76, 0
  %78 = xor i1 %77, true
  br label %79

79:                                               ; preds = %74, %69
  %80 = phi i1 [ false, %69 ], [ %78, %74 ]
  br i1 %80, label %81, label %97

81:                                               ; preds = %79
  %82 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %82)
  br label %84

84:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %85 = getelementptr inbounds [2048 x i8], ptr %6, i64 0, i64 0
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = call ptr @fgets(ptr noundef %85, i32 noundef 2048, ptr noundef %86)
  %88 = icmp eq ptr %87, null
  %89 = zext i1 %88 to i32
  store i32 %89, ptr %10, align 4, !tbaa !11
  %90 = load i32, ptr %10, align 4, !tbaa !11
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %94

92:                                               ; preds = %84
  %93 = load i32, ptr %10, align 4, !tbaa !11
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %93, i32 noundef -1, ptr noundef @.str.1, i32 noundef 416, ptr noundef @__FUNCTION__.mHelp, ptr noundef @.str.5)
  br label %94

94:                                               ; preds = %92, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %95

95:                                               ; preds = %94
  br label %96

96:                                               ; preds = %95
  br label %69, !llvm.loop !16

97:                                               ; preds = %79
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = call i32 @fclose(ptr noundef %98)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 2048, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #4

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #2

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

declare i32 @fclose(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 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 #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 willreturn memory(read) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@__FUNCTION__.mHelp = external hidden unnamed_addr constant [6 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1

; 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strspn(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @mHelp(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #3 {
  %3 = alloca [2048 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %3) #5
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %5 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.4)
  %6 = add i64 %4, 1
  %7 = getelementptr inbounds [2048 x i8], ptr %3, i64 0, i64 %6
  %8 = tail call i32 @feof(ptr noundef %5) #5
  %.not19 = icmp eq i32 %8, 0
  br i1 %.not19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %9 = getelementptr inbounds i8, ptr %3, i64 1
  br label %10

10:                                               ; preds = %.lr.ph, %22
  %11 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 2048, ptr noundef %5)
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.1, i32 noundef 404, ptr noundef nonnull @__FUNCTION__.mHelp, ptr noundef nonnull @.str.5) #5
  br label %14

14:                                               ; preds = %13, %10
  %15 = load i8, ptr %3, align 16, !tbaa !5
  %16 = icmp eq i8 %15, 91
  br i1 %16, label %17, label %22

17:                                               ; preds = %14
  %18 = call i64 @strspn(ptr noundef nonnull %9, ptr noundef %1) #6
  %.not16 = icmp ult i64 %18, %4
  br i1 %.not16, label %22, label %19

19:                                               ; preds = %17
  %20 = load i8, ptr %7, align 1, !tbaa !5
  %21 = icmp eq i8 %20, 93
  br i1 %21, label %._crit_edge, label %22

22:                                               ; preds = %17, %19, %14
  %23 = call i32 @feof(ptr noundef %5) #5
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %10, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %19, %22, %2
  %24 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 2048, ptr noundef %5)
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %._crit_edge
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.1, i32 noundef 412, ptr noundef nonnull @__FUNCTION__.mHelp, ptr noundef nonnull @.str.5) #5
  br label %27

27:                                               ; preds = %26, %._crit_edge
  %28 = load i8, ptr %3, align 16, !tbaa !5
  %.not1721 = icmp eq i8 %28, 91
  br i1 %.not1721, label %.critedge, label %.lr.ph23

.lr.ph23:                                         ; preds = %27, %35
  %29 = call i32 @feof(ptr noundef %5) #5
  %.not18 = icmp eq i32 %29, 0
  br i1 %.not18, label %30, label %.critedge

30:                                               ; preds = %.lr.ph23
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef nonnull %3)
  %32 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 2048, ptr noundef %5)
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str.1, i32 noundef 416, ptr noundef nonnull @__FUNCTION__.mHelp, ptr noundef nonnull @.str.5) #5
  br label %35

35:                                               ; preds = %34, %30
  %36 = load i8, ptr %3, align 16, !tbaa !5
  %.not17 = icmp eq i8 %36, 91
  br i1 %.not17, label %.critedge, label %.lr.ph23, !llvm.loop !10

.critedge:                                        ; preds = %.lr.ph23, %35, %27
  %37 = call i32 @fclose(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %3) #5
  ret void
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 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 #4 = { nofree 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 willreturn memory(read) }

!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"}
!10 = distinct !{!10, !9}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass