; LLVM IR from NOAA-PMEL/Ferret :: fer/ef_utility (ef_set_custom_axis_sub)

; 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.ExternalFunction = type { ptr, [40 x i8], [128 x i8], i32, i32, ptr }
%struct.ExternalFunctionInternals = type { float, [128 x i8], [40 x i8], [40 x i8], i32, i32, i32, i32, [9 x [6 x i32]], [9 x [6 x i32]], [6 x i32], [6 x i32], [6 x i32], i32, [6 x i32], [6 x %struct.Axis], [9 x [6 x i32]], [9 x [6 x i32]], [9 x [6 x i32]], [9 x i32], [9 x [40 x i8]], [9 x [40 x i8]], [9 x [128 x i8]] }
%struct.Axis = type { i32, i32, i32, i32, i32, double, double, double, [40 x i8] }

; Function Attrs: nounwind uwtable
define dso_local void @ef_set_custom_axis_sub_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = call ptr @ef_ptr_from_id_ptr(ptr noundef %16)
  store ptr %17, ptr %15, align 8, !tbaa !5
  %18 = load ptr, ptr %15, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %7
  call void @abort() #6
  unreachable

21:                                               ; preds = %7
  %22 = load ptr, ptr %15, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ExternalFunction, ptr %22, i32 0, i32 5
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %24, i32 0, i32 15
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = sub nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [6 x %struct.Axis], ptr %25, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.Axis, ptr %30, i32 0, i32 8
  %32 = getelementptr inbounds [40 x i8], ptr %31, i64 0, i64 0
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = call ptr @strcpy(ptr noundef %32, ptr noundef %33) #5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load float, ptr %35, align 4, !tbaa !13
  %37 = fpext float %36 to double
  %38 = load ptr, ptr %15, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ExternalFunction, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %40, i32 0, i32 15
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i32, ptr %42, align 4, !tbaa !12
  %44 = sub nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [6 x %struct.Axis], ptr %41, i64 0, i64 %45
  %47 = getelementptr inbounds %struct.Axis, ptr %46, i32 0, i32 5
  store double %37, ptr %47, align 8, !tbaa !15
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = load float, ptr %48, align 4, !tbaa !13
  %50 = fpext float %49 to double
  %51 = load ptr, ptr %15, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ExternalFunction, ptr %51, i32 0, i32 5
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %53, i32 0, i32 15
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = load i32, ptr %55, align 4, !tbaa !12
  %57 = sub nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [6 x %struct.Axis], ptr %54, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.Axis, ptr %59, i32 0, i32 6
  store double %50, ptr %60, align 8, !tbaa !18
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load float, ptr %61, align 4, !tbaa !13
  %63 = fpext float %62 to double
  %64 = load ptr, ptr %15, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ExternalFunction, ptr %64, i32 0, i32 5
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %66, i32 0, i32 15
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load i32, ptr %68, align 4, !tbaa !12
  %70 = sub nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [6 x %struct.Axis], ptr %67, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.Axis, ptr %72, i32 0, i32 7
  store double %63, ptr %73, align 8, !tbaa !19
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = load i32, ptr %74, align 4, !tbaa !12
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ExternalFunction, ptr %76, i32 0, i32 5
  %78 = load ptr, ptr %77, align 8, !tbaa !9
  %79 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %78, i32 0, i32 15
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = load i32, ptr %80, align 4, !tbaa !12
  %82 = sub nsw i32 %81, 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [6 x %struct.Axis], ptr %79, i64 0, i64 %83
  %85 = getelementptr inbounds %struct.Axis, ptr %84, i32 0, i32 1
  store i32 %75, ptr %85, align 4, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  ret void
}

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

declare ptr @ef_ptr_from_id_ptr(ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @abort() #3

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #4

; 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 = { "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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 184}
!10 = !{!"", !6, i64 0, !7, i64 8, !7, i64 48, !11, i64 176, !11, i64 180, !6, i64 184}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !17, i64 24}
!16 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !17, i64 24, !17, i64 32, !17, i64 40, !7, i64 48}
!17 = !{!"double", !7, i64 0}
!18 = !{!16, !17, i64 32}
!19 = !{!16, !17, i64 40}
!20 = !{!16, !11, i64 4}


; 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.Axis = type { i32, i32, i32, i32, i32, double, double, double, [40 x i8] }

; Function Attrs: nounwind uwtable
define dso_local void @ef_set_custom_axis_sub_(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef readonly %6) local_unnamed_addr #0 {
  %8 = tail call ptr @ef_ptr_from_id_ptr(ptr noundef %0) #4
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  tail call void @abort() #5
  unreachable

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %8, i64 184
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 760
  %15 = load i32, ptr %1, align 4, !tbaa !11
  %16 = add nsw i32 %15, -1
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [6 x %struct.Axis], ptr %14, i64 0, i64 %17, i32 8
  %19 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %18, ptr noundef nonnull dereferenceable(1) %5) #4
  %20 = load float, ptr %2, align 4, !tbaa !12
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 760
  %23 = load i32, ptr %1, align 4, !tbaa !11
  %24 = add nsw i32 %23, -1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [6 x %struct.Axis], ptr %22, i64 0, i64 %25, i32 5
  %27 = load float, ptr %3, align 4, !tbaa !12
  %28 = insertelement <2 x float> poison, float %20, i64 0
  %29 = insertelement <2 x float> %28, float %27, i64 1
  %30 = fpext <2 x float> %29 to <2 x double>
  store <2 x double> %30, ptr %26, align 8, !tbaa !14
  %31 = load float, ptr %4, align 4, !tbaa !12
  %32 = fpext float %31 to double
  %33 = getelementptr inbounds [6 x %struct.Axis], ptr %22, i64 0, i64 %25, i32 7
  store double %32, ptr %33, align 8, !tbaa !16
  %34 = load i32, ptr %6, align 4, !tbaa !11
  %35 = getelementptr inbounds [6 x %struct.Axis], ptr %22, i64 0, i64 %25, i32 1
  store i32 %34, ptr %35, align 4, !tbaa !18
  ret void
}

declare ptr @ef_ptr_from_id_ptr(ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #3

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 = { "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 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { 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, !7, i64 184}
!6 = !{!"", !7, i64 0, !8, i64 8, !8, i64 48, !10, i64 176, !10, i64 180, !7, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!17, !15, i64 40}
!17 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !8, i64 48}
!18 = !{!17, !10, i64 4}


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