; LLVM IR from csviragh/robotsim :: src (colors)

; 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.model_specific_color_t = type { ptr, [3 x float], [3 x ptr] }

@LoadModelSpecificColors.value_to_compare = external hidden global [32 x i8], align 16
@.str.42 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [5 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @LoadModelSpecificColors(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %80, %4
  %12 = load i32, ptr %9, align 4, !tbaa !9
  %13 = load ptr, ptr %8, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %16, label %83

16:                                               ; preds = %11
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds %struct.model_specific_color_t, ptr %17, i64 %19
  %21 = getelementptr inbounds %struct.model_specific_color_t, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @LoadModelSpecificColors.value_to_compare, ptr noundef @.str.42, ptr noundef %22) #5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 @strcmp(ptr noundef %24, ptr noundef @LoadModelSpecificColors.value_to_compare) #6
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %16
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call double @atof(ptr noundef %28) #6
  %30 = fptrunc double %29 to float
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.model_specific_color_t, ptr %31, i64 %33
  %35 = getelementptr inbounds %struct.model_specific_color_t, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds [3 x float], ptr %35, i64 0, i64 0
  store float %30, ptr %36, align 8, !tbaa !13
  store i32 1, ptr %10, align 4
  br label %84

37:                                               ; preds = %16
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct.model_specific_color_t, ptr %38, i64 %40
  %42 = getelementptr inbounds %struct.model_specific_color_t, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @LoadModelSpecificColors.value_to_compare, ptr noundef @.str.43, ptr noundef %43) #5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call i32 @strcmp(ptr noundef %45, ptr noundef @LoadModelSpecificColors.value_to_compare) #6
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %58

48:                                               ; preds = %37
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call double @atof(ptr noundef %49) #6
  %51 = fptrunc double %50 to float
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.model_specific_color_t, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.model_specific_color_t, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds [3 x float], ptr %56, i64 0, i64 1
  store float %51, ptr %57, align 4, !tbaa !13
  store i32 1, ptr %10, align 4
  br label %84

58:                                               ; preds = %37
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds %struct.model_specific_color_t, ptr %59, i64 %61
  %63 = getelementptr inbounds %struct.model_specific_color_t, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @LoadModelSpecificColors.value_to_compare, ptr noundef @.str.44, ptr noundef %64) #5
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = call i32 @strcmp(ptr noundef %66, ptr noundef @LoadModelSpecificColors.value_to_compare) #6
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %79

69:                                               ; preds = %58
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call double @atof(ptr noundef %70) #6
  %72 = fptrunc double %71 to float
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds %struct.model_specific_color_t, ptr %73, i64 %75
  %77 = getelementptr inbounds %struct.model_specific_color_t, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds [3 x float], ptr %77, i64 0, i64 2
  store float %72, ptr %78, align 8, !tbaa !13
  store i32 1, ptr %10, align 4
  br label %84

79:                                               ; preds = %58
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %9, align 4, !tbaa !9
  br label %11, !llvm.loop !15

83:                                               ; preds = %11
  store i32 0, ptr %10, align 4
  br label %84

84:                                               ; preds = %83, %69, %48, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  %85 = load i32, ptr %10, align 4
  switch i32 %85, label %87 [
    i32 0, label %86
    i32 1, label %86
  ]

86:                                               ; preds = %84, %84
  ret void

87:                                               ; preds = %84
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { 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 = { nounwind }
attributes #6 = { 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, !6, i64 0}
!12 = !{!"", !6, i64 0, !7, i64 8, !7, i64 24}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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.model_specific_color_t = type { ptr, [3 x float], [3 x ptr] }

@LoadModelSpecificColors.value_to_compare = external hidden global [32 x i8], align 16
@.str.42 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @LoadModelSpecificColors(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #3 {
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %.loopexit

7:                                                ; preds = %29
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = icmp slt i64 %indvars.iv.next, %9
  br i1 %10, label %.lr.ph, label %.loopexit, !llvm.loop !9

.lr.ph:                                           ; preds = %4, %7
  %indvars.iv = phi i64 [ %indvars.iv.next, %7 ], [ 0, %4 ]
  %11 = getelementptr inbounds %struct.model_specific_color_t, ptr %2, i64 %indvars.iv
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @LoadModelSpecificColors.value_to_compare, ptr noundef nonnull dereferenceable(1) @.str.42, ptr noundef %12) #4
  %14 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @LoadModelSpecificColors.value_to_compare) #5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %20

16:                                               ; preds = %.lr.ph
  %17 = tail call double @atof(ptr noundef %1) #5
  %18 = fptrunc double %17 to float
  %19 = getelementptr inbounds i8, ptr %11, i64 8
  store float %18, ptr %19, align 8, !tbaa !14
  br label %.loopexit

20:                                               ; preds = %.lr.ph
  %21 = load ptr, ptr %11, align 8, !tbaa !11
  %22 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @LoadModelSpecificColors.value_to_compare, ptr noundef nonnull dereferenceable(1) @.str.43, ptr noundef %21) #4
  %23 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @LoadModelSpecificColors.value_to_compare) #5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %20
  %26 = tail call double @atof(ptr noundef %1) #5
  %27 = fptrunc double %26 to float
  %28 = getelementptr inbounds i8, ptr %11, i64 12
  store float %27, ptr %28, align 4, !tbaa !14
  br label %.loopexit

29:                                               ; preds = %20
  %30 = load ptr, ptr %11, align 8, !tbaa !11
  %31 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @LoadModelSpecificColors.value_to_compare, ptr noundef nonnull dereferenceable(1) @.str.44, ptr noundef %30) #4
  %32 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) @LoadModelSpecificColors.value_to_compare) #5
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %7

34:                                               ; preds = %29
  %35 = tail call double @atof(ptr noundef %1) #5
  %36 = fptrunc double %35 to float
  %37 = getelementptr inbounds i8, ptr %11, i64 16
  store float %36, ptr %37, align 8, !tbaa !14
  br label %.loopexit

.loopexit:                                        ; preds = %7, %4, %34, %25, %16
  ret void
}

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { nofree 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 #4 = { nounwind }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !7, i64 8, !7, i64 24}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}


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