; LLVM IR from holzschu/ios_system :: text_cmds/paste (paste)

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

@tab = external dso_local global [2 x i32], align 4
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@optarg = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@delim = external dso_local global ptr, align 8
@delimcnt = external dso_local global i32, align 4
@optind = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %12 = call ptr @setlocale(i32 noundef 0, ptr noundef @.str) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %49, %2
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = call i32 @getopt(i32 noundef %14, ptr noundef %15, ptr noundef @.str.1) #6
  store i32 %16, ptr %6, align 4, !tbaa !5
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %18, label %50

18:                                               ; preds = %13
  %19 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %19, label %48 [
    i32 100, label %20
    i32 115, label %46
    i32 63, label %47
  ]

20:                                               ; preds = %18
  %21 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %21, ptr %10, align 8, !tbaa !9
  %22 = call i64 @mbsrtowcs(ptr noundef null, ptr noundef %10, i64 noundef 0, ptr noundef null) #6
  store i64 %22, ptr %11, align 8, !tbaa !11
  %23 = load i64, ptr %11, align 8, !tbaa !11
  %24 = icmp eq i64 %23, -1
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.2) #7
  unreachable

26:                                               ; preds = %20
  %27 = load i64, ptr %11, align 8, !tbaa !11
  %28 = add i64 %27, 1
  %29 = mul i64 %28, 4
  %30 = call noalias ptr @malloc(i64 noundef %29) #8
  store ptr %30, ptr %9, align 8, !tbaa !9
  %31 = load ptr, ptr %9, align 8, !tbaa !9
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %26
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef null) #7
  unreachable

34:                                               ; preds = %26
  %35 = load ptr, ptr @optarg, align 8, !tbaa !9
  store ptr %35, ptr %10, align 8, !tbaa !9
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  %37 = load i64, ptr %11, align 8, !tbaa !11
  %38 = add i64 %37, 1
  %39 = call i64 @mbsrtowcs(ptr noundef %36, ptr noundef %10, i64 noundef %38, ptr noundef null) #6
  store i64 %39, ptr %11, align 8, !tbaa !11
  %40 = load i64, ptr %11, align 8, !tbaa !11
  %41 = icmp eq i64 %40, -1
  br i1 %41, label %42, label %43

42:                                               ; preds = %34
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.2) #7
  unreachable

43:                                               ; preds = %34
  %44 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %44, ptr @delim, align 8, !tbaa !9
  %45 = call i32 @tr(ptr noundef %44)
  store i32 %45, ptr @delimcnt, align 4, !tbaa !5
  br label %49

46:                                               ; preds = %18
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %49

47:                                               ; preds = %18
  br label %48

48:                                               ; preds = %47, %18
  call void @usage()
  br label %49

49:                                               ; preds = %48, %46, %43
  br label %13, !llvm.loop !13

50:                                               ; preds = %13
  %51 = load i32, ptr @optind, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sub nsw i32 %52, %51
  store i32 %53, ptr %4, align 4, !tbaa !5
  %54 = load i32, ptr @optind, align 4, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = sext i32 %54 to i64
  %57 = getelementptr inbounds ptr, ptr %55, i64 %56
  store ptr %57, ptr %5, align 8, !tbaa !9
  %58 = load ptr, ptr %5, align 8, !tbaa !9
  %59 = load ptr, ptr %58, align 8, !tbaa !9
  %60 = icmp eq ptr %59, null
  br i1 %60, label %61, label %62

61:                                               ; preds = %50
  call void @usage()
  br label %62

62:                                               ; preds = %61, %50
  %63 = load ptr, ptr @delim, align 8, !tbaa !9
  %64 = icmp ne ptr %63, null
  br i1 %64, label %66, label %65

65:                                               ; preds = %62
  store i32 1, ptr @delimcnt, align 4, !tbaa !5
  store ptr @tab, ptr @delim, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %65, %62
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %72

69:                                               ; preds = %66
  %70 = load ptr, ptr %5, align 8, !tbaa !9
  %71 = call i32 @sequential(ptr noundef %70)
  store i32 %71, ptr %7, align 4, !tbaa !5
  br label %75

72:                                               ; preds = %66
  %73 = load ptr, ptr %5, align 8, !tbaa !9
  %74 = call i32 @parallel(ptr noundef %73)
  store i32 %74, ptr %7, align 4, !tbaa !5
  br label %75

