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

@delim = external dso_local global ptr, align 8
@delimcnt = external dso_local global i32, align 4
@stdin = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = 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: nounwind uwtable
define dso_local i32 @sequential(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %83, %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %86

13:                                               ; preds = %9
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 0
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = icmp eq i32 %17, 45
  br i1 %18, label %19, label %26

19:                                               ; preds = %13
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 1
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = icmp ne i8 %22, 0
  br i1 %23, label %26, label %24

24:                                               ; preds = %19
  %25 = load ptr, ptr @stdin, align 8, !tbaa !5
  store ptr %25, ptr %3, align 8, !tbaa !5
  br label %33

26:                                               ; preds = %19, %13
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noalias ptr @fopen(ptr noundef %27, ptr noundef @.str.3)
  store ptr %28, ptr %3, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %32, label %30

30:                                               ; preds = %26
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ...) @warn(ptr noundef @.str.4, ptr noundef %31)
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %83

32:                                               ; preds = %26
  br label %33

33:                                               ; preds = %32, %24
  store i32 0, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %69, %33
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = call i32 @getwc(ptr noundef %35)
  store i32 %36, ptr %7, align 4, !tbaa !9
  %37 = icmp ne i32 %36, -1
  br i1 %37, label %38, label %70

38:                                               ; preds = %34
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %62

41:                                               ; preds = %38
  store i32 0, ptr %6, align 4, !tbaa !9
  %42 = load ptr, ptr @delim, align 8, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %55

48:                                               ; preds = %41
  %49 = load ptr, ptr @delim, align 8, !tbaa !5
  %50 = load i32, ptr %4, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %49, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = call i32 @putwchar(i32 noundef %53)
  br label %55

55:                                               ; preds = %48, %41
  %56 = load i32, ptr %4, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %4, align 4, !tbaa !9
  %58 = load i32, ptr @delimcnt, align 4, !tbaa !9
  %59 = icmp eq i32 %57, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %60, %55
  br label %62

62:                                               ; preds = %61, %38
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = icmp ne i32 %63, 10
  br i1 %64, label %65, label %68

65:                                               ; preds = %62
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = call i32 @putwchar(i32 noundef %66)
  br label %69

68:                                               ; preds = %62
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %68, %65
  br label %34, !llvm.loop !12

70:                                               ; preds = %34
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %75

73:                                               ; preds = %70
  %74 = call i32 @putwchar(i32 noundef 10)
  br label %75

75:                                               ; preds = %73, %70
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = load ptr, ptr @stdin, align 8, !tbaa !5
  %78 = icmp ne ptr %76, %77
  br i1 %78, label %79, label %82

79:                                               ; preds = %75
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call i32 @fclose(ptr noundef %80)
  br label %82

82:                                               ; preds = %79, %75
  br label %83

83:                                               ; preds = %82, %30
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds ptr, ptr %84, i32 1
  store ptr %85, ptr %2, align 8, !tbaa !5
  br label %9, !llvm.loop !14

86:                                               ; preds = %9
  %87 = load i32, ptr %5, align 4, !tbaa !9
  %88 = icmp ne i32 %87, 0
  %89 = zext i1 %88 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i32 %89
}

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

declare i32 @putwchar(i32 noundef) #2

declare i32 @getwc(ptr noundef) #2

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

declare void @warn(ptr noundef, ...) #2

