; LLVM IR from csviragh/robotsim :: src/utilities (param_utils)

; 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.flocking_model_params_t = type { [256 x i8], i32, [64 x %struct.fl_param_double_t], i32, [64 x ptr], i32 }
%struct.fl_param_double_t = type { [64 x i8], [10 x i8], double, i32, double, double, double, double, [64 x i8], i8, i8, double, ptr, i32, %struct.anon }
%struct.anon = type { [32 x double], [32 x [7 x i8]] }

; Function Attrs: nounwind uwtable
define dso_local void @ChangeFlockingModelParameter(ptr noundef %0, i32 noundef %1, double noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !11
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.flocking_model_params_t, ptr %7, i32 0, i32 2
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %8, i64 0, i64 %10
  %12 = getelementptr inbounds %struct.fl_param_double_t, ptr %11, i32 0, i32 10
  %13 = load i8, ptr %12, align 1, !tbaa !13, !range !17, !noundef !18
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i32
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %88

17:                                               ; preds = %3
  %18 = load double, ptr %6, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.flocking_model_params_t, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %20, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.fl_param_double_t, ptr %23, i32 0, i32 11
  %25 = load double, ptr %24, align 8, !tbaa !19
  %26 = fadd double %25, %18
  store double %26, ptr %24, align 8, !tbaa !19
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.flocking_model_params_t, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %28, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.fl_param_double_t, ptr %31, i32 0, i32 11
  %33 = load double, ptr %32, align 8, !tbaa !19
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.flocking_model_params_t, ptr %34, i32 0, i32 2
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %35, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.fl_param_double_t, ptr %38, i32 0, i32 7
  %40 = load double, ptr %39, align 8, !tbaa !20
  %41 = fcmp ogt double %33, %40
  br i1 %41, label %42, label %56

42:                                               ; preds = %17
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.flocking_model_params_t, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %44, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.fl_param_double_t, ptr %47, i32 0, i32 7
  %49 = load double, ptr %48, align 8, !tbaa !20
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.flocking_model_params_t, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %51, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.fl_param_double_t, ptr %54, i32 0, i32 11
  store double %49, ptr %55, align 8, !tbaa !19
  br label %87

56:                                               ; preds = %17
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.flocking_model_params_t, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %58, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.fl_param_double_t, ptr %61, i32 0, i32 11
  %63 = load double, ptr %62, align 8, !tbaa !19
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.flocking_model_params_t, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %65, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.fl_param_double_t, ptr %68, i32 0, i32 6
  %70 = load double, ptr %69, align 8, !tbaa !21
  %71 = fcmp olt double %63, %70
  br i1 %71, label %72, label %86

72:                                               ; preds = %56
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.flocking_model_params_t, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %74, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.fl_param_double_t, ptr %77, i32 0, i32 6
  %79 = load double, ptr %78, align 8, !tbaa !21
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.flocking_model_params_t, ptr %80, i32 0, i32 2
  %82 = load i32, ptr %5, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %81, i64 0, i64 %83
  %85 = getelementptr inbounds %struct.fl_param_double_t, ptr %84, i32 0, i32 11
  store double %79, ptr %85, align 8, !tbaa !19
  br label %86

86:                                               ; preds = %72, %56
  br label %87

87:                                               ; preds = %86, %42
  br label %158

88:                                               ; preds = %3
  %89 = load double, ptr %6, align 8, !tbaa !11
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.flocking_model_params_t, ptr %90, i32 0, i32 2
  %92 = load i32, ptr %5, align 4, !tbaa !9
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %91, i64 0, i64 %93
  %95 = getelementptr inbounds %struct.fl_param_double_t, ptr %94, i32 0, i32 2
  %96 = load double, ptr %95, align 8, !tbaa !22
  %97 = fadd double %96, %89
  store double %97, ptr %95, align 8, !tbaa !22
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.flocking_model_params_t, ptr %98, i32 0, i32 2
  %100 = load i32, ptr %5, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %99, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.fl_param_double_t, ptr %102, i32 0, i32 2
  %104 = load double, ptr %103, align 8, !tbaa !22
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.flocking_model_params_t, ptr %105, i32 0, i32 2
  %107 = load i32, ptr %5, align 4, !tbaa !9
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %106, i64 0, i64 %108
  %110 = getelementptr inbounds %struct.fl_param_double_t, ptr %109, i32 0, i32 7
  %111 = load double, ptr %110, align 8, !tbaa !20
  %112 = fcmp ogt double %104, %111
  br i1 %112, label %113, label %127

113:                                              ; preds = %88
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.flocking_model_params_t, ptr %114, i32 0, i32 2
  %116 = load i32, ptr %5, align 4, !tbaa !9
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %115, i64 0, i64 %117
  %119 = getelementptr inbounds %struct.fl_param_double_t, ptr %118, i32 0, i32 7
  %120 = load double, ptr %119, align 8, !tbaa !20
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.flocking_model_params_t, ptr %121, i32 0, i32 2
  %123 = load i32, ptr %5, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %122, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.fl_param_double_t, ptr %125, i32 0, i32 2
  store double %120, ptr %126, align 8, !tbaa !22
  br label %158

127:                                              ; preds = %88
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.flocking_model_params_t, ptr %128, i32 0, i32 2
  %130 = load i32, ptr %5, align 4, !tbaa !9
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %129, i64 0, i64 %131
  %133 = getelementptr inbounds %struct.fl_param_double_t, ptr %132, i32 0, i32 2
  %134 = load double, ptr %133, align 8, !tbaa !22
  %135 = load ptr, ptr %4, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.flocking_model_params_t, ptr %135, i32 0, i32 2
  %137 = load i32, ptr %5, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %136, i64 0, i64 %138
  %140 = getelementptr inbounds %struct.fl_param_double_t, ptr %139, i32 0, i32 6
  %141 = load double, ptr %140, align 8, !tbaa !21
  %142 = fcmp olt double %134, %141
  br i1 %142, label %143, label %157

143:                                              ; preds = %127
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.flocking_model_params_t, ptr %144, i32 0, i32 2
  %146 = load i32, ptr %5, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %145, i64 0, i64 %147
  %149 = getelementptr inbounds %struct.fl_param_double_t, ptr %148, i32 0, i32 6
  %150 = load double, ptr %149, align 8, !tbaa !21
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.flocking_model_params_t, ptr %151, i32 0, i32 2
  %153 = load i32, ptr %5, align 4, !tbaa !9
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %152, i64 0, i64 %154
  %156 = getelementptr inbounds %struct.fl_param_double_t, ptr %155, i32 0, i32 2
  store double %150, ptr %156, align 8, !tbaa !22
  br label %157

157:                                              ; preds = %143, %127
  br label %158

158:                                              ; preds = %157, %113, %87
  ret void
}

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