75:                                               ; preds = %72, %69
  %76 = load i32, ptr %7, align 4, !tbaa !5
  call void @exit(i32 noundef %76) #9
  unreachable
}

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

; Function Attrs: nounwind
declare ptr @setlocale(i32 noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i64 @mbsrtowcs(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

; Function Attrs: noreturn
declare void @err(i32 noundef, ptr noundef, ...) #3

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @tr(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @usage() #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @sequential(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @parallel(ptr noundef) #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #5

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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { noreturn "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 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 #5 = { noreturn 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 #6 = { nounwind }
attributes #7 = { noreturn }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { noreturn 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@tab = external dso_local global [2 x i32], align 4
@.str = external hidden unnamed_addr constant [1 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@optarg = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@delim = external dso_local local_unnamed_addr global ptr, align 8
@delimcnt = external dso_local local_unnamed_addr global i32, align 4
@optind = external local_unnamed_addr global i32, align 4

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %4 = tail call ptr @setlocale(i32 noundef 0, ptr noundef nonnull @.str) #7
  br label %.outer

.outer:                                           ; preds = %5, %2
  %.not21 = phi i1 [ true, %2 ], [ false, %5 ]
  br label %5

5:                                                ; preds = %.backedge, %.outer
  %6 = call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.1) #7
  switch i32 %6, label %25 [
    i32 -1, label %26
    i32 100, label %7
    i32 115, label %.outer
  ], !llvm.loop !5

7:                                                ; preds = %5
  %8 = load ptr, ptr @optarg, align 8, !tbaa !7
  store ptr %8, ptr %3, align 8, !tbaa !7
  %9 = call i64 @mbsrtowcs(ptr noundef null, ptr noundef nonnull %3, i64 noundef 0, ptr noundef null) #7
  %10 = icmp eq i64 %9, -1
  br i1 %10, label %11, label %12

11:                                               ; preds = %7
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.2) #8
  unreachable

12:                                               ; preds = %7
  %13 = add nuw i64 %9, 1
  %14 = shl i64 %13, 2
  %15 = call noalias ptr @malloc(i64 noundef %14) #9
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %12
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef null) #8
  unreachable

18:                                               ; preds = %12
  %19 = load ptr, ptr @optarg, align 8, !tbaa !7
  store ptr %19, ptr %3, align 8, !tbaa !7
  %20 = call i64 @mbsrtowcs(ptr noundef nonnull %15, ptr noundef nonnull %3, i64 noundef %13, ptr noundef null) #7
  %21 = icmp eq i64 %20, -1
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.2) #8
  unreachable

23:                                               ; preds = %18
  store ptr %15, ptr @delim, align 8, !tbaa !7
  %24 = call i32 @tr(ptr noundef nonnull %15)
  store i32 %24, ptr @delimcnt, align 4, !tbaa !11
  br label %.backedge

25:                                               ; preds = %5
  call void @usage()
  br label %.backedge

.backedge:                                        ; preds = %25, %23
  br label %5, !llvm.loop !5

26:                                               ; preds = %5
  %27 = load i32, ptr @optind, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds ptr, ptr %1, i64 %28
  %30 = load ptr, ptr %29, align 8, !tbaa !7
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %26
  call void @usage()
  br label %33

33:                                               ; preds = %32, %26
  %34 = load ptr, ptr @delim, align 8, !tbaa !7
  %.not20 = icmp eq ptr %34, null
  br i1 %.not20, label %35, label %36

35:                                               ; preds = %33
  store i32 1, ptr @delimcnt, align 4, !tbaa !11
  store ptr @tab, ptr @delim, align 8, !tbaa !7
  br label %36

36:                                               ; preds = %35, %33
  br i1 %.not21, label %39, label %37

37:                                               ; preds = %36
  %38 = call i32 @sequential(ptr noundef nonnull %29)
  br label %41

39:                                               ; preds = %36
  %40 = call i32 @parallel(ptr noundef nonnull %29)
  br label %41

41:                                               ; preds = %39, %37
  %.016 = phi i32 [ %38, %37 ], [ %40, %39 ]
  call void @exit(i32 noundef %.016) #8
  unreachable
}

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

; Function Attrs: nounwind
declare ptr @setlocale(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i64 @mbsrtowcs(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: noreturn
declare void @err(i32 noundef, 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @tr(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden void @usage() local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @sequential(ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @parallel(ptr noundef) local_unnamed_addr #5

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #6

attributes #0 = { noreturn 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { noreturn "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 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 #6 = { noreturn 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass