; LLVM IR from NOAA-PMEL/Ferret :: fer/ccr (EF_InternalUtil)

; 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: 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
declare dso_local ptr @ef_ptr_from_id_ptr(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @efcn_get_custom_axis_sub_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #1 {
  %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
  %16 = alloca i32, align 4
  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) #3
  store ptr null, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = call ptr @ef_ptr_from_id_ptr(ptr noundef %17)
  store ptr %18, ptr %15, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %7
  store i32 1, ptr %16, align 4
  br label %83

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

83:                                               ; preds = %21, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  ret void
}

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 = { 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 = { 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, !15, i64 24}
!14 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !7, i64 48}
!15 = !{!"double", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!14, !15, i64 32}
!18 = !{!14, !15, i64 40}
!19 = !{!14, !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
declare dso_local ptr @ef_ptr_from_id_ptr(ptr noundef) local_unnamed_addr #0

; 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 #1

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

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

32:                                               ; preds = %7, %10
  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" }
attributes #1 = { 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 #2 = { 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, !14, i64 24}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !8, i64 48}
!14 = !{!"double", !8, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!13, !14, i64 32}
!17 = !{!13, !14, i64 40}
!18 = !{!13, !10, i64 4}


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