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

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

%struct.s_mdparams = type { ptr, [2000 x i8], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32, i32, [3 x float], float, i16, [3 x i16] }

@stdout = external global ptr, align 8
@.str.34 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external global ptr, align 8
@.str.36 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.38 = 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

declare ptr @my_malloc(i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @add_list_snapshots(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 i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [2000 x i8], align 16
  %11 = alloca [4006 x i8], align 16
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2000, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4006, ptr %11) #4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = call noalias ptr @fopen(ptr noundef %12, ptr noundef @.str.34)
  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 %82

16:                                               ; preds = %2
  br label %17

17:                                               ; preds = %39, %16
  %18 = getelementptr inbounds [2000 x i8], ptr %10, 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 %40

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

31:                                               ; preds = %22
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = getelementptr inbounds [2000 x i8], ptr %10, i64 0, i64 0
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.36, ptr noundef %33, i32 noundef %34) #4
  br label %39

36:                                               ; preds = %22
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %9, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %36, %31
  br label %17, !llvm.loop !15

40:                                               ; preds = %17
  %41 = load ptr, ptr @stdout, align 8, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.37, i32 noundef %42) #4
  %44 = load ptr, ptr @stdout, align 8, !tbaa !5
  %45 = call i32 @fflush(ptr noundef %44)
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %48, label %81

48:                                               ; preds = %40
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = mul i64 %50, 8
  %52 = call ptr @my_malloc(i64 noundef %51)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.s_mdparams, ptr %53, i32 0, i32 0
  store ptr %52, ptr %54, align 8, !tbaa !17
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call i32 @fseek(ptr noundef %55, i64 noundef 0, i32 noundef 0)
  br label %57

57:                                               ; preds = %79, %48
  %58 = getelementptr inbounds [2000 x i8], ptr %10, i64 0, i64 0
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call ptr @fgets(ptr noundef %58, i32 noundef 210, ptr noundef %59)
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %80

62:                                               ; preds = %57
  %63 = getelementptr inbounds [2000 x i8], ptr %10, i64 0, i64 0
  %64 = getelementptr inbounds [4006 x i8], ptr %11, i64 0, i64 0
  %65 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %63, ptr noundef @.str.35, ptr noundef %64) #4
  store i32 %65, ptr %8, align 4, !tbaa !9
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = icmp slt i32 %66, 1
  br i1 %67, label %68, label %73

68:                                               ; preds = %62
  %69 = load ptr, ptr @stderr, align 8, !tbaa !5
  %70 = getelementptr inbounds [2000 x i8], ptr %10, i64 0, i64 0
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.36, ptr noundef %70, i32 noundef %71) #4
  br label %79

73:                                               ; preds = %62
  %74 = getelementptr inbounds [4006 x i8], ptr %11, i64 0, i64 0
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = call i32 @add_snapshot(ptr noundef %74, ptr noundef %75)
  %77 = load i32, ptr %7, align 4, !tbaa !9
  %78 = add nsw i32 %77, %76
  store i32 %78, ptr %7, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %73, %68
  br label %57, !llvm.loop !18

80:                                               ; preds = %57
  br label %81

81:                                               ; preds = %80, %40
  br label %86

82:                                               ; preds = %2
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.38, ptr noundef %84) #4
  br label %86

86:                                               ; preds = %82, %81
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = call i32 @fclose(ptr noundef %87)
  %89 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4006, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 2000, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, 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 %89
}

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

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

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

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

declare i32 @fflush(ptr noundef) #1

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #1

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

declare i32 @fclose(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 "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 = !{!12, !10, i64 2128}
!12 = !{!"s_mdparams", !6, i64 0, !7, i64 8, !6, i64 2008, !6, i64 2016, !6, i64 2024, !6, i64 2032, !6, i64 2040, !6, i64 2048, !6, i64 2056, !6, i64 2064, !6, i64 2072, !6, i64 2080, !6, i64 2088, !6, i64 2096, !6, i64 2104, !6, i64 2112, !6, i64 2120, !10, i64 2128, !6, i64 2136, !10, i64 2144, !10, i64 2148, !7, i64 2152, !13, i64 2164, !14, i64 2168, !7, i64 2170}
!13 = !{!"float", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !6, i64 0}
!18 = distinct !{!18, !16}


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

@stdout = external local_unnamed_addr global ptr, align 8
@.str.34 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.36 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.38 = 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

declare ptr @my_malloc(i64 noundef) local_unnamed_addr #1

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

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

.preheader:                                       ; preds = %2
  %6 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 210, ptr noundef nonnull %5)
  %.not2325 = icmp eq ptr %6, null
  br i1 %.not2325, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %14
  %.026 = phi i32 [ %.1, %14 ], [ 0, %.preheader ]
  %7 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %3, ptr noundef nonnull @.str.35, ptr noundef nonnull %4) #4
  %8 = icmp slt i32 %7, 1
  br i1 %8, label %9, label %12

