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

%struct.InputLine = type { ptr, ptr, i32, i32, i32, ptr, ptr }

@Last_Keyword = external dso_local global ptr, align 8
@Last_NonBlank = external dso_local global ptr, align 8
@EndOfString = external dso_local global [8 x i8], align 1
@mqc_Alloc_InputLine.Blank_count = external hidden global i32, align 4
@.str.45 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [10 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
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

declare void @mqc_error_i_c2f_0(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mqc_FINDstrINline(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @mqc_DupString(ptr noundef, ptr noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local ptr @mqc_Alloc_InputLine(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca [2096 x i8], align 16
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2096, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store ptr null, ptr %8, align 8, !tbaa !5
  %9 = call noalias ptr @malloc(i64 noundef 176) #7
  store ptr %9, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %8, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %16

12:                                               ; preds = %3
  %13 = getelementptr inbounds [2096 x i8], ptr %7, i64 0, i64 0
  %14 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %13, ptr noundef @.str.45, ptr noundef @EndOfString) #6
  %15 = getelementptr inbounds [2096 x i8], ptr %7, i64 0, i64 0
  call void @mqc_error_i_c2f_0(ptr noundef %15, ptr noundef %6)
  br label %16

16:                                               ; preds = %12, %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.InputLine, ptr %20, i32 0, i32 1
  store ptr null, ptr %21, align 8, !tbaa !11
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.InputLine, ptr %22, i32 0, i32 0
  store ptr null, ptr %23, align 8, !tbaa !13
  br label %36

24:                                               ; preds = %16
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.InputLine, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.InputLine, ptr %28, i32 0, i32 0
  store ptr %27, ptr %29, align 8, !tbaa !13
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.InputLine, ptr %31, i32 0, i32 0
  store ptr %30, ptr %32, align 8, !tbaa !13
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.InputLine, ptr %34, i32 0, i32 1
  store ptr %33, ptr %35, align 8, !tbaa !11
  br label %36

36:                                               ; preds = %24, %19
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call ptr @mqc_DupString(ptr noundef %37, ptr noundef null)
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.InputLine, ptr %39, i32 0, i32 5
  store ptr %38, ptr %40, align 8, !tbaa !14
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  call void @mqc_Remove_Init_WhiteSpace(ptr noundef %41)
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = call ptr @mqc_DupString(ptr noundef %42, ptr noundef null)
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.InputLine, ptr %44, i32 0, i32 6
  store ptr %43, ptr %45, align 8, !tbaa !15
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.InputLine, ptr %46, i32 0, i32 6
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  call void @mqc_LOWER(ptr noundef %48)
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.InputLine, ptr %49, i32 0, i32 3
  store i32 0, ptr %50, align 4, !tbaa !16
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.InputLine, ptr %51, i32 0, i32 6
  %53 = load ptr, ptr %52, align 8, !tbaa !15
  %54 = call i64 @strlen(ptr noundef %53) #8
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %56, label %62

56:                                               ; preds = %36
  %57 = load i32, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !9
  %59 = load i32, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !9
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.InputLine, ptr %60, i32 0, i32 2
  store i32 %59, ptr %61, align 8, !tbaa !17
  br label %88

62:                                               ; preds = %36
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.InputLine, ptr %63, i32 0, i32 2
  store i32 0, ptr %64, align 8, !tbaa !17
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.InputLine, ptr %65, i32 0, i32 4
  store i32 0, ptr %66, align 8, !tbaa !18
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %67, ptr @Last_NonBlank, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.InputLine, ptr %68, i32 0, i32 6
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = call i32 @strncmp(ptr noundef %70, ptr noundef @.str.46, i64 noundef 1) #8
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %77

73:                                               ; preds = %62
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.InputLine, ptr %74, i32 0, i32 3
  store i32 1, ptr %75, align 4, !tbaa !16
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %76, ptr @Last_Keyword, align 8, !tbaa !5
  br label %87

77:                                               ; preds = %62
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.InputLine, ptr %78, i32 0, i32 6
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = call i32 @mqc_FINDstrINline(ptr noundef @.str.47, ptr noundef %80)
  %82 = icmp ne i32 %81, -1
  br i1 %82, label %83, label %86

83:                                               ; preds = %77
  store i32 0, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.InputLine, ptr %84, i32 0, i32 4
  store i32 1, ptr %85, align 8, !tbaa !18
  br label %86

86:                                               ; preds = %83, %77
  br label %87

87:                                               ; preds = %86, %73
  br label %88

88:                                               ; preds = %87, %56
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 2096, ptr %7) #6
  ret ptr %89
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_Remove_Init_WhiteSpace(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_LOWER(ptr noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 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 #5 = { nounwind allocsize(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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"InputLine", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !6, i64 32}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 16}
!18 = !{!12, !10, i64 24}


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

@Last_Keyword = external dso_local local_unnamed_addr global ptr, align 8
@Last_NonBlank = external dso_local local_unnamed_addr global ptr, align 8
@EndOfString = external dso_local global [8 x i8], align 1
@mqc_Alloc_InputLine.Blank_count = external hidden local_unnamed_addr global i32, align 4
@.str.45 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [10 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: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare void @mqc_error_i_c2f_0(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @mqc_FINDstrINline(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @mqc_DupString(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @mqc_Alloc_InputLine(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #3 {
  %4 = alloca i32, align 4
  %5 = alloca [2096 x i8], align 16
  store i32 %2, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2096, ptr nonnull %5) #5
  %6 = tail call noalias dereferenceable_or_null(176) ptr @malloc(i64 noundef 176) #6
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %3
  %9 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) @.str.45, ptr noundef nonnull @EndOfString) #5
  call void @mqc_error_i_c2f_0(ptr noundef nonnull %5, ptr noundef nonnull %4) #5
  br label %10

10:                                               ; preds = %8, %3
  %11 = icmp eq ptr %1, null
  br i1 %11, label %14, label %12

12:                                               ; preds = %10
  %13 = load ptr, ptr %1, align 8, !tbaa !9
  store ptr %6, ptr %1, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %10, %12
  %.sink = phi ptr [ %13, %12 ], [ null, %10 ]
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %1, ptr %15, align 8
  store ptr %.sink, ptr %6, align 8
  %16 = call ptr @mqc_DupString(ptr noundef %0, ptr noundef null)
  %17 = getelementptr inbounds i8, ptr %6, i64 32
  store ptr %16, ptr %17, align 8, !tbaa !12
  call void @mqc_Remove_Init_WhiteSpace(ptr noundef %0)
  %18 = call ptr @mqc_DupString(ptr noundef %0, ptr noundef null)
  %19 = getelementptr inbounds i8, ptr %6, i64 40
  store ptr %18, ptr %19, align 8, !tbaa !13
  call void @mqc_LOWER(ptr noundef %18)
  %20 = getelementptr inbounds i8, ptr %6, i64 20
  store i32 0, ptr %20, align 4, !tbaa !14
  %21 = load ptr, ptr %19, align 8, !tbaa !13
  %char0 = load i8, ptr %21, align 1
  %22 = icmp eq i8 %char0, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %14
  %24 = load i32, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 %25, ptr %26, align 8, !tbaa !15
  br label %35

27:                                               ; preds = %14
  %28 = getelementptr inbounds i8, ptr %6, i64 16
  store i32 0, ptr %28, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %6, i64 24
  store i32 0, ptr %29, align 8, !tbaa !16
  store ptr %6, ptr @Last_NonBlank, align 8, !tbaa !17
  %lhsc = load i8, ptr %21, align 1
  %rhsc = load i8, ptr @.str.46, align 1
  %30 = icmp eq i8 %lhsc, %rhsc
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  store i32 1, ptr %20, align 4, !tbaa !14
  store ptr %6, ptr @Last_Keyword, align 8, !tbaa !17
  br label %35

32:                                               ; preds = %27
  %33 = call i32 @mqc_FINDstrINline(ptr noundef nonnull @.str.47, ptr noundef nonnull %21)
  %.not = icmp eq i32 %33, -1
  br i1 %.not, label %35, label %34

34:                                               ; preds = %32
  store i32 0, ptr @mqc_Alloc_InputLine.Blank_count, align 4, !tbaa !5
  store i32 1, ptr %29, align 8, !tbaa !16
  br label %35

35:                                               ; preds = %31, %34, %32, %23
  call void @llvm.lifetime.end.p0(i64 2096, ptr nonnull %5) #5
  ret ptr %6
}

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_Remove_Init_WhiteSpace(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_LOWER(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }

!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, !11, i64 0}
!10 = !{!"InputLine", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 20, !6, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 32}
!13 = !{!10, !11, i64 40}
!14 = !{!10, !6, i64 20}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 24}
!17 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass