; LLVM IR from Discngine/fpocket :: src (tparams)

; 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.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 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 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @add_list_data(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [4006 x i8], align 16
  %9 = alloca [2000 x i8], align 16
  %10 = alloca [2000 x i8], align 16
  %11 = alloca [5 x i8], align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4006, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 2000, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 2000, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 5, ptr %11) #4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call noalias ptr @fopen(ptr noundef %12, ptr noundef @.str.7)
  store ptr %13, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %60

16:                                               ; preds = %2
  br label %17

17:                                               ; preds = %58, %16
  %18 = getelementptr inbounds [4006 x i8], ptr %8, i64 0, i64 0
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = call ptr @fgets(ptr noundef %18, i32 noundef 210, ptr noundef %19)
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %59

22:                                               ; preds = %17
  %23 = getelementptr inbounds [4006 x i8], ptr %8, i64 0, i64 0
  %24 = getelementptr inbounds [2000 x i8], ptr %9, i64 0, i64 0
  %25 = getelementptr inbounds [2000 x i8], ptr %10, i64 0, i64 0
  %26 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 0
  %27 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %23, ptr noundef @.str.8, ptr noundef %24, ptr noundef %25, ptr noundef %26) #4
  store i32 %27, ptr %7, align 4, !tbaa !9
  %28 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 0
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %30, 32
  br i1 %31, label %32, label %42

32:                                               ; preds = %22
  %33 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = sext i8 %34 to i32
  %36 = icmp eq i32 %35, 32
  br i1 %36, label %37, label %42

37:                                               ; preds = %32
  %38 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 2
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 0
  store i8 %39, ptr %40, align 1, !tbaa !11
  %41 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 1
  store i8 0, ptr %41, align 1, !tbaa !11
  br label %42

42:                                               ; preds = %37, %32, %22
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = icmp slt i32 %43, 3
  br i1 %44, label %45, label %50

45:                                               ; preds = %42
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = getelementptr inbounds [4006 x i8], ptr %8, i64 0, i64 0
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.9, ptr noundef %47, i32 noundef %48) #4
  br label %58

50:                                               ; preds = %42
  %51 = getelementptr inbounds [2000 x i8], ptr %9, i64 0, i64 0
  %52 = getelementptr inbounds [2000 x i8], ptr %10, i64 0, i64 0
  %53 = getelementptr inbounds [5 x i8], ptr %11, i64 0, i64 0
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = call i32 @add_prot(ptr noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %54)
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = add nsw i32 %56, %55
  store i32 %57, ptr %6, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %50, %45
  br label %17, !llvm.loop !12

59:                                               ; preds = %17
  br label %64

60:                                               ; preds = %2
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str.10, ptr noundef %62) #4
  br label %64

64:                                               ; preds = %60, %59
  %65 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 5, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 2000, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 2000, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4006, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret i32 %65
}

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

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

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

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(ptr noundef, ptr noundef, ...) #1

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 = { 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 }

!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"}


; 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.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 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 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @add_list_data(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [4006 x i8], align 16
  %4 = alloca [2000 x i8], align 16
  %5 = alloca [2000 x i8], align 16
  %6 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 4006, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 2000, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 2000, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %6) #3
  %7 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.7)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %29, label %.preheader

.preheader:                                       ; preds = %2
  %8 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 210, ptr noundef nonnull %7)
  %.not1213 = icmp eq ptr %8, null
  br i1 %.not1213, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %9 = getelementptr inbounds i8, ptr %6, i64 1
  %10 = getelementptr inbounds i8, ptr %6, i64 2
  br label %11

11:                                               ; preds = %.lr.ph, %27
  %.014 = phi i32 [ 0, %.lr.ph ], [ %.1, %27 ]
  %12 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %3, ptr noundef nonnull @.str.8, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6) #3
  %13 = load i8, ptr %6, align 1, !tbaa !5
  %14 = icmp eq i8 %13, 32
  %15 = load i8, ptr %9, align 1
  %16 = icmp eq i8 %15, 32
  %or.cond = select i1 %14, i1 %16, i1 false
  br i1 %or.cond, label %17, label %19

17:                                               ; preds = %11
  %18 = load i8, ptr %10, align 1, !tbaa !5
  store i8 %18, ptr %6, align 1, !tbaa !5
  store i8 0, ptr %9, align 1, !tbaa !5
  br label %19

19:                                               ; preds = %17, %11
  %20 = icmp slt i32 %12, 3
  br i1 %20, label %21, label %24

21:                                               ; preds = %19
  %22 = load ptr, ptr @stderr, align 8, !tbaa !8
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.9, ptr noundef nonnull %3, i32 noundef %12) #4
  br label %27

24:                                               ; preds = %19
  %25 = call i32 @add_prot(ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef %1)
  %26 = add nsw i32 %25, %.014
  br label %27

27:                                               ; preds = %24, %21
  %.1 = phi i32 [ %.014, %21 ], [ %26, %24 ]
  %28 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 210, ptr noundef nonnull %7)
  %.not12 = icmp eq ptr %28, null
  br i1 %.not12, label %.loopexit, label %11, !llvm.loop !10

29:                                               ; preds = %2
  %30 = load ptr, ptr @stderr, align 8, !tbaa !8
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.10, ptr noundef %0) #4
  br label %.loopexit

.loopexit:                                        ; preds = %27, %.preheader, %29
  %.2 = phi i32 [ 0, %29 ], [ 0, %.preheader ], [ %.1, %27 ]
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 2000, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 2000, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4006, ptr nonnull %3) #3
  ret i32 %.2
}

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

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

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

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

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


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