; LLVM IR from sbu-fsl/kernel-ml :: examples (linear_regression)

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

%union.val = type { double }
%struct.linear_regression = type { i32, ptr, ptr, ptr, ptr, %struct.model_data, %struct.model_multithreading, %struct.model_state }
%struct.model_data = type { ptr, ptr, ptr, ptr }
%struct.model_multithreading = type { [32 x %struct.mt_buffer], [32 x i32], i32, i32, i32, i64, ptr }
%struct.mt_buffer = type { ptr, ptr }
%struct.model_state = type { i8, i32 }
%struct.matrix = type { i32, i32, i32, %union.anon }
%union.anon = type { ptr }

@__const.simulation.modula = external hidden unnamed_addr constant { float, [4 x i8] }, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@iter = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@num_samples = external hidden global i32, align 4
@.str.5 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [29 x i8], align 1
@timing_sum = external hidden global float, align 4

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local float @simulation(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca [20 x i8], align 16
  %6 = alloca [10 x i8], align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %union.val, align 8
  %13 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 20, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 10, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 1000, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 @__const.simulation.modula, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store float 0.000000e+00, ptr %13, align 4, !tbaa !11
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.linear_regression, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = getelementptr inbounds %union.val, ptr %12, i32 0, i32 0
  %18 = load i64, ptr %17, align 8
  call void @set_random_weights(ptr noundef %16, i64 %18)
  %19 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %19, ptr %3, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %208, %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds [20 x i8], ptr %5, i64 0, i64 0
  %23 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  %24 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %21, ptr noundef @.str.2, ptr noundef %22, ptr noundef %23, ptr noundef %7, ptr noundef %8, ptr noundef %9)
  %25 = icmp ne i32 %24, -1
  br i1 %25, label %26, label %209

26:                                               ; preds = %20
  %27 = load i32, ptr @iter, align 4, !tbaa !9
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.linear_regression, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !19
  %32 = sdiv i32 %28, %31
  %33 = icmp slt i32 %27, %32
  br i1 %33, label %34, label %38

34:                                               ; preds = %26
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.linear_regression, ptr %35, i32 0, i32 7
  %37 = getelementptr inbounds %struct.model_state, ptr %36, i32 0, i32 0
  store atomic i8 1, ptr %37 seq_cst, align 1, !tbaa !20
  br label %51

38:                                               ; preds = %26
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.linear_regression, ptr %39, i32 0, i32 7
  %41 = getelementptr inbounds %struct.model_state, ptr %40, i32 0, i32 0
  %42 = load atomic i8, ptr %41 seq_cst, align 1, !tbaa !20
  %43 = trunc i8 %42 to i1
  br i1 %43, label %44, label %47

44:                                               ; preds = %38
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.linear_regression, ptr %45, i32 0, i32 6
  call void @wait_for_draining_pipeline(ptr noundef %46)
  br label %47

47:                                               ; preds = %44, %38
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.linear_regression, ptr %48, i32 0, i32 7
  %50 = getelementptr inbounds %struct.model_state, ptr %49, i32 0, i32 0
  store atomic i8 0, ptr %50 seq_cst, align 1, !tbaa !20
  br label %51

51:                                               ; preds = %47, %34
  %52 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  %53 = call i32 @strcmp(ptr noundef %52, ptr noundef @.str.3) #7
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %73

55:                                               ; preds = %51
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.linear_regression, ptr %56, i32 0, i32 5
  %58 = getelementptr inbounds %struct.model_data, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = getelementptr inbounds %struct.matrix, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !22
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.linear_regression, ptr %63, i32 0, i32 5
  %65 = getelementptr inbounds %struct.model_data, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !21
  %67 = getelementptr inbounds %struct.matrix, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !23
  %69 = mul nsw i32 %62, %68
  %70 = add nsw i32 %69, 0
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %61, i64 %71
  store float 1.000000e+00, ptr %72, align 4, !tbaa !11
  br label %114

