; LLVM IR from ggml-org/ggml :: examples/sam (main)

; 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.prompt_encoder_result = type { ptr, ptr }
%struct.sam_model = type { %struct.sam_hparams, %struct.sam_encoder_image, %struct.sam_encoder_prompt, %struct.sam_decoder_mask, ptr, %"class.std::map" }
%struct.sam_hparams = type { i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float }
%struct.sam_encoder_image = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::vector.9" }
%"class.std::vector.9" = type { %"struct.std::_Vector_base.10" }
%"struct.std::_Vector_base.10" = type { %"struct.std::_Vector_base<sam_layer_enc, std::allocator<sam_layer_enc>>::_Vector_impl" }
%"struct.std::_Vector_base<sam_layer_enc, std::allocator<sam_layer_enc>>::_Vector_impl" = type { %"struct.std::_Vector_base<sam_layer_enc, std::allocator<sam_layer_enc>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sam_layer_enc, std::allocator<sam_layer_enc>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.sam_encoder_prompt = type { ptr, ptr, %"class.std::vector.14", ptr }
%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<ggml_tensor *, std::allocator<ggml_tensor *>>::_Vector_impl" }
%"struct.std::_Vector_base<ggml_tensor *, std::allocator<ggml_tensor *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ggml_tensor *, std::allocator<ggml_tensor *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ggml_tensor *, std::allocator<ggml_tensor *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.sam_decoder_mask = type { %"class.std::vector.19", %struct.sam_layer_dec_transformer_attn, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::vector.24", ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.std::vector.19" = type { %"struct.std::_Vector_base.20" }
%"struct.std::_Vector_base.20" = type { %"struct.std::_Vector_base<sam_layer_dec_transformer, std::allocator<sam_layer_dec_transformer>>::_Vector_impl" }
%"struct.std::_Vector_base<sam_layer_dec_transformer, std::allocator<sam_layer_dec_transformer>>::_Vector_impl" = type { %"struct.std::_Vector_base<sam_layer_dec_transformer, std::allocator<sam_layer_dec_transformer>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sam_layer_dec_transformer, std::allocator<sam_layer_dec_transformer>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.sam_layer_dec_transformer_attn = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"class.std::vector.24" = type { %"struct.std::_Vector_base.25" }
%"struct.std::_Vector_base.25" = type { %"struct.std::_Vector_base<sam_layer_dec_output_hypernet_mlps, std::allocator<sam_layer_dec_output_hypernet_mlps>>::_Vector_impl" }
%"struct.std::_Vector_base<sam_layer_dec_output_hypernet_mlps, std::allocator<sam_layer_dec_output_hypernet_mlps>>::_Vector_impl" = type { %"struct.std::_Vector_base<sam_layer_dec_output_hypernet_mlps, std::allocator<sam_layer_dec_output_hypernet_mlps>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sam_layer_dec_output_hypernet_mlps, std::allocator<sam_layer_dec_output_hypernet_mlps>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, ggml_tensor *>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%struct.ggml_tensor = type { i32, ptr, [4 x i64], [4 x i64], i32, [16 x i32], i32, [10 x ptr], ptr, i64, ptr, [64 x i8], ptr, [8 x i8] }

@.str.142 = external hidden unnamed_addr constant [13 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: mustprogress uwtable
declare dso_local noundef i32 @_ZNK11sam_hparams10n_img_embdEv(ptr noundef nonnull align 4 dereferenceable(52)) #1 align 2

declare ptr @ggml_new_tensor_3d(ptr noundef, i32 noundef, i64 noundef, i64 noundef, i64 noundef) #2

declare ptr @ggml_new_tensor_2d(ptr noundef, i32 noundef, i64 noundef, i64 noundef) #2

declare ptr @ggml_set_name(ptr noundef, ptr noundef) #2

declare void @ggml_set_input(ptr noundef) #2

declare ptr @ggml_mul_mat(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @ggml_cont(ptr noundef, ptr noundef) #2

declare ptr @ggml_transpose(ptr noundef, ptr noundef) #2

declare ptr @ggml_scale(ptr noundef, ptr noundef, float noundef) #2

declare ptr @ggml_map_custom1(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL12ggml_sam_sinP11ggml_tensorPKS_iiPv(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL12ggml_sam_cosP11ggml_tensorPKS_iiPv(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

declare void @ggml_build_forward_expand(ptr noundef, ptr noundef) #2

declare ptr @ggml_cpy(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @ggml_view_3d(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #2

declare ptr @ggml_repeat(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @ggml_add_inplace(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local { ptr, ptr } @_Z17sam_encode_promptRK9sam_modelP12ggml_contextP11ggml_cgraphR9sam_state(ptr noundef nonnull align 8 dereferenceable(496) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(112) %3) #1 {
  %5 = alloca %struct.prompt_encoder_result, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %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 ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sam_model, ptr %19, i32 0, i32 0
  store ptr %20, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sam_model, ptr %21, i32 0, i32 2
  store ptr %22, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call ptr @ggml_new_tensor_2d(ptr noundef %23, i32 noundef 0, i64 noundef 2, i64 noundef 2)
  store ptr %24, ptr %12, align 8, !tbaa !5
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  %26 = call ptr @ggml_set_name(ptr noundef %25, ptr noundef @.str.142)
  %27 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ggml_set_input(ptr noundef %27)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call ptr @ggml_transpose(ptr noundef %30, ptr noundef %33)
  %35 = call ptr @ggml_cont(ptr noundef %29, ptr noundef %34)
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = call ptr @ggml_mul_mat(ptr noundef %28, ptr noundef %35, ptr noundef %36)
  store ptr %37, ptr %13, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = call ptr @ggml_scale(ptr noundef %38, ptr noundef %39, float noundef 0x401921FB60000000)
  store ptr %40, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = call ptr @ggml_map_custom1(ptr noundef %41, ptr noundef %42, ptr noundef @_ZL12ggml_sam_sinP11ggml_tensorPKS_iiPv, i32 noundef -1, ptr noundef null)
  store ptr %43, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %13, align 8, !tbaa !5
  %46 = call ptr @ggml_map_custom1(ptr noundef %44, ptr noundef %45, ptr noundef @_ZL12ggml_sam_cosP11ggml_tensorPKS_iiPv, i32 noundef -1, ptr noundef null)
  store ptr %46, ptr %15, align 8, !tbaa !5
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ggml_tensor, ptr %48, i32 0, i32 2
  %50 = getelementptr inbounds [4 x i64], ptr %49, i64 0, i64 0
  %51 = load i64, ptr %50, align 8, !tbaa !15
  %52 = load ptr, ptr %15, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ggml_tensor, ptr %52, i32 0, i32 2
  %54 = getelementptr inbounds [4 x i64], ptr %53, i64 0, i64 0
  %55 = load i64, ptr %54, align 8, !tbaa !15
  %56 = add nsw i64 %51, %55
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ggml_tensor, ptr %57, i32 0, i32 2
  %59 = getelementptr inbounds [4 x i64], ptr %58, i64 0, i64 1
  %60 = load i64, ptr %59, align 8, !tbaa !15
  %61 = call ptr @ggml_new_tensor_2d(ptr noundef %47, i32 noundef 0, i64 noundef %56, i64 noundef %60)
  store ptr %61, ptr %13, align 8, !tbaa !5
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %14, align 8, !tbaa !5
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ggml_tensor, ptr %67, i32 0, i32 2
  %69 = getelementptr inbounds [4 x i64], ptr %68, i64 0, i64 0
  %70 = load i64, ptr %69, align 8, !tbaa !15
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ggml_tensor, ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds [4 x i64], ptr %72, i64 0, i64 1
  %74 = load i64, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ggml_tensor, ptr %75, i32 0, i32 3
  %77 = getelementptr inbounds [4 x i64], ptr %76, i64 0, i64 1
  %78 = load i64, ptr %77, align 8, !tbaa !15
  %79 = call ptr @ggml_view_2d(ptr noundef %65, ptr noundef %66, i64 noundef %70, i64 noundef %74, i64 noundef %78, i64 noundef 0)
  %80 = call ptr @ggml_cpy(ptr noundef %63, ptr noundef %64, ptr noundef %79)
  call void @ggml_build_forward_expand(ptr noundef %62, ptr noundef %80)
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = load ptr, ptr %14, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.ggml_tensor, ptr %86, i32 0, i32 2
  %88 = getelementptr inbounds [4 x i64], ptr %87, i64 0, i64 0
  %89 = load i64, ptr %88, align 8, !tbaa !15
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ggml_tensor, ptr %90, i32 0, i32 2
  %92 = getelementptr inbounds [4 x i64], ptr %91, i64 0, i64 1
  %93 = load i64, ptr %92, align 8, !tbaa !15
  %94 = load ptr, ptr %13, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.ggml_tensor, ptr %94, i32 0, i32 3
  %96 = getelementptr inbounds [4 x i64], ptr %95, i64 0, i64 1
  %97 = load i64, ptr %96, align 8, !tbaa !15
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.ggml_tensor, ptr %98, i32 0, i32 3
  %100 = getelementptr inbounds [4 x i64], ptr %99, i64 0, i64 1
  %101 = load i64, ptr %100, align 8, !tbaa !15
  %102 = call ptr @ggml_view_2d(ptr noundef %84, ptr noundef %85, i64 noundef %89, i64 noundef %93, i64 noundef %97, i64 noundef %101)
  %103 = call ptr @ggml_cpy(ptr noundef %82, ptr noundef %83, ptr noundef %102)
  call void @ggml_build_forward_expand(ptr noundef %81, ptr noundef %103)
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %106, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !17
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  %111 = load ptr, ptr %13, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.ggml_tensor, ptr %111, i32 0, i32 2
  %113 = getelementptr inbounds [4 x i64], ptr %112, i64 0, i64 0
  %114 = load i64, ptr %113, align 8, !tbaa !15
  %115 = load ptr, ptr %13, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.ggml_tensor, ptr %115, i32 0, i32 3
  %117 = getelementptr inbounds [4 x i64], ptr %116, i64 0, i64 1
  %118 = load i64, ptr %117, align 8, !tbaa !15
  %119 = load ptr, ptr %13, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.ggml_tensor, ptr %119, i32 0, i32 3
  %121 = getelementptr inbounds [4 x i64], ptr %120, i64 0, i64 1
  %122 = load i64, ptr %121, align 8, !tbaa !15
  %123 = call ptr @ggml_view_2d(ptr noundef %109, ptr noundef %110, i64 noundef %114, i64 noundef 1, i64 noundef %118, i64 noundef %122)
  %124 = call ptr @ggml_cpy(ptr noundef %105, ptr noundef %108, ptr noundef %123)
  call void @ggml_build_forward_expand(ptr noundef %104, ptr noundef %124)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = load ptr, ptr %13, align 8, !tbaa !5
  %127 = load ptr, ptr %13, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.ggml_tensor, ptr %127, i32 0, i32 2
  %129 = getelementptr inbounds [4 x i64], ptr %128, i64 0, i64 0
  %130 = load i64, ptr %129, align 8, !tbaa !15
  %131 = load ptr, ptr %13, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.ggml_tensor, ptr %131, i32 0, i32 3
  %133 = getelementptr inbounds [4 x i64], ptr %132, i64 0, i64 1
  %134 = load i64, ptr %133, align 8, !tbaa !15
  %135 = call ptr @ggml_view_2d(ptr noundef %125, ptr noundef %126, i64 noundef %130, i64 noundef 1, i64 noundef %134, i64 noundef 0)
  store ptr %135, ptr %16, align 8, !tbaa !5
  %136 = load ptr, ptr %8, align 8, !tbaa !5
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  %138 = load ptr, ptr %7, align 8, !tbaa !5
  %139 = load ptr, ptr %16, align 8, !tbaa !5
  %140 = load ptr, ptr %11, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %140, i32 0, i32 2
  %142 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP11ggml_tensorSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %141, i64 noundef 1) #5
  %143 = load ptr, ptr %142, align 8, !tbaa !5
  %144 = call ptr @ggml_add_inplace(ptr noundef %138, ptr noundef %139, ptr noundef %143)
  %145 = load ptr, ptr %16, align 8, !tbaa !5
  %146 = call ptr @ggml_cpy(ptr noundef %137, ptr noundef %144, ptr noundef %145)
  call void @ggml_build_forward_expand(ptr noundef %136, ptr noundef %146)
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %147 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %147, ptr %17, align 8, !tbaa !5
  %148 = load ptr, ptr %8, align 8, !tbaa !5
  %149 = load ptr, ptr %17, align 8, !tbaa !5
  call void @ggml_build_forward_expand(ptr noundef %148, ptr noundef %149)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  %152 = load ptr, ptr %7, align 8, !tbaa !5
  %153 = load ptr, ptr %11, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %153, i32 0, i32 3
  %155 = load ptr, ptr %154, align 8, !tbaa !18
  %156 = load ptr, ptr %11, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %156, i32 0, i32 3
  %158 = load ptr, ptr %157, align 8, !tbaa !18
  %159 = getelementptr inbounds %struct.ggml_tensor, ptr %158, i32 0, i32 2
  %160 = getelementptr inbounds [4 x i64], ptr %159, i64 0, i64 0
  %161 = load i64, ptr %160, align 8, !tbaa !15
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %162, i32 0, i32 3
  %164 = load ptr, ptr %163, align 8, !tbaa !18
  %165 = getelementptr inbounds %struct.ggml_tensor, ptr %164, i32 0, i32 3
  %166 = getelementptr inbounds [4 x i64], ptr %165, i64 0, i64 0
  %167 = load i64, ptr %166, align 8, !tbaa !15
  %168 = load ptr, ptr %11, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.sam_encoder_prompt, ptr %168, i32 0, i32 3
  %170 = load ptr, ptr %169, align 8, !tbaa !18
  %171 = getelementptr inbounds %struct.ggml_tensor, ptr %170, i32 0, i32 3
  %172 = getelementptr inbounds [4 x i64], ptr %171, i64 0, i64 0
  %173 = load i64, ptr %172, align 8, !tbaa !15
  %174 = call ptr @ggml_view_3d(ptr noundef %152, ptr noundef %155, i64 noundef 1, i64 noundef 1, i64 noundef %161, i64 noundef %167, i64 noundef %173, i64 noundef 0)
  %175 = call ptr @ggml_cont(ptr noundef %151, ptr noundef %174)
  %176 = load ptr, ptr %7, align 8, !tbaa !5
  %177 = load ptr, ptr %10, align 8, !tbaa !5
  %178 = call noundef i32 @_ZNK11sam_hparams10n_img_embdEv(ptr noundef nonnull align 4 dereferenceable(52) %177)
  %179 = sext i32 %178 to i64
  %180 = load ptr, ptr %10, align 8, !tbaa !5
  %181 = call noundef i32 @_ZNK11sam_hparams10n_img_embdEv(ptr noundef nonnull align 4 dereferenceable(52) %180)
  %182 = sext i32 %181 to i64
  %183 = load ptr, ptr %10, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.sam_hparams, ptr %183, i32 0, i32 3
  %185 = load i32, ptr %184, align 4, !tbaa !19
  %186 = sext i32 %185 to i64
  %187 = call ptr @ggml_new_tensor_3d(ptr noundef %176, i32 noundef 0, i64 noundef %179, i64 noundef %182, i64 noundef %186)
  %188 = call ptr @ggml_repeat(ptr noundef %150, ptr noundef %175, ptr noundef %187)
  store ptr %188, ptr %18, align 8, !tbaa !5
  %189 = load ptr, ptr %8, align 8, !tbaa !5
  %190 = load ptr, ptr %18, align 8, !tbaa !5
  call void @ggml_build_forward_expand(ptr noundef %189, ptr noundef %190)
  call void @_ZN21prompt_encoder_resultC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #5
  %191 = load ptr, ptr %17, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.prompt_encoder_result, ptr %5, i32 0, i32 0
  store ptr %191, ptr %192, align 8, !tbaa !23
  %193 = load ptr, ptr %18, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.prompt_encoder_result, ptr %5, i32 0, i32 1
  store ptr %193, ptr %194, align 8, !tbaa !25
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %195 = load { ptr, ptr }, ptr %5, align 8
  ret { ptr, ptr } %195
}

declare ptr @ggml_view_2d(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP11ggml_tensorSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN21prompt_encoder_resultC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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 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 = { inlinehint mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS18sam_encoder_prompt", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 40}
!11 = !{!"_ZTSSt6vectorIP11ggml_tensorSaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIP11ggml_tensorSaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIP11ggml_tensorSaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIP11ggml_tensorSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !6, i64 8}
!18 = !{!10, !6, i64 40}
!19 = !{!20, !21, i64 12}
!20 = !{!"_ZTS11sam_hparams", !21, i64 0, !21, i64 4, !21, i64 8, !21, i64 12, !21, i64 16, !21, i64 20, !21, i64 24, !22, i64 28, !22, i64 32, !22, i64 36, !22, i64 40, !22, i64 44, !22, i64 48}
!21 = !{!"int", !7, i64 0}
!22 = !{!"float", !7, i64 0}
!23 = !{!24, !6, i64 0}
!24 = !{!"_ZTS21prompt_encoder_result", !6, i64 0, !6, i64 8}
!25 = !{!24, !6, i64 8}


; 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.prompt_encoder_result = type { ptr, ptr }

@.str.142 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK11sam_hparams10n_img_embdEv(ptr noundef nonnull align 4 dereferenceable(52)) local_unnamed_addr #0 align 2

declare ptr @ggml_new_tensor_3d(ptr noundef, i32 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare ptr @ggml_new_tensor_2d(ptr noundef, i32 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare ptr @ggml_set_name(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @ggml_set_input(ptr noundef) local_unnamed_addr #1

declare ptr @ggml_mul_mat(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ggml_cont(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ggml_transpose(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ggml_scale(ptr noundef, ptr noundef, float noundef) local_unnamed_addr #1

declare ptr @ggml_map_custom1(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL12ggml_sam_sinP11ggml_tensorPKS_iiPv(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL12ggml_sam_cosP11ggml_tensorPKS_iiPv(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

declare void @ggml_build_forward_expand(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ggml_cpy(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ggml_view_3d(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare ptr @ggml_repeat(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ggml_add_inplace(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local { ptr, ptr } @_Z17sam_encode_promptRK9sam_modelP12ggml_contextP11ggml_cgraphR9sam_state(ptr noundef nonnull align 8 dereferenceable(496) %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef nonnull readnone align 8 dereferenceable(112) %3) local_unnamed_addr #0 {
  %5 = alloca %struct.prompt_encoder_result, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 152
  %7 = tail call ptr @ggml_new_tensor_2d(ptr noundef %1, i32 noundef 0, i64 noundef 2, i64 noundef 2)
  %8 = tail call ptr @ggml_set_name(ptr noundef %7, ptr noundef nonnull @.str.142)
  tail call void @ggml_set_input(ptr noundef %7)
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = tail call ptr @ggml_transpose(ptr noundef %1, ptr noundef %9)
  %11 = tail call ptr @ggml_cont(ptr noundef %1, ptr noundef %10)
  %12 = tail call ptr @ggml_mul_mat(ptr noundef %1, ptr noundef %11, ptr noundef %7)
  %13 = tail call ptr @ggml_scale(ptr noundef %1, ptr noundef %12, float noundef 0x401921FB60000000)
  %14 = tail call ptr @ggml_map_custom1(ptr noundef %1, ptr noundef %13, ptr noundef nonnull @_ZL12ggml_sam_sinP11ggml_tensorPKS_iiPv, i32 noundef -1, ptr noundef null)
  %15 = tail call ptr @ggml_map_custom1(ptr noundef %1, ptr noundef %13, ptr noundef nonnull @_ZL12ggml_sam_cosP11ggml_tensorPKS_iiPv, i32 noundef -1, ptr noundef null)
  %16 = getelementptr inbounds i8, ptr %14, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %15, i64 16
  %19 = load i64, ptr %18, align 8, !tbaa !14
  %20 = add nsw i64 %19, %17
  %21 = getelementptr inbounds i8, ptr %13, i64 24
  %22 = load i64, ptr %21, align 8, !tbaa !14
  %23 = tail call ptr @ggml_new_tensor_2d(ptr noundef %1, i32 noundef 0, i64 noundef %20, i64 noundef %22)
  %24 = load i64, ptr %16, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %14, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %23, i64 56
  %28 = load i64, ptr %27, align 8, !tbaa !14
  %29 = tail call ptr @ggml_view_2d(ptr noundef %1, ptr noundef %23, i64 noundef %24, i64 noundef %26, i64 noundef %28, i64 noundef 0)
  %30 = tail call ptr @ggml_cpy(ptr noundef %1, ptr noundef %14, ptr noundef %29)
  tail call void @ggml_build_forward_expand(ptr noundef %2, ptr noundef %30)
  %31 = load i64, ptr %16, align 8, !tbaa !14
  %32 = load i64, ptr %25, align 8, !tbaa !14
  %33 = load i64, ptr %27, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %14, i64 56
  %35 = load i64, ptr %34, align 8, !tbaa !14
  %36 = tail call ptr @ggml_view_2d(ptr noundef %1, ptr noundef %23, i64 noundef %31, i64 noundef %32, i64 noundef %33, i64 noundef %35)
  %37 = tail call ptr @ggml_cpy(ptr noundef %1, ptr noundef %15, ptr noundef %36)
  tail call void @ggml_build_forward_expand(ptr noundef %2, ptr noundef %37)
  %38 = getelementptr inbounds i8, ptr %0, i64 160
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %23, i64 16
  %41 = load i64, ptr %40, align 8, !tbaa !14
  %42 = load i64, ptr %27, align 8, !tbaa !14
  %43 = tail call ptr @ggml_view_2d(ptr noundef %1, ptr noundef %23, i64 noundef %41, i64 noundef 1, i64 noundef %42, i64 noundef %42)
  %44 = tail call ptr @ggml_cpy(ptr noundef %1, ptr noundef %39, ptr noundef %43)
  tail call void @ggml_build_forward_expand(ptr noundef %2, ptr noundef %44)
  %45 = load i64, ptr %40, align 8, !tbaa !14
  %46 = load i64, ptr %27, align 8, !tbaa !14
  %47 = tail call ptr @ggml_view_2d(ptr noundef %1, ptr noundef %23, i64 noundef %45, i64 noundef 1, i64 noundef %46, i64 noundef 0)
  %48 = getelementptr inbounds i8, ptr %0, i64 168
  %49 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP11ggml_tensorSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %48, i64 noundef 1) #4
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = tail call ptr @ggml_add_inplace(ptr noundef %1, ptr noundef %47, ptr noundef %50)
  %52 = tail call ptr @ggml_cpy(ptr noundef %1, ptr noundef %51, ptr noundef %47)
  tail call void @ggml_build_forward_expand(ptr noundef %2, ptr noundef %52)
  tail call void @ggml_build_forward_expand(ptr noundef %2, ptr noundef %23)
  %53 = getelementptr inbounds i8, ptr %0, i64 192
  %54 = load ptr, ptr %53, align 8, !tbaa !18
  %55 = getelementptr inbounds i8, ptr %54, i64 16
  %56 = load i64, ptr %55, align 8, !tbaa !14
  %57 = getelementptr inbounds i8, ptr %54, i64 48
  %58 = load i64, ptr %57, align 8, !tbaa !14
  %59 = tail call ptr @ggml_view_3d(ptr noundef %1, ptr noundef %54, i64 noundef 1, i64 noundef 1, i64 noundef %56, i64 noundef %58, i64 noundef %58, i64 noundef 0)
  %60 = tail call ptr @ggml_cont(ptr noundef %1, ptr noundef %59)
  %61 = tail call noundef i32 @_ZNK11sam_hparams10n_img_embdEv(ptr noundef nonnull align 4 dereferenceable(52) %0)
  %62 = sext i32 %61 to i64
  %63 = tail call noundef i32 @_ZNK11sam_hparams10n_img_embdEv(ptr noundef nonnull align 4 dereferenceable(52) %0)
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %0, i64 12
  %66 = load i32, ptr %65, align 4, !tbaa !19
  %67 = sext i32 %66 to i64
  %68 = tail call ptr @ggml_new_tensor_3d(ptr noundef %1, i32 noundef 0, i64 noundef %62, i64 noundef %64, i64 noundef %67)
  %69 = tail call ptr @ggml_repeat(ptr noundef %1, ptr noundef %60, ptr noundef %68)
  tail call void @ggml_build_forward_expand(ptr noundef %2, ptr noundef %69)
  call void @_ZN21prompt_encoder_resultC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  %.fca.0.insert = insertvalue { ptr, ptr } poison, ptr %23, 0
  %.fca.1.insert = insertvalue { ptr, ptr } %.fca.0.insert, ptr %69, 1
  ret { ptr, ptr } %.fca.1.insert
}

declare ptr @ggml_view_2d(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP11ggml_tensorSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN21prompt_encoder_resultC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

attributes #0 = { mustprogress 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 = { mustprogress 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 #3 = { inlinehint mustprogress 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 }

!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 0}
!6 = !{!"_ZTS18sam_encoder_prompt", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIP11ggml_tensorSaIS1_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIP11ggml_tensorSaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIP11ggml_tensorSaIS1_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIP11ggml_tensorSaIS1_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!6, !7, i64 8}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !7, i64 40}
!19 = !{!20, !21, i64 12}
!20 = !{!"_ZTS11sam_hparams", !21, i64 0, !21, i64 4, !21, i64 8, !21, i64 12, !21, i64 16, !21, i64 20, !21, i64 24, !22, i64 28, !22, i64 32, !22, i64 36, !22, i64 40, !22, i64 44, !22, i64 48}
!21 = !{!"int", !8, i64 0}
!22 = !{!"float", !8, i64 0}


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