; LLVM IR from giusenso/Ball-Balancing-PID-System :: settings (file_handler)

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

; Function Attrs: nounwind uwtable
define dso_local void @arrayFromTextFile(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i16, align 2
  %9 = alloca [256 x i8], align 16
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca i16, align 2
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #8
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = trunc i32 %16 to i16
  store i16 %17, ptr %8, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 256, ptr %9) #8
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 256, i1 false)
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #8
  store i16 0, ptr %10, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #8
  store i16 0, ptr %11, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #8
  store i16 0, ptr %12, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #8
  store i16 0, ptr %13, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str)
  store ptr %19, ptr %14, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %24, %3
  %21 = load i16, ptr %8, align 2, !tbaa !11
  %22 = zext i16 %21 to i32
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %20
  %25 = load ptr, ptr %14, align 8, !tbaa !5
  %26 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %27 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %25, ptr noundef @.str.1, ptr noundef %26)
  store i32 %27, ptr %7, align 4, !tbaa !9
  %28 = load i16, ptr %8, align 2, !tbaa !11
  %29 = add i16 %28, -1
  store i16 %29, ptr %8, align 2, !tbaa !11
  br label %20, !llvm.loop !13

30:                                               ; preds = %20
  br label %31

31:                                               ; preds = %46, %30
  br label %32

32:                                               ; preds = %31
  %33 = load i16, ptr %13, align 2, !tbaa !11
  %34 = zext i16 %33 to i64
  %35 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !15
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %37, 91
  br i1 %38, label %39, label %46

39:                                               ; preds = %32
  %40 = load i16, ptr %8, align 2, !tbaa !11
  %41 = zext i16 %40 to i32
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %39
  %44 = load i16, ptr %13, align 2, !tbaa !11
  %45 = add i16 %44, 1
  store i16 %45, ptr %13, align 2, !tbaa !11
  br label %49

46:                                               ; preds = %39, %32
  %47 = load i16, ptr %13, align 2, !tbaa !11
  %48 = add i16 %47, 1
  store i16 %48, ptr %13, align 2, !tbaa !11
  br label %31

49:                                               ; preds = %43
  br label %50

50:                                               ; preds = %113, %49
  %51 = load i16, ptr %13, align 2, !tbaa !11
  %52 = zext i16 %51 to i32
  %53 = sub nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 %54
  %56 = load i8, ptr %55, align 1, !tbaa !15
  %57 = sext i8 %56 to i32
  %58 = icmp ne i32 %57, 93
  br i1 %58, label %59, label %116

59:                                               ; preds = %50
  %60 = load i16, ptr %13, align 2, !tbaa !11
  store i16 %60, ptr %10, align 2, !tbaa !11
  br label %61

61:                                               ; preds = %78, %59
  %62 = load i16, ptr %13, align 2, !tbaa !11
  %63 = zext i16 %62 to i64
  %64 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 %63
  %65 = load i8, ptr %64, align 1, !tbaa !15
  %66 = sext i8 %65 to i32
  %67 = icmp eq i32 %66, 44
  br i1 %67, label %75, label %68

68:                                               ; preds = %61
  %69 = load i16, ptr %13, align 2, !tbaa !11
  %70 = zext i16 %69 to i64
  %71 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 %70
  %72 = load i8, ptr %71, align 1, !tbaa !15
  %73 = sext i8 %72 to i32
  %74 = icmp eq i32 %73, 93
  br label %75

75:                                               ; preds = %68, %61
  %76 = phi i1 [ true, %61 ], [ %74, %68 ]
  %77 = xor i1 %76, true
  br i1 %77, label %78, label %81

78:                                               ; preds = %75
  %79 = load i16, ptr %13, align 2, !tbaa !11
  %80 = add i16 %79, 1
  store i16 %80, ptr %13, align 2, !tbaa !11
  br label %61, !llvm.loop !16

81:                                               ; preds = %75
  %82 = load i16, ptr %13, align 2, !tbaa !11
  store i16 %82, ptr %11, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %83 = load i16, ptr %11, align 2, !tbaa !11
  %84 = zext i16 %83 to i32
  %85 = load i16, ptr %10, align 2, !tbaa !11
  %86 = zext i16 %85 to i32
  %87 = sub nsw i32 %84, %86
  %88 = sext i32 %87 to i64
  %89 = mul i64 1, %88
  %90 = call noalias ptr @malloc(i64 noundef %89) #9
  store ptr %90, ptr %15, align 8, !tbaa !5
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  %92 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %93 = load i16, ptr %10, align 2, !tbaa !11
  %94 = zext i16 %93 to i32
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %92, i64 %95
  %97 = load i16, ptr %11, align 2, !tbaa !11
  %98 = zext i16 %97 to i32
  %99 = load i16, ptr %10, align 2, !tbaa !11
  %100 = zext i16 %99 to i32
  %101 = sub nsw i32 %98, %100
  %102 = sext i32 %101 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %91, ptr align 1 %96, i64 %102, i1 false)
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = call double @atof(ptr noundef %103) #10
  %105 = fptrunc double %104 to float
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load i16, ptr %12, align 2, !tbaa !11
  %108 = zext i16 %107 to i64
  %109 = getelementptr inbounds float, ptr %106, i64 %108
  store float %105, ptr %109, align 4, !tbaa !17
  %110 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %110) #8
  %111 = load i16, ptr %12, align 2, !tbaa !11
  %112 = add i16 %111, 1
  store i16 %112, ptr %12, align 2, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  br label %113

113:                                              ; preds = %81
  %114 = load i16, ptr %13, align 2, !tbaa !11
  %115 = add i16 %114, 1
  store i16 %115, ptr %13, align 2, !tbaa !11
  br label %50, !llvm.loop !19

116:                                              ; preds = %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 256, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare double @atof(ptr noundef nonnull) #6

; Function Attrs: nounwind
declare void @free(ptr noundef) #7

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { inlinehint nounwind willreturn memory(read) 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 "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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !14}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !14}


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

; Function Attrs: nounwind uwtable
define dso_local void @arrayFromTextFile(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca [256 x i8], align 16
  %5 = trunc i32 %2 to i16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %4) #9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(256) %4, i8 0, i64 256, i1 false)
  %6 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str)
  %.not34 = icmp eq i16 %5, 0
  br i1 %.not34, label %.preheader33.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.035 = phi i16 [ %8, %.lr.ph ], [ %5, %3 ]
  %7 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %6, ptr noundef nonnull @.str.1, ptr noundef nonnull %4) #9
  %8 = add i16 %.035, -1
  %.not = icmp eq i16 %8, 0
  br i1 %.not, label %.preheader33.preheader, label %.lr.ph, !llvm.loop !5

.preheader33.preheader:                           ; preds = %.lr.ph, %3
  br label %.preheader33

.preheader33:                                     ; preds = %.preheader33.preheader, %.preheader33
  %.028 = phi i16 [ %13, %.preheader33 ], [ 0, %.preheader33.preheader ]
  %9 = zext i16 %.028 to i64
  %10 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !7
  %12 = icmp eq i8 %11, 91
  %13 = add i16 %.028, 1
  br i1 %12, label %.preheader32, label %.preheader33

.preheader32:                                     ; preds = %.preheader33
  %14 = zext i16 %13 to i32
  %15 = add nsw i32 %14, -1
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !7
  %.not3137 = icmp eq i8 %18, 93
  br i1 %.not3137, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %.preheader32, %26
  %19 = phi i32 [ %38, %26 ], [ %14, %.preheader32 ]
  %.139 = phi i16 [ %.1, %26 ], [ %13, %.preheader32 ]
  %.02938 = phi i16 [ %37, %26 ], [ 0, %.preheader32 ]
  br label %20

20:                                               ; preds = %.preheader, %24
  %.2 = phi i16 [ %25, %24 ], [ %.139, %.preheader ]
  %21 = zext i16 %.2 to i64
  %22 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !7
  switch i8 %23, label %24 [
    i8 93, label %26
    i8 44, label %26
  ]

24:                                               ; preds = %20
  %25 = add i16 %.2, 1
  br label %20, !llvm.loop !10

26:                                               ; preds = %20, %20
  %27 = zext i16 %.2 to i32
  %28 = sub nsw i32 %27, %19
  %29 = sext i32 %28 to i64
  %30 = call noalias ptr @malloc(i64 noundef %29) #10
  %31 = zext i16 %.139 to i64
  %32 = getelementptr inbounds i8, ptr %4, i64 %31
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %30, ptr nonnull align 1 %32, i64 %29, i1 false)
  %33 = call double @atof(ptr noundef %30) #11
  %34 = fptrunc double %33 to float
  %35 = zext i16 %.02938 to i64
  %36 = getelementptr inbounds float, ptr %1, i64 %35
  store float %34, ptr %36, align 4, !tbaa !11
  call void @free(ptr noundef %30) #9
  %37 = add i16 %.02938, 1
  %.1 = add i16 %.2, 1
  %38 = zext i16 %.1 to i32
  %39 = add nsw i32 %38, -1
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !7
  %.not31 = icmp eq i8 %42, 93
  br i1 %.not31, label %._crit_edge, label %.preheader, !llvm.loop !13

._crit_edge:                                      ; preds = %26, %.preheader32
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %4) #9
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare double @atof(ptr nocapture noundef nonnull) local_unnamed_addr #7

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #8 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = distinct !{!10, !6}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = distinct !{!13, !6}


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