73:                                               ; preds = %51
  %74 = getelementptr inbounds [10 x i8], ptr %6, i64 0, i64 0
  %75 = call i32 @strcmp(ptr noundef %74, ptr noundef @.str.4) #7
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %95

77:                                               ; preds = %73
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.linear_regression, ptr %78, i32 0, i32 5
  %80 = getelementptr inbounds %struct.model_data, ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  %82 = getelementptr inbounds %struct.matrix, ptr %81, i32 0, i32 3
  %83 = load ptr, ptr %82, align 8, !tbaa !22
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.linear_regression, ptr %85, i32 0, i32 5
  %87 = getelementptr inbounds %struct.model_data, ptr %86, i32 0, i32 2
  %88 = load ptr, ptr %87, align 8, !tbaa !21
  %89 = getelementptr inbounds %struct.matrix, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !23
  %91 = mul nsw i32 %84, %90
  %92 = add nsw i32 %91, 0
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds float, ptr %83, i64 %93
  store float 1.000000e+00, ptr %94, align 4, !tbaa !11
  br label %113

95:                                               ; preds = %73
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.linear_regression, ptr %96, i32 0, i32 5
  %98 = getelementptr inbounds %struct.model_data, ptr %97, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !21
  %100 = getelementptr inbounds %struct.matrix, ptr %99, i32 0, i32 3
  %101 = load ptr, ptr %100, align 8, !tbaa !22
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.linear_regression, ptr %103, i32 0, i32 5
  %105 = getelementptr inbounds %struct.model_data, ptr %104, i32 0, i32 2
  %106 = load ptr, ptr %105, align 8, !tbaa !21
  %107 = getelementptr inbounds %struct.matrix, ptr %106, i32 0, i32 1
  %108 = load i32, ptr %107, align 4, !tbaa !23
  %109 = mul nsw i32 %102, %108
  %110 = add nsw i32 %109, 0
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds float, ptr %101, i64 %111
  store float 0.000000e+00, ptr %112, align 4, !tbaa !11
  br label %113

113:                                              ; preds = %95, %77
  br label %114

114:                                              ; preds = %113, %55
  %115 = load i32, ptr %8, align 4, !tbaa !9
  %116 = sitofp i32 %115 to float
  %117 = fdiv float %116, 2.000000e+06
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.linear_regression, ptr %118, i32 0, i32 5
  %120 = getelementptr inbounds %struct.model_data, ptr %119, i32 0, i32 2
  %121 = load ptr, ptr %120, align 8, !tbaa !21
  %122 = getelementptr inbounds %struct.matrix, ptr %121, i32 0, i32 3
  %123 = load ptr, ptr %122, align 8, !tbaa !22
  %124 = load i32, ptr %10, align 4, !tbaa !9
  %125 = load ptr, ptr %2, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.linear_regression, ptr %125, i32 0, i32 5
  %127 = getelementptr inbounds %struct.model_data, ptr %126, i32 0, i32 2
  %128 = load ptr, ptr %127, align 8, !tbaa !21
  %129 = getelementptr inbounds %struct.matrix, ptr %128, i32 0, i32 1
  %130 = load i32, ptr %129, align 4, !tbaa !23
  %131 = mul nsw i32 %124, %130
  %132 = add nsw i32 %131, 1
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds float, ptr %123, i64 %133
  store float %117, ptr %134, align 4, !tbaa !11
  %135 = load i32, ptr %7, align 4, !tbaa !9
  %136 = sitofp i32 %135 to float
  %137 = load ptr, ptr %2, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.linear_regression, ptr %137, i32 0, i32 5
  %139 = getelementptr inbounds %struct.model_data, ptr %138, i32 0, i32 3
  %140 = load ptr, ptr %139, align 8, !tbaa !25
  %141 = getelementptr inbounds %struct.matrix, ptr %140, i32 0, i32 3
  %142 = load ptr, ptr %141, align 8, !tbaa !22
  %143 = load i32, ptr %10, align 4, !tbaa !9
  %144 = load ptr, ptr %2, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.linear_regression, ptr %144, i32 0, i32 5
  %146 = getelementptr inbounds %struct.model_data, ptr %145, i32 0, i32 3
  %147 = load ptr, ptr %146, align 8, !tbaa !25
  %148 = getelementptr inbounds %struct.matrix, ptr %147, i32 0, i32 1
  %149 = load i32, ptr %148, align 4, !tbaa !23
  %150 = mul nsw i32 %143, %149
  %151 = add nsw i32 %150, 0
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds float, ptr %142, i64 %152
  store float %136, ptr %153, align 4, !tbaa !11
  %154 = load i32, ptr %10, align 4, !tbaa !9
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %10, align 4, !tbaa !9
  %156 = load i32, ptr %10, align 4, !tbaa !9
  %157 = load ptr, ptr %2, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.linear_regression, ptr %157, i32 0, i32 0
  %159 = load i32, ptr %158, align 8, !tbaa !19
  %160 = icmp eq i32 %156, %159
  br i1 %160, label %161, label %177

161:                                              ; preds = %114
  %162 = call i64 @clock() #6
  store i64 %162, ptr %4, align 8, !tbaa !26
  %163 = load ptr, ptr %2, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.linear_regression, ptr %163, i32 0, i32 5
  %165 = load ptr, ptr %2, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.linear_regression, ptr %165, i32 0, i32 6
  call void @set_data_async(ptr noundef %164, ptr noundef %166)
  %167 = call i64 @clock() #6
  %168 = load i64, ptr %4, align 8, !tbaa !26
  %169 = sub nsw i64 %167, %168
  store i64 %169, ptr %4, align 8, !tbaa !26
  %170 = load i64, ptr %4, align 8, !tbaa !26
  %171 = sitofp i64 %170 to float
  %172 = fdiv float %171, 1.000000e+06
  %173 = load float, ptr %13, align 4, !tbaa !11
  %174 = fadd float %173, %172
  store float %174, ptr %13, align 4, !tbaa !11
  store i32 0, ptr %10, align 4, !tbaa !9
  %175 = load i32, ptr @iter, align 4, !tbaa !9
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr @iter, align 4, !tbaa !9
  br label %177

177:                                              ; preds = %161, %114
  %178 = load i32, ptr @iter, align 4, !tbaa !9
  %179 = load i32, ptr @num_samples, align 4, !tbaa !9
  %180 = load ptr, ptr %2, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.linear_regression, ptr %180, i32 0, i32 0
  %182 = load i32, ptr %181, align 8, !tbaa !19
  %183 = sdiv i32 %179, %182
  %184 = icmp sge i32 %178, %183
  br i1 %184, label %185, label %208

185:                                              ; preds = %177
  %186 = load ptr, ptr %2, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.linear_regression, ptr %186, i32 0, i32 6
  call void @wait_for_draining_pipeline(ptr noundef %187)
  %188 = load ptr, ptr %2, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.linear_regression, ptr %188, i32 0, i32 7
  %190 = getelementptr inbounds %struct.model_state, ptr %189, i32 0, i32 1
  %191 = load atomic i32, ptr %190 seq_cst, align 4, !tbaa !27
  %192 = sitofp i32 %191 to float
  %193 = load i32, ptr @iter, align 4, !tbaa !9
  %194 = load i32, ptr %11, align 4, !tbaa !9
  %195 = load ptr, ptr %2, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.linear_regression, ptr %195, i32 0, i32 0
  %197 = load i32, ptr %196, align 8, !tbaa !19
  %198 = sdiv i32 %194, %197
  %199 = sub nsw i32 %193, %198
  %200 = load ptr, ptr %2, align 8, !tbaa !5
  %201 = getelementptr inbounds %struct.linear_regression, ptr %200, i32 0, i32 0
  %202 = load i32, ptr %201, align 8, !tbaa !19
  %203 = mul nsw i32 %199, %202
  %204 = sitofp i32 %203 to float
  %205 = fdiv float %192, %204
  %206 = fpext float %205 to double
  %207 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, double noundef %206)
  br label %209

