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

; 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_fparams = type { [2000 x i8], [2000 x i8], [2000 x i8], [8000 x i8], ptr, ptr, ptr, i32, i32, ptr, ptr, ptr, i8, i8, i32, i32, i16, i32, i32, i32, i16, i32, i32, i32, i16, float, float, float, float, float, [20 x ptr], i16, i16, [20 x ptr], i32, [10 x i8] }

@stdout = external global ptr, align 8
@.str = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [34 x i8], align 1

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

13:                                               ; preds = %2
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.s_fparams, ptr %14, i32 0, i32 16
  store i16 1, ptr %15, align 4, !tbaa !11
  %16 = load ptr, ptr %6, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.s_fparams, ptr %16, i32 0, i32 18
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %23, label %20

20:                                               ; preds = %13
  %21 = load ptr, ptr @stdout, align 8, !tbaa !9
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str) #5
  br label %23

23:                                               ; preds = %20, %13
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.s_fparams, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %75

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %71, %28
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.s_fparams, ptr %31, i32 0, i32 15
  %33 = load i32, ptr %32, align 8, !tbaa !17
  %34 = icmp slt i32 %30, %33
  br i1 %34, label %35, label %74

35:                                               ; preds = %29
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.s_fparams, ptr %37, i32 0, i32 15
  %39 = load i32, ptr %38, align 8, !tbaa !17
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.s_fparams, ptr %40, i32 0, i32 4
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds ptr, ptr %42, i64 %44
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %36, i32 noundef %39, ptr noundef %46)
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.s_fparams, ptr %49, i32 0, i32 15
  %51 = load i32, ptr %50, align 8, !tbaa !17
  %52 = sub nsw i32 %51, 1
  %53 = icmp eq i32 %48, %52
  br i1 %53, label %54, label %57

54:                                               ; preds = %35
  %55 = load ptr, ptr @stdout, align 8, !tbaa !9
  %56 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.2) #5
  br label %60

57:                                               ; preds = %35
  %58 = load ptr, ptr @stdout, align 8, !tbaa !9
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.3) #5
  br label %60

60:                                               ; preds = %57, %54
  %61 = load ptr, ptr @stdout, align 8, !tbaa !9
  %62 = call i32 @fflush(ptr noundef %61)
  %63 = load ptr, ptr %6, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.s_fparams, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = load ptr, ptr %6, align 8, !tbaa !9
  call void @process_pdb(ptr noundef %69, ptr noundef %70)
  br label %71

71:                                               ; preds = %60
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %7, align 4, !tbaa !5
  br label %29, !llvm.loop !18

74:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %97

75:                                               ; preds = %23
  %76 = load ptr, ptr %6, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.s_fparams, ptr %76, i32 0, i32 0
  %78 = getelementptr inbounds [2000 x i8], ptr %77, i64 0, i64 0
  %79 = load i8, ptr %78, align 8, !tbaa !20
  %80 = icmp ne i8 %79, 0
  br i1 %80, label %81, label %87

81:                                               ; preds = %75
  %82 = load ptr, ptr %6, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.s_fparams, ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds [2000 x i8], ptr %83, i64 0, i64 0
  %85 = call i64 @strlen(ptr noundef %84) #6
  %86 = icmp ule i64 %85, 0
  br i1 %86, label %87, label %91

87:                                               ; preds = %81, %75
  %88 = load ptr, ptr @stdout, align 8, !tbaa !9
  %89 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %88, ptr noundef @.str.4) #5
  %90 = load ptr, ptr @stdout, align 8, !tbaa !9
  call void @print_pocket_usage(ptr noundef %90)
  br label %96

91:                                               ; preds = %81
  %92 = load ptr, ptr %6, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct.s_fparams, ptr %92, i32 0, i32 0
  %94 = getelementptr inbounds [2000 x i8], ptr %93, i64 0, i64 0
  %95 = load ptr, ptr %6, align 8, !tbaa !9
  call void @process_pdb(ptr noundef %94, ptr noundef %95)
  br label %96

96:                                               ; preds = %91, %87
  br label %97

97:                                               ; preds = %96, %74
  %98 = load ptr, ptr %6, align 8, !tbaa !9
  %99 = getelementptr inbounds %struct.s_fparams, ptr %98, i32 0, i32 18
  %100 = load i32, ptr %99, align 4, !tbaa !15
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %105, label %102

102:                                              ; preds = %97
  %103 = load ptr, ptr @stdout, align 8, !tbaa !9
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef @.str.5) #5
  br label %105

105:                                              ; preds = %102, %97
  %106 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free_fparams(ptr noundef %106)
  br label %109

107:                                              ; preds = %2
  %108 = load ptr, ptr @stdout, align 8, !tbaa !9
  call void @print_pocket_usage(ptr noundef %108)
  br label %109

109:                                              ; preds = %107, %105
  call void @free_all()
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret i32 0
}

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

declare ptr @get_fpocket_args(i32 noundef, ptr noundef) #2

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

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

