; 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_extend_hi_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = sub nsw i32 %11, 1
  store i32 %12, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call ptr @ef_ptr_from_id_ptr(ptr noundef %13)
  store ptr %14, ptr %7, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %3
  store i32 1, ptr %9, align 4
  br label %84

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

84:                                               ; preds = %17, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 184}
!12 = !{!"", !6, i64 0, !7, i64 8, !7, i64 48, !10, i64 176, !10, i64 180, !6, i64 184}


; 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_extend_hi_(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = tail call ptr @ef_ptr_from_id_ptr(ptr noundef %0)
  %6 = icmp eq ptr %5, null
  br i1 %6, label %30, label %7

7:                                                ; preds = %3
  %8 = add nsw i32 %4, -1
  %9 = getelementptr inbounds i8, ptr %5, i64 184
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %10, i64 1720
  %12 = sext i32 %8 to i64
  %13 = getelementptr inbounds [9 x [6 x i32]], ptr %11, i64 0, i64 %12
  %14 = load i32, ptr %13, align 8, !tbaa !5
  store i32 %14, ptr %2, align 4, !tbaa !5
  %15 = getelementptr inbounds [9 x [6 x i32]], ptr %11, i64 0, i64 %12, i64 1
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds [9 x [6 x i32]], ptr %11, i64 0, i64 %12, i64 2
  %19 = load i32, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %19, ptr %20, align 4, !tbaa !5
  %21 = getelementptr inbounds [9 x [6 x i32]], ptr %11, i64 0, i64 %12, i64 3
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %2, i64 12
  store i32 %22, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds [9 x [6 x i32]], ptr %11, i64 0, i64 %12, i64 4
  %25 = load i32, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 %25, ptr %26, align 4, !tbaa !5
  %27 = getelementptr inbounds [9 x [6 x i32]], ptr %11, i64 0, i64 %12, i64 5
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %2, i64 20
  store i32 %28, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %3, %7
  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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 184}
!10 = !{!"", !11, i64 0, !7, i64 8, !7, i64 48, !6, i64 176, !6, i64 180, !11, i64 184}
!11 = !{!"any pointer", !7, i64 0}


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