208:                                              ; preds = %177
  br label %20, !llvm.loop !28

209:                                              ; preds = %185, %20
  %210 = load float, ptr %13, align 4, !tbaa !11
  %211 = fpext float %210 to double
  %212 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, double noundef %211)
  %213 = load ptr, ptr %2, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.linear_regression, ptr %213, i32 0, i32 3
  %215 = load ptr, ptr %214, align 8, !tbaa !13
  call void @print_weigths(ptr noundef %215)
  %216 = load float, ptr %13, align 4, !tbaa !11
  %217 = load float, ptr @timing_sum, align 4, !tbaa !11
  %218 = fadd float %217, %216
  store float %218, ptr @timing_sum, align 4, !tbaa !11
  %219 = load ptr, ptr %3, align 8, !tbaa !5
  %220 = call i32 @fclose(ptr noundef %219)
  %221 = load ptr, ptr %2, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.linear_regression, ptr %221, i32 0, i32 7
  %223 = getelementptr inbounds %struct.model_state, ptr %222, i32 0, i32 1
  %224 = load atomic i32, ptr %223 seq_cst, align 4, !tbaa !27
  %225 = sitofp i32 %224 to float
  %226 = load i32, ptr @iter, align 4, !tbaa !9
  %227 = load i32, ptr %11, align 4, !tbaa !9
  %228 = load ptr, ptr %2, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.linear_regression, ptr %228, i32 0, i32 0
  %230 = load i32, ptr %229, align 8, !tbaa !19
  %231 = sdiv i32 %227, %230
  %232 = sub nsw i32 %226, %231
  %233 = load ptr, ptr %2, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct.linear_regression, ptr %233, i32 0, i32 0
  %235 = load i32, ptr %234, align 8, !tbaa !19
  %236 = mul nsw i32 %232, %235
  %237 = sitofp i32 %236 to float
  %238 = fdiv float %225, %237
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 10, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 20, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret float %238
}

; 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) #2

declare void @set_random_weights(ptr noundef, i64) #3

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

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

declare void @wait_for_draining_pipeline(ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind
declare i64 @clock() #5

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

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

declare void @print_weigths(ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"linear_regression", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !15, i64 40, !16, i64 72, !18, i64 744}
!15 = !{!"model_data", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"model_multithreading", !7, i64 0, !7, i64 512, !7, i64 640, !7, i64 644, !7, i64 648, !17, i64 656, !6, i64 664}
!17 = !{!"long", !7, i64 0}
!18 = !{!"model_state", !7, i64 0, !7, i64 4}
!19 = !{!14, !10, i64 0}
!20 = !{!14, !7, i64 744}
!21 = !{!14, !6, i64 56}
!22 = !{!7, !7, i64 0}
!23 = !{!24, !10, i64 4}
!24 = !{!"matrix", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 16}
!25 = !{!14, !6, i64 64}
!26 = !{!17, !17, i64 0}
!27 = !{!14, !7, i64 748}
!28 = distinct !{!28, !29}
!29 = !{!"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"

@__const.simulation.modula = external hidden unnamed_addr constant { float, [4 x i8] }, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@iter = external hidden local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@num_samples = external hidden local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [29 x i8], align 1
@timing_sum = external hidden local_unnamed_addr global float, align 4

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local float @simulation(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca [20 x i8], align 16
  %3 = alloca [10 x i8], align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  %.sroa.0.0.copyload = load i64, ptr @__const.simulation.modula, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @set_random_weights(ptr noundef %8, i64 %.sroa.0.0.copyload) #6
  %9 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %10 = getelementptr inbounds i8, ptr %0, i64 744
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  br label %15

15:                                               ; preds = %82, %1
  %.044 = phi i32 [ 0, %1 ], [ %.145, %82 ]
  %.0 = phi float [ 0.000000e+00, %1 ], [ %.1, %82 ]
  %16 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %9, ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6) #6
  %.not = icmp eq i32 %16, -1
  br i1 %.not, label %.loopexit, label %17

17:                                               ; preds = %15
  %18 = load i32, ptr @iter, align 4, !tbaa !15
  %19 = load i32, ptr %0, align 8, !tbaa !16
  %20 = sdiv i32 1000, %19
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %26, label %22

22:                                               ; preds = %17
  %23 = load atomic i8, ptr %10 seq_cst, align 1, !tbaa !17
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  call void @wait_for_draining_pipeline(ptr noundef nonnull %11) #6
  br label %26

26:                                               ; preds = %22, %25, %17
  %.sink = phi i8 [ 1, %17 ], [ 0, %25 ], [ 0, %22 ]
  store atomic i8 %.sink, ptr %10 seq_cst, align 1, !tbaa !17
  %27 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.3) #7
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %38

29:                                               ; preds = %26
  %30 = load ptr, ptr %12, align 8, !tbaa !18
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = getelementptr inbounds i8, ptr %30, i64 4
  %34 = load i32, ptr %33, align 4, !tbaa !20
  %35 = mul nsw i32 %34, %.044
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %32, i64 %36
  store float 1.000000e+00, ptr %37, align 4, !tbaa !22
  br label %51

38:                                               ; preds = %26
  %39 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.4) #7
  %40 = icmp eq i32 %39, 0
  %41 = load ptr, ptr %12, align 8, !tbaa !18
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  %43 = load ptr, ptr %42, align 8, !tbaa !19
  %44 = getelementptr inbounds i8, ptr %41, i64 4
  %45 = load i32, ptr %44, align 4, !tbaa !20
  %46 = mul nsw i32 %45, %.044
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %43, i64 %47
  br i1 %40, label %49, label %50

49:                                               ; preds = %38
  store float 1.000000e+00, ptr %48, align 4, !tbaa !22
  br label %51

50:                                               ; preds = %38
  store float 0.000000e+00, ptr %48, align 4, !tbaa !22
  br label %51

51:                                               ; preds = %49, %50, %29
  %.pre-phi51 = phi i64 [ %47, %49 ], [ %47, %50 ], [ %36, %29 ]
  %52 = phi ptr [ %41, %49 ], [ %41, %50 ], [ %30, %29 ]
  %53 = load i32, ptr %5, align 4, !tbaa !15
  %54 = sitofp i32 %53 to float
  %55 = fdiv float %54, 2.000000e+06
  %56 = getelementptr inbounds i8, ptr %52, i64 16
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = getelementptr float, ptr %57, i64 %.pre-phi51
  %59 = getelementptr i8, ptr %58, i64 4
  store float %55, ptr %59, align 4, !tbaa !22
  %60 = load i32, ptr %4, align 4, !tbaa !15
  %61 = sitofp i32 %60 to float
  %62 = load ptr, ptr %13, align 8, !tbaa !24
  %63 = getelementptr inbounds i8, ptr %62, i64 16
  %64 = load ptr, ptr %63, align 8, !tbaa !19
  %65 = getelementptr inbounds i8, ptr %62, i64 4
  %66 = load i32, ptr %65, align 4, !tbaa !20
  %67 = mul nsw i32 %66, %.044
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %64, i64 %68
  store float %61, ptr %69, align 4, !tbaa !22
  %70 = add nsw i32 %.044, 1
  %71 = load i32, ptr %0, align 8, !tbaa !16
  %72 = icmp eq i32 %70, %71
  br i1 %72, label %73, label %._crit_edge

._crit_edge:                                      ; preds = %51
  %.pre = load i32, ptr @iter, align 4, !tbaa !15
  br label %82

73:                                               ; preds = %51
  %74 = call i64 @clock() #6
  call void @set_data_async(ptr noundef nonnull %14, ptr noundef nonnull %11) #6
  %75 = call i64 @clock() #6
  %76 = sub nsw i64 %75, %74
  %77 = sitofp i64 %76 to float
  %78 = fdiv float %77, 1.000000e+06
  %79 = fadd float %.0, %78
  %80 = load i32, ptr @iter, align 4, !tbaa !15
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr @iter, align 4, !tbaa !15
  %.pre50 = load i32, ptr %0, align 8, !tbaa !16
  br label %82

