; LLVM IR from MQCPack/mqcPack :: examples/tools (Check)

; 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.22 = external hidden unnamed_addr constant [2 x i8], align 1
@Tab = external dso_local global [8 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [2 x i8], align 1
@CarriageReturn = external dso_local global [8 x i8], align 1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @mqc_Remove_Init_WhiteSpace(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %3

3:                                                ; preds = %15, %1
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 0
  %6 = call i32 @strncmp(ptr noundef %5, ptr noundef @.str.22, i64 noundef 1) #3
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %13, label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 0
  %11 = call i32 @strncmp(ptr noundef %10, ptr noundef @Tab, i64 noundef 1) #3
  %12 = icmp eq i32 %11, 0
  br label %13

13:                                               ; preds = %8, %3
  %14 = phi i1 [ true, %3 ], [ %12, %8 ]
  br i1 %14, label %15, label %20

15:                                               ; preds = %13
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 1
  %19 = call ptr @strcpy(ptr noundef %16, ptr noundef %18) #4
  br label %3, !llvm.loop !9

20:                                               ; preds = %13
  br label %21

21:                                               ; preds = %26, %20
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 0
  %24 = call i32 @strncmp(ptr noundef %23, ptr noundef @.str.43, i64 noundef 1) #3
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %21
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 1
  %30 = call ptr @strcpy(ptr noundef %27, ptr noundef %29) #4
  br label %21, !llvm.loop !11

31:                                               ; preds = %21
  br label %32

32:                                               ; preds = %36, %31
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = call i32 @strncmp(ptr noundef %33, ptr noundef @CarriageReturn, i64 noundef 1) #3
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %41

36:                                               ; preds = %32
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i64 1
  %40 = call ptr @strcpy(ptr noundef %37, ptr noundef %39) #4
  br label %32, !llvm.loop !12

41:                                               ; preds = %32
  ret void
}

attributes #0 = { 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 #1 = { 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 #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 willreturn memory(read) }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; 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.22 = external hidden unnamed_addr constant [2 x i8], align 1
@Tab = external dso_local local_unnamed_addr global [8 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [2 x i8], align 1
@CarriageReturn = external dso_local local_unnamed_addr global [8 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @mqc_Remove_Init_WhiteSpace(ptr noundef %0) local_unnamed_addr #1 {
  %rhsc = load i8, ptr @.str.22, align 1
  %lhsc17 = load i8, ptr %0, align 1
  %2 = icmp eq i8 %lhsc17, %rhsc
  %rhsc1118 = load i8, ptr @Tab, align 1
  %3 = icmp eq i8 %lhsc17, %rhsc1118
  %or.cond19 = select i1 %2, i1 true, i1 %3
  br i1 %or.cond19, label %.critedge.lr.ph, label %.preheader16

.critedge.lr.ph:                                  ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 1
  br label %.critedge

.preheader16:                                     ; preds = %.critedge, %1
  %lhsc1220 = phi i8 [ %lhsc17, %1 ], [ %lhsc, %.critedge ]
  %rhsc13 = load i8, ptr @.str.43, align 1
  %5 = icmp eq i8 %lhsc1220, %rhsc13
  br i1 %5, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %.preheader16
  %6 = getelementptr inbounds i8, ptr %0, i64 1
  br label %12

.critedge:                                        ; preds = %.critedge.lr.ph, %.critedge
  %7 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %4) #2
  %lhsc = load i8, ptr %0, align 1
  %8 = icmp eq i8 %lhsc, %rhsc
  %rhsc11 = load i8, ptr @Tab, align 1
  %9 = icmp eq i8 %lhsc, %rhsc11
  %or.cond = select i1 %8, i1 true, i1 %9
  br i1 %or.cond, label %.critedge, label %.preheader16, !llvm.loop !5

.preheader:                                       ; preds = %12, %.preheader16
  %lhsc1421 = phi i8 [ %lhsc1220, %.preheader16 ], [ %lhsc12, %12 ]
  %rhsc1522 = load i8, ptr @CarriageReturn, align 1
  %10 = icmp eq i8 %lhsc1421, %rhsc1522
  br i1 %10, label %.lr.ph23, label %._crit_edge

.lr.ph23:                                         ; preds = %.preheader
  %11 = getelementptr inbounds i8, ptr %0, i64 1
  br label %15

12:                                               ; preds = %.lr.ph, %12
  %13 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %6) #2
  %lhsc12 = load i8, ptr %0, align 1
  %14 = icmp eq i8 %lhsc12, %lhsc1220
  br i1 %14, label %12, label %.preheader, !llvm.loop !7

15:                                               ; preds = %.lr.ph23, %15
  %16 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %11) #2
  %lhsc14 = load i8, ptr %0, align 1
  %rhsc15 = load i8, ptr @CarriageReturn, align 1
  %17 = icmp eq i8 %lhsc14, %rhsc15
  br i1 %17, label %15, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %15, %.preheader
  ret void
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { nofree nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


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