; LLVM IR from gost-engine/engine :: gostsum (get_line)

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

@stderr = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @get_line(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call i64 @fread(ptr noundef %10, i64 noundef 1, i64 noundef 64, ptr noundef %11)
  %13 = icmp ult i64 %12, 64
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %115

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 64
  store i8 0, ptr %17, align 1, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !10
  br label %18

18:                                               ; preds = %74, %15
  %19 = load i32, ptr %8, align 4, !tbaa !10
  %20 = icmp slt i32 %19, 64
  br i1 %20, label %21, label %77

21:                                               ; preds = %18
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !10
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = sext i8 %26 to i32
  %28 = icmp slt i32 %27, 48
  br i1 %28, label %69, label %29

29:                                               ; preds = %21
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !10
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %30, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = sext i8 %34 to i32
  %36 = icmp sgt i32 %35, 57
  br i1 %36, label %37, label %45

37:                                               ; preds = %29
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i32, ptr %8, align 4, !tbaa !10
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %38, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %43 = sext i8 %42 to i32
  %44 = icmp slt i32 %43, 65
  br i1 %44, label %69, label %45

45:                                               ; preds = %37, %29
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %8, align 4, !tbaa !10
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !9
  %51 = sext i8 %50 to i32
  %52 = icmp sgt i32 %51, 70
  br i1 %52, label %53, label %61

53:                                               ; preds = %45
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !10
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !9
  %59 = sext i8 %58 to i32
  %60 = icmp slt i32 %59, 97
  br i1 %60, label %69, label %61

61:                                               ; preds = %53, %45
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !10
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !9
  %67 = sext i8 %66 to i32
  %68 = icmp sgt i32 %67, 102
  br i1 %68, label %69, label %73

69:                                               ; preds = %61, %53, %37, %21
  %70 = load ptr, ptr @stderr, align 8, !tbaa !5
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str.13, ptr noundef %71) #5
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %115

73:                                               ; preds = %61
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %8, align 4, !tbaa !10
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %8, align 4, !tbaa !10
  br label %18, !llvm.loop !12

77:                                               ; preds = %18
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = call i32 @fgetc(ptr noundef %78)
  %80 = icmp ne i32 %79, 32
  br i1 %80, label %81, label %84

81:                                               ; preds = %77
  %82 = load ptr, ptr @stderr, align 8, !tbaa !5
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.14) #5
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %115

84:                                               ; preds = %77
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = call ptr @fgets(ptr noundef %85, i32 noundef 4096, ptr noundef %86)
  %88 = call i64 @strlen(ptr noundef %87) #6
  %89 = trunc i64 %88 to i32
  store i32 %89, ptr %8, align 4, !tbaa !10
  br label %90

90:                                               ; preds = %109, %84
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = load i32, ptr %8, align 4, !tbaa !10
  %93 = add nsw i32 %92, -1
  store i32 %93, ptr %8, align 4, !tbaa !10
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %91, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !9
  %97 = sext i8 %96 to i32
  %98 = icmp eq i32 %97, 10
  br i1 %98, label %107, label %99

99:                                               ; preds = %90
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  %101 = load i32, ptr %8, align 4, !tbaa !10
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  %104 = load i8, ptr %103, align 1, !tbaa !9
  %105 = sext i8 %104 to i32
  %106 = icmp eq i32 %105, 13
  br label %107

107:                                              ; preds = %99, %90
  %108 = phi i1 [ true, %90 ], [ %106, %99 ]
  br i1 %108, label %109, label %114

109:                                              ; preds = %107
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = load i32, ptr %8, align 4, !tbaa !10
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds i8, ptr %110, i64 %112
  store i8 0, ptr %113, align 1, !tbaa !9
  br label %90, !llvm.loop !14

114:                                              ; preds = %107
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %115

115:                                              ; preds = %114, %81, %69, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %116 = load i32, ptr %4, align 4
  ret i32 %116
}

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

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

declare i32 @fgetc(ptr noundef) #3

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

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #3

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


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @get_line(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = tail call i64 @fread(ptr noundef %1, i64 noundef 1, i64 noundef 64, ptr noundef %0)
  %5 = icmp ult i64 %4, 64
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 64
  store i8 0, ptr %7, align 1, !tbaa !5
  br label %17

8:                                                ; preds = %22
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv.next
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = icmp slt i8 %10, 48
  %12 = add nsw i8 %10, -58
  %or.cond.1 = icmp ult i8 %12, 7
  %or.cond33.1 = select i1 %11, i1 true, i1 %or.cond.1
  br i1 %or.cond33.1, label %25, label %13

13:                                               ; preds = %8
  %14 = add nsw i8 %10, -71
  %or.cond31.1 = icmp ult i8 %14, 26
  %15 = icmp ugt i8 %10, 102
  %or.cond32.1 = or i1 %15, %or.cond31.1
  br i1 %or.cond32.1, label %25, label %16

16:                                               ; preds = %13
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 64
  br i1 %exitcond.not.1, label %28, label %17, !llvm.loop !8

17:                                               ; preds = %16, %6
  %indvars.iv = phi i64 [ 0, %6 ], [ %indvars.iv.next.1, %16 ]
  %18 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp slt i8 %19, 48
  %21 = add nsw i8 %19, -58
  %or.cond = icmp ult i8 %21, 7
  %or.cond33 = select i1 %20, i1 true, i1 %or.cond
  br i1 %or.cond33, label %25, label %22

22:                                               ; preds = %17
  %23 = add nsw i8 %19, -71
  %or.cond31 = icmp ult i8 %23, 26
  %24 = icmp ugt i8 %19, 102
  %or.cond32 = or i1 %24, %or.cond31
  br i1 %or.cond32, label %25, label %8

25:                                               ; preds = %13, %8, %22, %17
  %26 = load ptr, ptr @stderr, align 8, !tbaa !10
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.13, ptr noundef nonnull %1) #3
  br label %.loopexit

28:                                               ; preds = %16
  %29 = tail call i32 @fgetc(ptr noundef %0)
  %.not = icmp eq i32 %29, 32
  br i1 %.not, label %33, label %30

30:                                               ; preds = %28
  %31 = load ptr, ptr @stderr, align 8, !tbaa !10
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.14) #3
  br label %.loopexit

33:                                               ; preds = %28
  %34 = tail call ptr @fgets(ptr noundef %2, i32 noundef 4096, ptr noundef %0)
  %35 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %34) #4
  %sext = shl i64 %35, 32
  %36 = ashr exact i64 %sext, 32
  br label %37

37:                                               ; preds = %.critedge, %33
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %.critedge ], [ %36, %33 ]
  %indvars.iv.next37 = add nsw i64 %indvars.iv36, -1
  %38 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv.next37
  %39 = load i8, ptr %38, align 1, !tbaa !5
  switch i8 %39, label %.loopexit [
    i8 10, label %.critedge
    i8 13, label %.critedge
  ]

.critedge:                                        ; preds = %37, %37
  store i8 0, ptr %38, align 1, !tbaa !5
  br label %37, !llvm.loop !12

.loopexit:                                        ; preds = %37, %3, %30, %25
  %.027 = phi i32 [ 0, %25 ], [ 0, %30 ], [ 0, %3 ], [ 1, %37 ]
  ret i32 %.027
}

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #0

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


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