9:                                                ; preds = %.lr.ph
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.36, ptr noundef nonnull %3, i32 noundef %7) #5
  br label %14

12:                                               ; preds = %.lr.ph
  %13 = add nsw i32 %.026, 1
  br label %14

14:                                               ; preds = %12, %9
  %.1 = phi i32 [ %.026, %9 ], [ %13, %12 ]
  %15 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 210, ptr noundef nonnull %5)
  %.not23 = icmp eq ptr %15, null
  br i1 %.not23, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %14, %.preheader
  %.0.lcssa = phi i32 [ 0, %.preheader ], [ %.1, %14 ]
  %16 = load ptr, ptr @stdout, align 8, !tbaa !5
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.37, i32 noundef %.0.lcssa) #4
  %18 = load ptr, ptr @stdout, align 8, !tbaa !5
  %19 = call i32 @fflush(ptr noundef %18)
  %20 = icmp sgt i32 %.0.lcssa, 0
  br i1 %20, label %21, label %.loopexit

21:                                               ; preds = %._crit_edge
  %22 = zext nneg i32 %.0.lcssa to i64
  %23 = shl nuw nsw i64 %22, 3
  %24 = call ptr @my_malloc(i64 noundef %23) #4
  store ptr %24, ptr %1, align 8, !tbaa !11
  %25 = call i32 @fseek(ptr noundef nonnull %5, i64 noundef 0, i32 noundef 0)
  %26 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 210, ptr noundef nonnull %5)
  %.not2427 = icmp eq ptr %26, null
  br i1 %.not2427, label %.loopexit, label %.lr.ph30

.lr.ph30:                                         ; preds = %21, %35
  %.01928 = phi i32 [ %.120, %35 ], [ 0, %21 ]
  %27 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %3, ptr noundef nonnull @.str.35, ptr noundef nonnull %4) #4
  %28 = icmp slt i32 %27, 1
  br i1 %28, label %29, label %32

29:                                               ; preds = %.lr.ph30
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.36, ptr noundef nonnull %3, i32 noundef %27) #5
  br label %35

32:                                               ; preds = %.lr.ph30
  %33 = call i32 @add_snapshot(ptr noundef nonnull %4, ptr noundef nonnull %1)
  %34 = add nsw i32 %33, %.01928
  br label %35

35:                                               ; preds = %32, %29
  %.120 = phi i32 [ %.01928, %29 ], [ %34, %32 ]
  %36 = call ptr @fgets(ptr noundef nonnull %3, i32 noundef 210, ptr noundef nonnull %5)
  %.not24 = icmp eq ptr %36, null
  br i1 %.not24, label %.loopexit, label %.lr.ph30, !llvm.loop !16

37:                                               ; preds = %2
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str.38, ptr noundef %0) #5
  br label %.loopexit

.loopexit:                                        ; preds = %35, %21, %._crit_edge, %37
  %.2 = phi i32 [ 0, %._crit_edge ], [ 0, %37 ], [ 0, %21 ], [ %.120, %35 ]
  %40 = call i32 @fclose(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 4006, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 2000, ptr nonnull %3) #4
  ret i32 %.2
}

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

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

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !6, i64 0}
!12 = !{!"s_mdparams", !6, i64 0, !7, i64 8, !6, i64 2008, !6, i64 2016, !6, i64 2024, !6, i64 2032, !6, i64 2040, !6, i64 2048, !6, i64 2056, !6, i64 2064, !6, i64 2072, !6, i64 2080, !6, i64 2088, !6, i64 2096, !6, i64 2104, !6, i64 2112, !6, i64 2120, !13, i64 2128, !6, i64 2136, !13, i64 2144, !13, i64 2148, !7, i64 2152, !14, i64 2164, !15, i64 2168, !7, i64 2170}
!13 = !{!"int", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = distinct !{!16, !10}


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