declare i32 @fclose(ptr noundef) #2

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

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


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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @sequential(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %.not37 = icmp eq ptr %2, null
  br i1 %.not37, label %._crit_edge42, label %.lr.ph41

.lr.ph41:                                         ; preds = %1, %38
  %3 = phi ptr [ %40, %38 ], [ %2, %1 ]
  %.039 = phi ptr [ %39, %38 ], [ %0, %1 ]
  %.01838 = phi i32 [ %.119, %38 ], [ 0, %1 ]
  %4 = load i8, ptr %3, align 1, !tbaa !9
  %5 = icmp eq i8 %4, 45
  br i1 %5, label %6, label %11

6:                                                ; preds = %.lr.ph41
  %7 = getelementptr inbounds i8, ptr %3, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %.not26 = icmp eq i8 %8, 0
  br i1 %.not26, label %9, label %11

9:                                                ; preds = %6
  %10 = load ptr, ptr @stdin, align 8, !tbaa !5
  br label %14

11:                                               ; preds = %6, %.lr.ph41
  %12 = tail call noalias ptr @fopen(ptr noundef nonnull %3, ptr noundef nonnull @.str.3)
  %.not27 = icmp eq ptr %12, null
  br i1 %.not27, label %13, label %14

13:                                               ; preds = %11
  tail call void (ptr, ...) @warn(ptr noundef nonnull @.str.4, ptr noundef nonnull %3) #3
  br label %38

14:                                               ; preds = %11, %9
  %.016 = phi ptr [ %12, %11 ], [ %10, %9 ]
  %15 = tail call i32 @getwc(ptr noundef %.016) #3
  %.not2834 = icmp eq i32 %15, -1
  br i1 %.not2834, label %._crit_edge.thread, label %.lr.ph

.lr.ph:                                           ; preds = %14, %31
  %16 = phi i32 [ %32, %31 ], [ %15, %14 ]
  %.01736 = phi i32 [ %.2, %31 ], [ 0, %14 ]
  %.02035 = phi i32 [ %.121, %31 ], [ 0, %14 ]
  %.not31 = icmp eq i32 %.01736, 0
  br i1 %.not31, label %28, label %17

17:                                               ; preds = %.lr.ph
  %18 = load ptr, ptr @delim, align 8, !tbaa !5
  %19 = sext i32 %.02035 to i64
  %20 = getelementptr inbounds i32, ptr %18, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !10
  %.not32 = icmp eq i32 %21, 0
  br i1 %.not32, label %24, label %22

22:                                               ; preds = %17
  %23 = tail call i32 @putwchar(i32 noundef %21) #3
  br label %24

24:                                               ; preds = %22, %17
  %25 = add nsw i32 %.02035, 1
  %26 = load i32, ptr @delimcnt, align 4, !tbaa !10
  %27 = icmp eq i32 %25, %26
  %spec.store.select = select i1 %27, i32 0, i32 %25
  br label %28

28:                                               ; preds = %24, %.lr.ph
  %.121 = phi i32 [ %spec.store.select, %24 ], [ %.02035, %.lr.ph ]
  %.not33.not = icmp eq i32 %16, 10
  br i1 %.not33.not, label %31, label %29

29:                                               ; preds = %28
  %30 = tail call i32 @putwchar(i32 noundef %16) #3
  br label %31

31:                                               ; preds = %28, %29
  %.2 = phi i32 [ 0, %29 ], [ 1, %28 ]
  %32 = tail call i32 @getwc(ptr noundef %.016) #3
  %.not28 = icmp eq i32 %32, -1
  br i1 %.not28, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %31
  br i1 %.not33.not, label %33, label %._crit_edge.thread

33:                                               ; preds = %._crit_edge
  %34 = tail call i32 @putwchar(i32 noundef 10) #3
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %14, %33, %._crit_edge
  %35 = load ptr, ptr @stdin, align 8, !tbaa !5
  %.not30 = icmp eq ptr %.016, %35
  br i1 %.not30, label %38, label %36

36:                                               ; preds = %._crit_edge.thread
  %37 = tail call i32 @fclose(ptr noundef %.016)
  br label %38

38:                                               ; preds = %._crit_edge.thread, %36, %13
  %.119 = phi i32 [ %.01838, %36 ], [ %.01838, %._crit_edge.thread ], [ 1, %13 ]
  %39 = getelementptr inbounds i8, ptr %.039, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %.not = icmp eq ptr %40, null
  br i1 %.not, label %._crit_edge42.loopexit, label %.lr.ph41, !llvm.loop !14

._crit_edge42.loopexit:                           ; preds = %38
  %41 = icmp ne i32 %.119, 0
  %42 = zext i1 %41 to i32
  br label %._crit_edge42

._crit_edge42:                                    ; preds = %._crit_edge42.loopexit, %1
  %.018.lcssa = phi i32 [ 0, %1 ], [ %42, %._crit_edge42.loopexit ]
  ret i32 %.018.lcssa
}

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

declare i32 @putwchar(i32 noundef) local_unnamed_addr #2

declare i32 @getwc(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #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 = { 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 }

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


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