; LLVM IR from stivalaa/EstimNetDirected :: src (EstimNetDirectedMain)

; 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.estim_config_s = type { double, double, double, i32, i32, i32, i32, i32, i32, i32, double, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, double, double, i32, ptr, i32, ptr, i32, i32, i32, i32, %struct.param_config_s }
%struct.param_config_s = type { i32, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr }
%struct.config_param_s = type { ptr, i32, i64, ptr }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@ESTIM_CONFIG = external global %struct.estim_config_s, align 8
@ESTIM_CONFIG_PARAMS = external constant [0 x %struct.config_param_s], align 8
@NUM_ESTIM_CONFIG_PARAMS = external constant i32, align 4
@optind = external global i32, align 4
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [37 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 i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = 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 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store ptr null, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @init_prng(i32 noundef 0)
  call void @init_estim_config_parser()
  br label %10

10:                                               ; preds = %23, %2
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = call i32 @getopt(i32 noundef %11, ptr noundef %12, ptr noundef @.str) #5
  store i32 %13, ptr %6, align 4, !tbaa !5
  %14 = icmp ne i32 %13, -1
  br i1 %14, label %15, label %24

15:                                               ; preds = %10
  %16 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %16, label %19 [
    i32 104, label %17
  ]

17:                                               ; preds = %15
  %18 = load i32, ptr @NUM_ESTIM_CONFIG_PARAMS, align 4, !tbaa !5
  call void @dump_config_names(ptr noundef @ESTIM_CONFIG, ptr noundef @ESTIM_CONFIG_PARAMS, i32 noundef %18)
  call void @dump_parameter_names()
  call void @exit(i32 noundef 0) #6
  unreachable

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds ptr, ptr %20, i64 0
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  call void @usage(ptr noundef %22)
  br label %23

23:                                               ; preds = %19
  br label %10, !llvm.loop !11

24:                                               ; preds = %10
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = load i32, ptr @optind, align 4, !tbaa !5
  %27 = sub nsw i32 %25, %26
  %28 = icmp ne i32 %27, 1
  br i1 %28, label %29, label %33

29:                                               ; preds = %24
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %30, i64 0
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  call void @usage(ptr noundef %32)
  br label %33

33:                                               ; preds = %29, %24
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = load i32, ptr @optind, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  store ptr %38, ptr %7, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = call ptr @parse_estim_config_file(ptr noundef %39)
  store ptr %40, ptr %8, align 8, !tbaa !9
  %41 = icmp ne ptr %40, null
  br i1 %41, label %46, label %42

42:                                               ; preds = %33
  %43 = load ptr, ptr @stderr, align 8, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.1, ptr noundef %44) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %49

46:                                               ; preds = %33
  %47 = load ptr, ptr %8, align 8, !tbaa !9
  %48 = call i32 @do_estimation(ptr noundef %47, i32 noundef 0)
  store i32 %48, ptr %9, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %46, %42
  %50 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free_estim_config_struct(ptr noundef %50)
  %51 = load i32, ptr %9, align 4, !tbaa !5
  call void @exit(i32 noundef %51) #6
  unreachable
}

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

declare void @init_prng(i32 noundef) #2

declare void @init_estim_config_parser() #2

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

declare void @dump_config_names(ptr noundef, ptr noundef, i32 noundef) #2

declare void @dump_parameter_names() #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @usage(ptr noundef) #0

declare ptr @parse_estim_config_file(ptr noundef) #2

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

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

declare void @free_estim_config_struct(ptr noundef) #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 = { noreturn 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 = { nounwind }
attributes #6 = { noreturn 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"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"

%struct.estim_config_s = type { double, double, double, i32, i32, i32, i32, i32, i32, i32, double, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, double, double, i32, ptr, i32, ptr, i32, i32, i32, i32, %struct.param_config_s }
%struct.param_config_s = type { i32, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr }
%struct.config_param_s = type { ptr, i32, i64, ptr }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@ESTIM_CONFIG = external global %struct.estim_config_s, align 8
@ESTIM_CONFIG_PARAMS = external constant [0 x %struct.config_param_s], align 8
@NUM_ESTIM_CONFIG_PARAMS = external local_unnamed_addr constant i32, align 4
@optind = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [37 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @init_prng(i32 noundef 0) #6
  tail call void @init_estim_config_parser() #6
  br label %3

3:                                                ; preds = %7, %2
  %4 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str) #6
  switch i32 %4, label %7 [
    i32 -1, label %9
    i32 104, label %5
  ]

5:                                                ; preds = %3
  %6 = load i32, ptr @NUM_ESTIM_CONFIG_PARAMS, align 4, !tbaa !5
  tail call void @dump_config_names(ptr noundef nonnull @ESTIM_CONFIG, ptr noundef nonnull @ESTIM_CONFIG_PARAMS, i32 noundef %6) #6
  tail call void @dump_parameter_names() #6
  tail call void @exit(i32 noundef 0) #7
  unreachable

7:                                                ; preds = %3
  %8 = load ptr, ptr %1, align 8, !tbaa !9
  tail call void @usage(ptr noundef %8)
  br label %3, !llvm.loop !11

9:                                                ; preds = %3
  %10 = load i32, ptr @optind, align 4, !tbaa !5
  %11 = sub nsw i32 %0, %10
  %.not13 = icmp eq i32 %11, 1
  br i1 %.not13, label %14, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr %1, align 8, !tbaa !9
  tail call void @usage(ptr noundef %13)
  %.pre = load i32, ptr @optind, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %12, %9
  %15 = phi i32 [ %.pre, %12 ], [ %10, %9 ]
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds ptr, ptr %1, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = tail call ptr @parse_estim_config_file(ptr noundef %18) #6
  %.not14 = icmp eq ptr %19, null
  br i1 %.not14, label %20, label %23

20:                                               ; preds = %14
  %21 = load ptr, ptr @stderr, align 8, !tbaa !9
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.1, ptr noundef %18) #8
  br label %25

23:                                               ; preds = %14
  %24 = tail call i32 @do_estimation(ptr noundef nonnull %19, i32 noundef 0) #6
  br label %25

25:                                               ; preds = %23, %20
  %.0 = phi i32 [ %24, %23 ], [ 1, %20 ]
  tail call void @free_estim_config_struct(ptr noundef %19) #6
  tail call void @exit(i32 noundef %.0) #7
  unreachable
}

declare void @init_prng(i32 noundef) local_unnamed_addr #1

declare void @init_estim_config_parser() local_unnamed_addr #1

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

declare void @dump_config_names(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @dump_parameter_names() local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @usage(ptr noundef) local_unnamed_addr #4

declare ptr @parse_estim_config_file(ptr noundef) local_unnamed_addr #1

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

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

declare void @free_estim_config_struct(ptr noundef) local_unnamed_addr #1

attributes #0 = { noreturn 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 = { 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 = { noreturn 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 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass