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

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

@sflag = external dso_local global i32, align 4
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@lineno = external dso_local global i64, align 8
@nfiles = external dso_local global i64, align 8
@maxfiles = external dso_local global i64, align 8
@reps = external dso_local global i64, align 8
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@currfile = external dso_local global [4096 x i8], align 16
@.str.28 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [18 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(none)
declare ptr @__errno_location() #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @do_lineno(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %8 = call ptr @__errno_location() #7
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i64 @strtol(ptr noundef %9, ptr noundef %5, i32 noundef 10) #6
  store i64 %10, ptr %4, align 8, !tbaa !11
  %11 = load i64, ptr %4, align 8, !tbaa !11
  %12 = icmp sle i64 %11, 0
  br i1 %12, label %22, label %13

13:                                               ; preds = %1
  %14 = call ptr @__errno_location() #7
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %22, label %17

17:                                               ; preds = %13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load i8, ptr %18, align 1, !tbaa !13
  %20 = sext i8 %19 to i32
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %17, %13, %1
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.28, ptr noundef %23) #8
  unreachable

24:                                               ; preds = %17
  %25 = load i64, ptr %4, align 8, !tbaa !11
  store i64 %25, ptr %3, align 8, !tbaa !11
  %26 = load i64, ptr %3, align 8, !tbaa !11
  %27 = load i64, ptr @lineno, align 8, !tbaa !11
  %28 = icmp sle i64 %26, %27
  br i1 %28, label %29, label %31

29:                                               ; preds = %24
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.29, ptr noundef %30) #8
  unreachable

31:                                               ; preds = %24
  br label %32

32:                                               ; preds = %73, %31
  %33 = load i64, ptr @nfiles, align 8, !tbaa !11
  %34 = load i64, ptr @maxfiles, align 8, !tbaa !11
  %35 = sub nsw i64 %34, 1
  %36 = icmp slt i64 %33, %35
  br i1 %36, label %37, label %77

37:                                               ; preds = %32
  %38 = call ptr @newfile()
  store ptr %38, ptr %7, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %55, %37
  %40 = load i64, ptr @lineno, align 8, !tbaa !11
  %41 = add nsw i64 %40, 1
  %42 = load i64, ptr %3, align 8, !tbaa !11
  %43 = icmp ne i64 %41, %42
  br i1 %43, label %44, label %56

44:                                               ; preds = %39
  %45 = call ptr @csplit_getline()
  store ptr %45, ptr %6, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %49

47:                                               ; preds = %44
  %48 = load i64, ptr %3, align 8, !tbaa !11
  call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef @.str.30, i64 noundef %48) #8
  unreachable

49:                                               ; preds = %44
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = call i32 @fputs(ptr noundef %50, ptr noundef %51)
  %53 = icmp eq i32 %52, -1
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  br label %56

55:                                               ; preds = %49
  br label %39, !llvm.loop !14

56:                                               ; preds = %54, %39
  %57 = load i32, ptr @sflag, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %63, label %59

59:                                               ; preds = %56
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i64 @ftello(ptr noundef %60)
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i64 noundef %61)
  br label %63

63:                                               ; preds = %59, %56
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call i32 @fclose(ptr noundef %64)
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %63
  call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef @.str.11, ptr noundef @currfile) #8
  unreachable

68:                                               ; preds = %63
  %69 = load i64, ptr @reps, align 8, !tbaa !11
  %70 = add nsw i64 %69, -1
  store i64 %70, ptr @reps, align 8, !tbaa !11
  %71 = icmp eq i64 %69, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %68
  br label %77

73:                                               ; preds = %68
  %74 = load i64, ptr %4, align 8, !tbaa !11
  %75 = load i64, ptr %3, align 8, !tbaa !11
  %76 = add nsw i64 %75, %74
  store i64 %76, ptr %3, align 8, !tbaa !11
  br label %32, !llvm.loop !16

77:                                               ; preds = %72, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @newfile() #4

; Function Attrs: nounwind uwtable
declare dso_local ptr @csplit_getline() #4

declare i32 @fputs(ptr noundef, ptr noundef) #5

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

declare i64 @ftello(ptr noundef) #5

declare i32 @fclose(ptr noundef) #5

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