82:                                               ; preds = %._crit_edge, %73
  %83 = phi i32 [ %.pre50, %73 ], [ %71, %._crit_edge ]
  %84 = phi i32 [ %81, %73 ], [ %.pre, %._crit_edge ]
  %.145 = phi i32 [ 0, %73 ], [ %70, %._crit_edge ]
  %.1 = phi float [ %79, %73 ], [ %.0, %._crit_edge ]
  %85 = load i32, ptr @num_samples, align 4, !tbaa !15
  %86 = sdiv i32 %85, %83
  %.not47 = icmp slt i32 %84, %86
  br i1 %.not47, label %15, label %87, !llvm.loop !25

87:                                               ; preds = %82
  call void @wait_for_draining_pipeline(ptr noundef nonnull %11) #6
  %88 = getelementptr inbounds i8, ptr %0, i64 748
  %89 = load atomic i32, ptr %88 seq_cst, align 4, !tbaa !27
  %90 = sitofp i32 %89 to float
  %91 = load i32, ptr @iter, align 4, !tbaa !15
  %92 = load i32, ptr %0, align 8, !tbaa !16
  %93 = sdiv i32 1000, %92
  %94 = sub nsw i32 %91, %93
  %95 = mul nsw i32 %94, %92
  %96 = sitofp i32 %95 to float
  %97 = fdiv float %90, %96
  %98 = fpext float %97 to double
  %99 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %98)
  br label %.loopexit

.loopexit:                                        ; preds = %15, %87
  %.2 = phi float [ %.1, %87 ], [ %.0, %15 ]
  %100 = fpext float %.2 to double
  %101 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, double noundef %100)
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  call void @print_weigths(ptr noundef %102) #6
  %103 = load float, ptr @timing_sum, align 4, !tbaa !22
  %104 = fadd float %.2, %103
  store float %104, ptr @timing_sum, align 4, !tbaa !22
  %105 = call i32 @fclose(ptr noundef %9)
  %106 = getelementptr inbounds i8, ptr %0, i64 748
  %107 = load atomic i32, ptr %106 seq_cst, align 4, !tbaa !27
  %108 = sitofp i32 %107 to float
  %109 = load i32, ptr @iter, align 4, !tbaa !15
  %110 = load i32, ptr %0, align 8, !tbaa !16
  %111 = sdiv i32 1000, %110
  %112 = sub nsw i32 %109, %111
  %113 = mul nsw i32 %112, %110
  %114 = sitofp i32 %113 to float
  %115 = fdiv float %108, %114
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %2) #6
  ret float %115
}

declare void @set_random_weights(ptr noundef, i64) local_unnamed_addr #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 #2

declare void @wait_for_draining_pipeline(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare i64 @clock() local_unnamed_addr #5

declare void @set_data_async(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @print_weigths(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 = { 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 #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 = { 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 = { mustprogress nofree nounwind willreturn memory(argmem: 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 "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, !10, i64 24}
!6 = !{!"linear_regression", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !12, i64 72, !14, i64 744}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"model_data", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!12 = !{!"model_multithreading", !8, i64 0, !8, i64 512, !8, i64 640, !8, i64 644, !8, i64 648, !13, i64 656, !10, i64 664}
!13 = !{!"long", !8, i64 0}
!14 = !{!"model_state", !8, i64 0, !8, i64 4}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !8, i64 744}
!18 = !{!6, !10, i64 56}
!19 = !{!8, !8, i64 0}
!20 = !{!21, !7, i64 4}
!21 = !{!"matrix", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 16}
!22 = !{!23, !23, i64 0}
!23 = !{!"float", !8, i64 0}
!24 = !{!6, !10, i64 64}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!6, !8, i64 748}


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