declare i32 @fflush(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @process_pdb(ptr noundef, ptr noundef) #0

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

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

declare void @print_pocket_usage(ptr noundef) #2

declare void @free_fparams(ptr noundef) #2

declare void @free_all() #2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = !{!"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 = !{!12, !13, i64 14068}
!12 = !{!"s_fparams", !7, i64 0, !7, i64 2000, !7, i64 4000, !7, i64 6000, !10, i64 14000, !10, i64 14008, !10, i64 14016, !6, i64 14024, !6, i64 14028, !10, i64 14032, !10, i64 14040, !10, i64 14048, !7, i64 14056, !7, i64 14057, !6, i64 14060, !6, i64 14064, !13, i64 14068, !6, i64 14072, !6, i64 14076, !6, i64 14080, !13, i64 14084, !6, i64 14088, !6, i64 14092, !6, i64 14096, !13, i64 14100, !14, i64 14104, !14, i64 14108, !14, i64 14112, !14, i64 14116, !14, i64 14120, !7, i64 14128, !13, i64 14288, !13, i64 14290, !7, i64 14296, !6, i64 14456, !7, i64 14460}
!13 = !{!"short", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !6, i64 14076}
!16 = !{!12, !10, i64 14000}
!17 = !{!12, !6, i64 14064}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!7, !7, i64 0}


; 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 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr @get_fpocket_args(i32 noundef %0, ptr noundef %1) #3
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %49, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %3, i64 14068
  store i16 1, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 14076
  %7 = load i32, ptr %6, align 4, !tbaa !13
  %.not25 = icmp eq i32 %7, 0
  br i1 %.not25, label %8, label %11

8:                                                ; preds = %4
  %9 = load ptr, ptr @stdout, align 8, !tbaa !14
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str) #3
  br label %11

11:                                               ; preds = %8, %4
  %12 = getelementptr inbounds i8, ptr %3, i64 14000
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %.not26 = icmp eq ptr %13, null
  br i1 %.not26, label %37, label %.preheader

.preheader:                                       ; preds = %11
  %14 = getelementptr inbounds i8, ptr %3, i64 14064
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %17 = phi i32 [ %34, %.lr.ph ], [ %15, %.preheader ]
  %18 = load ptr, ptr %12, align 8, !tbaa !15
  %19 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = trunc nuw nsw i64 %indvars.iv to i32
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %21, i32 noundef %17, ptr noundef %20)
  %23 = load i32, ptr %14, align 8, !tbaa !16
  %24 = add nsw i32 %23, -1
  %25 = zext i32 %24 to i64
  %26 = icmp eq i64 %indvars.iv, %25
  %27 = load ptr, ptr @stdout, align 8, !tbaa !14
  %.str.2..str.3 = select i1 %26, ptr @.str.2, ptr @.str.3
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull %.str.2..str.3) #3
  %29 = load ptr, ptr @stdout, align 8, !tbaa !14
  %30 = tail call i32 @fflush(ptr noundef %29)
  %31 = load ptr, ptr %12, align 8, !tbaa !15
  %32 = getelementptr inbounds ptr, ptr %31, i64 %indvars.iv
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  tail call void @process_pdb(ptr noundef %33, ptr noundef nonnull %3)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i32, ptr %14, align 8, !tbaa !16
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %.lr.ph, label %.loopexit, !llvm.loop !17

37:                                               ; preds = %11
  %38 = load i8, ptr %3, align 8
  %.not27 = icmp eq i8 %38, 0
  br i1 %.not27, label %39, label %43

39:                                               ; preds = %37
  %40 = load ptr, ptr @stdout, align 8, !tbaa !14
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.4) #3
  %42 = load ptr, ptr @stdout, align 8, !tbaa !14
  tail call void @print_pocket_usage(ptr noundef %42) #3
  br label %.loopexit

43:                                               ; preds = %37
  tail call void @process_pdb(ptr noundef nonnull %3, ptr noundef nonnull %3)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %39, %43
  %44 = load i32, ptr %6, align 4, !tbaa !13
  %.not28 = icmp eq i32 %44, 0
  br i1 %.not28, label %45, label %48

45:                                               ; preds = %.loopexit
  %46 = load ptr, ptr @stdout, align 8, !tbaa !14
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef nonnull @.str.5) #3
  br label %48

48:                                               ; preds = %45, %.loopexit
  tail call void @free_fparams(ptr noundef nonnull %3) #3
  br label %51

49:                                               ; preds = %2
  %50 = load ptr, ptr @stdout, align 8, !tbaa !14
  tail call void @print_pocket_usage(ptr noundef %50) #3
  br label %51

51:                                               ; preds = %49, %48
  tail call void @free_all() #3
  ret i32 0
}

declare ptr @get_fpocket_args(i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @process_pdb(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @print_pocket_usage(ptr noundef) local_unnamed_addr #1

declare void @free_fparams(ptr noundef) local_unnamed_addr #1

declare void @free_all() 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 = { "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 = { 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 #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, !11, i64 14068}
!6 = !{!"s_fparams", !7, i64 0, !7, i64 2000, !7, i64 4000, !7, i64 6000, !9, i64 14000, !9, i64 14008, !9, i64 14016, !10, i64 14024, !10, i64 14028, !9, i64 14032, !9, i64 14040, !9, i64 14048, !7, i64 14056, !7, i64 14057, !10, i64 14060, !10, i64 14064, !11, i64 14068, !10, i64 14072, !10, i64 14076, !10, i64 14080, !11, i64 14084, !10, i64 14088, !10, i64 14092, !10, i64 14096, !11, i64 14100, !12, i64 14104, !12, i64 14108, !12, i64 14112, !12, i64 14116, !12, i64 14120, !7, i64 14128, !11, i64 14288, !11, i64 14290, !7, i64 14296, !10, i64 14456, !7, i64 14460}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!6, !10, i64 14076}
!14 = !{!9, !9, i64 0}
!15 = !{!6, !9, i64 14000}
!16 = !{!6, !10, i64 14064}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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