; 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 uwtable
define dso_local void @efcn_get_axis_reduction_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store ptr null, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = call ptr @ef_ptr_from_id_ptr(ptr noundef %7)
  store ptr %8, ptr %5, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store i32 1, ptr %6, align 4
  br label %60

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ExternalFunction, ptr %12, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %14, i32 0, i32 11
  %16 = getelementptr inbounds [6 x i32], ptr %15, i64 0, i64 0
  %17 = load i32, ptr %16, align 4, !tbaa !12
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds i32, ptr %18, i64 0
  store i32 %17, ptr %19, align 4, !tbaa !12
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ExternalFunction, ptr %20, i32 0, i32 5
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %22, i32 0, i32 11
  %24 = getelementptr inbounds [6 x i32], ptr %23, i64 0, i64 1
  %25 = load i32, ptr %24, align 4, !tbaa !12
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 1
  store i32 %25, ptr %27, align 4, !tbaa !12
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ExternalFunction, ptr %28, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %30, i32 0, i32 11
  %32 = getelementptr inbounds [6 x i32], ptr %31, i64 0, i64 2
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds i32, ptr %34, i64 2
  store i32 %33, ptr %35, align 4, !tbaa !12
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ExternalFunction, ptr %36, i32 0, i32 5
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %38, i32 0, i32 11
  %40 = getelementptr inbounds [6 x i32], ptr %39, i64 0, i64 3
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds i32, ptr %42, i64 3
  store i32 %41, ptr %43, align 4, !tbaa !12
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ExternalFunction, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %46, i32 0, i32 11
  %48 = getelementptr inbounds [6 x i32], ptr %47, i64 0, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !12
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds i32, ptr %50, i64 4
  store i32 %49, ptr %51, align 4, !tbaa !12
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ExternalFunction, ptr %52, i32 0, i32 5
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.ExternalFunctionInternals, ptr %54, i32 0, i32 11
  %56 = getelementptr inbounds [6 x i32], ptr %55, i64 0, i64 5
  %57 = load i32, ptr %56, align 4, !tbaa !12
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds i32, ptr %58, i64 5
  store i32 %57, ptr %59, align 4, !tbaa !12
  store i32 1, ptr %6, align 4
  br label %60

60:                                               ; preds = %11, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  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 }

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


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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ef_ptr_from_id_ptr(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @efcn_get_axis_reduction_(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = tail call ptr @ef_ptr_from_id_ptr(ptr noundef %0)
  %4 = icmp eq ptr %3, null
  br i1 %4, label %25, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %3, i64 184
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 684
  %9 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %9, ptr %1, align 4, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %7, i64 688
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 %11, ptr %12, align 4, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %7, i64 692
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %14, ptr %15, align 4, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %7, i64 696
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 %17, ptr %18, align 4, !tbaa !11
  %19 = getelementptr inbounds i8, ptr %7, i64 700
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %20, ptr %21, align 4, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %7, i64 704
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %23, ptr %24, align 4, !tbaa !11
  br label %25

25:                                               ; preds = %2, %5
  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, !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}


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