!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, !12, i64 0}
!12 = !{!"long", !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"

@sflag = external dso_local local_unnamed_addr global i32, align 4
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@lineno = external dso_local local_unnamed_addr global i64, align 8
@nfiles = external dso_local local_unnamed_addr global i64, align 8
@maxfiles = external dso_local local_unnamed_addr global i64, align 8
@reps = external dso_local local_unnamed_addr global i64, align 8
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@currfile = external dso_local global [4096 x i8], align 16
@.str.28 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [18 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 nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local void @do_lineno(ptr noundef %0) local_unnamed_addr #4 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %3 = tail call ptr @__errno_location() #7
  store i32 0, ptr %3, align 4, !tbaa !5
  %4 = call i64 @strtol(ptr noundef %0, ptr noundef nonnull %2, i32 noundef 10) #6
  %5 = icmp slt i64 %4, 1
  br i1 %5, label %11, label %6

6:                                                ; preds = %1
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %11

8:                                                ; preds = %6
  %9 = load ptr, ptr %2, align 8, !tbaa !9
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %.not15 = icmp eq i8 %10, 0
  br i1 %.not15, label %12, label %11

11:                                               ; preds = %8, %6, %1
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.28, ptr noundef %0) #8
  unreachable

12:                                               ; preds = %8
  %13 = load i64, ptr @lineno, align 8, !tbaa !12
  %.not16 = icmp sgt i64 %4, %13
  br i1 %.not16, label %.preheader, label %18

.preheader:                                       ; preds = %12
  %14 = load i64, ptr @nfiles, align 8, !tbaa !12
  %15 = load i64, ptr @maxfiles, align 8, !tbaa !12
  %16 = add nsw i64 %15, -1
  %17 = icmp slt i64 %14, %16
  br i1 %17, label %.lr.ph, label %._crit_edge

18:                                               ; preds = %12
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.29, ptr noundef %0) #8
  unreachable

.lr.ph:                                           ; preds = %.preheader, %42
  %.022 = phi i64 [ %43, %42 ], [ %4, %.preheader ]
  %19 = tail call ptr @newfile()
  br label %20

20:                                               ; preds = %27, %.lr.ph
  %21 = load i64, ptr @lineno, align 8, !tbaa !12
  %22 = add nsw i64 %21, 1
  %.not17 = icmp eq i64 %22, %.022
  br i1 %.not17, label %30, label %23

23:                                               ; preds = %20
  %24 = tail call ptr @csplit_getline()
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  tail call void (i32, ptr, ...) @errx(i32 noundef 1, ptr noundef nonnull @.str.30, i64 noundef %.022) #8
  unreachable

27:                                               ; preds = %23
  %28 = tail call i32 @fputs(ptr noundef nonnull %24, ptr noundef %19)
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %30, label %20, !llvm.loop !14

30:                                               ; preds = %27, %20
  %31 = load i32, ptr @sflag, align 4, !tbaa !5
  %.not18 = icmp eq i32 %31, 0
  br i1 %.not18, label %32, label %35

32:                                               ; preds = %30
  %33 = tail call i64 @ftello(ptr noundef %19)
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i64 noundef %33)
  br label %35

35:                                               ; preds = %32, %30
  %36 = tail call i32 @fclose(ptr noundef %19)
  %.not19 = icmp eq i32 %36, 0
  br i1 %.not19, label %38, label %37

37:                                               ; preds = %35
  tail call void (i32, ptr, ...) @err(i32 noundef 1, ptr noundef nonnull @.str.11, ptr noundef nonnull @currfile) #8
  unreachable

38:                                               ; preds = %35
  %39 = load i64, ptr @reps, align 8, !tbaa !12
  %40 = add nsw i64 %39, -1
  store i64 %40, ptr @reps, align 8, !tbaa !12
  %41 = icmp eq i64 %39, 0
  br i1 %41, label %._crit_edge, label %42

42:                                               ; preds = %38
  %43 = add nuw nsw i64 %.022, %4
  %44 = load i64, ptr @nfiles, align 8, !tbaa !12
  %45 = load i64, ptr @maxfiles, align 8, !tbaa !12
  %46 = add nsw i64 %45, -1
  %47 = icmp slt i64 %44, %46
  br i1 %47, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %42, %38, %.preheader
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @newfile() local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local ptr @csplit_getline() local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fputs(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #5

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

; Function Attrs: nofree nounwind
declare noundef i64 @ftello(ptr nocapture noundef) local_unnamed_addr #5

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 = { mustprogress nofree nounwind willreturn "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 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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