!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 = !{!"double", !7, i64 0}
!13 = !{!14, !15, i64 193}
!14 = !{!"", !7, i64 0, !7, i64 64, !12, i64 80, !10, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !7, i64 128, !15, i64 192, !15, i64 193, !12, i64 200, !6, i64 208, !10, i64 216, !16, i64 224}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !7, i64 0, !7, i64 256}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!14, !12, i64 200}
!20 = !{!14, !12, i64 120}
!21 = !{!14, !12, i64 112}
!22 = !{!14, !12, i64 80}


; 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.fl_param_double_t = type { [64 x i8], [10 x i8], double, i32, double, double, double, double, [64 x i8], i8, i8, double, ptr, i32, %struct.anon }
%struct.anon = type { [32 x double], [32 x [7 x i8]] }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @ChangeFlockingModelParameter(ptr nocapture noundef %0, i32 noundef %1, double noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 264
  %5 = sext i32 %1 to i64
  %6 = getelementptr inbounds [64 x %struct.fl_param_double_t], ptr %4, i64 0, i64 %5
  %7 = getelementptr inbounds i8, ptr %6, i64 193
  %8 = load i8, ptr %7, align 1, !tbaa !5, !range !14, !noundef !15
  %9 = trunc nuw i8 %8 to i1
  %10 = getelementptr inbounds i8, ptr %6, i64 120
  br i1 %9, label %11, label %23

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %6, i64 200
  %13 = load double, ptr %12, align 8, !tbaa !16
  %14 = fadd double %13, %2
  store double %14, ptr %12, align 8, !tbaa !16
  %15 = load double, ptr %10, align 8, !tbaa !17
  %16 = fcmp ogt double %14, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %11
  store double %15, ptr %12, align 8, !tbaa !16
  br label %35

18:                                               ; preds = %11
  %19 = getelementptr inbounds i8, ptr %6, i64 112
  %20 = load double, ptr %19, align 8, !tbaa !18
  %21 = fcmp olt double %14, %20
  br i1 %21, label %22, label %35

22:                                               ; preds = %18
  store double %20, ptr %12, align 8, !tbaa !16
  br label %35

23:                                               ; preds = %3
  %24 = getelementptr inbounds i8, ptr %6, i64 80
  %25 = load double, ptr %24, align 8, !tbaa !19
  %26 = fadd double %25, %2
  store double %26, ptr %24, align 8, !tbaa !19
  %27 = load double, ptr %10, align 8, !tbaa !17
  %28 = fcmp ogt double %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %23
  store double %27, ptr %24, align 8, !tbaa !19
  br label %35

30:                                               ; preds = %23
  %31 = getelementptr inbounds i8, ptr %6, i64 112
  %32 = load double, ptr %31, align 8, !tbaa !18
  %33 = fcmp olt double %26, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  store double %32, ptr %24, align 8, !tbaa !19
  br label %35

35:                                               ; preds = %30, %34, %17, %22, %18, %29
  ret void
}

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

!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 193}
!6 = !{!"", !7, i64 0, !7, i64 64, !9, i64 80, !10, i64 88, !9, i64 96, !9, i64 104, !9, i64 112, !9, i64 120, !7, i64 128, !11, i64 192, !11, i64 193, !9, i64 200, !12, i64 208, !10, i64 216, !13, i64 224}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"double", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 256}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!6, !9, i64 200}
!17 = !{!6, !9, i64 120}
!18 = !{!6, !9, i64 112}
!19 = !{!6, !9, i64 80}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass