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

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

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

declare void @extract_path(ptr noundef, ptr noundef) #3

declare void @remove_ext(ptr noundef) #3

declare void @remove_path(ptr noundef) #3

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

declare i32 @system(ptr noundef) #3

; 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 void @write_out_fpocket_DB(ptr noundef %0, ptr noundef %1, ptr noundef %2) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [350 x i8], align 16
  %8 = alloca [350 x i8], align 16
  %9 = alloca [350 x i8], align 16
  %10 = alloca [350 x i8], align 16
  %11 = alloca [370 x i8], align 16
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 350, ptr %7) #6
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 350, ptr %8) #6
  call void @llvm.memset.p0.i64(ptr align 16 %8, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 350, ptr %9) #6
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 350, ptr %10) #6
  call void @llvm.memset.p0.i64(ptr align 16 %10, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 370, ptr %11) #6
  call void @llvm.memset.p0.i64(ptr align 16 %11, i8 0, i64 370, i1 false)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %47

15:                                               ; preds = %3
  %16 = getelementptr inbounds [350 x i8], ptr %7, i64 0, i64 0
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call ptr @strcpy(ptr noundef %16, ptr noundef %17) #6
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds [350 x i8], ptr %8, i64 0, i64 0
  call void @extract_path(ptr noundef %19, ptr noundef %20)
  %21 = getelementptr inbounds [350 x i8], ptr %7, i64 0, i64 0
  call void @remove_ext(ptr noundef %21)
  %22 = getelementptr inbounds [350 x i8], ptr %7, i64 0, i64 0
  call void @remove_path(ptr noundef %22)
  %23 = getelementptr inbounds [350 x i8], ptr %8, i64 0, i64 0
  %24 = call i64 @strlen(ptr noundef %23) #7
  %25 = icmp ugt i64 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %15
  %27 = getelementptr inbounds [350 x i8], ptr %9, i64 0, i64 0
  %28 = getelementptr inbounds [350 x i8], ptr %8, i64 0, i64 0
  %29 = getelementptr inbounds [350 x i8], ptr %7, i64 0, i64 0
  %30 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %27, ptr noundef @.str, ptr noundef %28, ptr noundef %29) #6
  br label %35

31:                                               ; preds = %15
  %32 = getelementptr inbounds [350 x i8], ptr %9, i64 0, i64 0
  %33 = getelementptr inbounds [350 x i8], ptr %7, i64 0, i64 0
  %34 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %32, ptr noundef @.str.1, ptr noundef %33) #6
  br label %35

35:                                               ; preds = %31, %26
  %36 = getelementptr inbounds [370 x i8], ptr %11, i64 0, i64 0
  %37 = getelementptr inbounds [350 x i8], ptr %9, i64 0, i64 0
  %38 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %36, ptr noundef @.str.2, ptr noundef %37) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %39 = getelementptr inbounds [370 x i8], ptr %11, i64 0, i64 0
  %40 = call i32 @system(ptr noundef %39)
  store i32 %40, ptr %12, align 4, !tbaa !9
  %41 = getelementptr inbounds [350 x i8], ptr %10, i64 0, i64 0
  %42 = getelementptr inbounds [350 x i8], ptr %9, i64 0, i64 0
  %43 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %41, ptr noundef @.str.4, ptr noundef %42) #6
  %44 = getelementptr inbounds [350 x i8], ptr %9, i64 0, i64 0
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  call void @write_each_pocket_for_DB(ptr noundef %44, ptr noundef %45, ptr noundef %46)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %47

47:                                               ; preds = %35, %3
  call void @llvm.lifetime.end.p0(i64 370, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 350, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 350, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 350, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 350, ptr %7) #6
  ret void
}

declare void @write_each_pocket_for_DB(ptr noundef, ptr noundef, ptr noundef) #3

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

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

declare void @extract_path(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @remove_ext(ptr noundef) local_unnamed_addr #3

declare void @remove_path(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

; 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 void @write_out_fpocket_DB(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #6 {
  %4 = alloca [350 x i8], align 16
  %5 = alloca [350 x i8], align 16
  %6 = alloca [350 x i8], align 16
  %7 = alloca [350 x i8], align 16
  %8 = alloca [370 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 350, ptr nonnull %4) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(350) %4, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 350, ptr nonnull %5) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(350) %5, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 350, ptr nonnull %6) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(350) %6, i8 0, i64 350, i1 false)
  call void @llvm.lifetime.start.p0(i64 350, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 370, ptr nonnull %8) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(370) %8, i8 0, i64 370, i1 false)
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %19, label %9

9:                                                ; preds = %3
  %10 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) %2) #7
  call void @extract_path(ptr noundef %2, ptr noundef nonnull %5) #7
  call void @remove_ext(ptr noundef nonnull %4) #7
  call void @remove_path(ptr noundef nonnull %4) #7
  %char0 = load i8, ptr %5, align 16
  %.not5 = icmp eq i8 %char0, 0
  br i1 %.not5, label %13, label %11

11:                                               ; preds = %9
  %12 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull %5, ptr noundef nonnull %4) #7
  br label %15

13:                                               ; preds = %9
  %14 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %4) #7
  br label %15

15:                                               ; preds = %13, %11
  %16 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull %6) #7
  %17 = call i32 @system(ptr noundef nonnull %8) #7
  %18 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %7, ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %6) #7
  call void @write_each_pocket_for_DB(ptr noundef nonnull %6, ptr noundef nonnull %0, ptr noundef %1) #7
  br label %19

19:                                               ; preds = %15, %3
  call void @llvm.lifetime.end.p0(i64 370, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 350, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 350, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 350, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 350, ptr nonnull %4) #7
  ret void
}

declare void @write_each_pocket_for_DB(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass