; LLVM IR from ggml-org/ggml :: src (ggml)

; 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.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.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ggml_new_tensor(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @ggml_concat(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca [4 x i64], align 16
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = icmp sge i32 %12, 0
  br i1 %13, label %14, label %17

14:                                               ; preds = %4
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 4
  br i1 %16, label %18, label %17

17:                                               ; preds = %14, %4
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 2302, ptr noundef @.str.13, ptr noundef @.str.31) #3
  unreachable

18:                                               ; preds = %14
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ggml_tensor, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ggml_tensor, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %18
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 2303, ptr noundef @.str.13, ptr noundef @.str.32) #3
  unreachable

27:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %78, %27
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %81

32:                                               ; preds = %28
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = icmp eq i32 %33, %34
  br i1 %35, label %36, label %53

36:                                               ; preds = %32
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ggml_tensor, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [4 x i64], ptr %38, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !14
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ggml_tensor, ptr %43, i32 0, i32 2
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [4 x i64], ptr %44, i64 0, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !14
  %49 = add nsw i64 %42, %48
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 %51
  store i64 %49, ptr %52, align 8, !tbaa !14
  br label %78

53:                                               ; preds = %32
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ggml_tensor, ptr %54, i32 0, i32 2
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [4 x i64], ptr %55, i64 0, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !14
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ggml_tensor, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %10, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [4 x i64], ptr %61, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !14
  %66 = icmp eq i64 %59, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %53
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str.12, i32 noundef 2311, ptr noundef @.str.13, ptr noundef @.str.33) #3
  unreachable

68:                                               ; preds = %53
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ggml_tensor, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [4 x i64], ptr %70, i64 0, i64 %72
  %74 = load i64, ptr %73, align 8, !tbaa !14
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 %76
  store i64 %74, ptr %77, align 8, !tbaa !14
  br label %78

78:                                               ; preds = %68, %36
  %79 = load i32, ptr %10, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %10, align 4, !tbaa !9
  br label %28, !llvm.loop !15

81:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.ggml_tensor, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !11
  %86 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  %87 = call ptr @ggml_new_tensor(ptr noundef %82, i32 noundef %85, i32 noundef 4, ptr noundef %86)
  store ptr %87, ptr %11, align 8, !tbaa !5
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load i32, ptr %8, align 4, !tbaa !9
  call void @ggml_set_op_params_i32(ptr noundef %88, i32 noundef 0, i32 noundef %89)
  %90 = load ptr, ptr %11, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ggml_tensor, ptr %90, i32 0, i32 4
  store i32 20, ptr %91, align 8, !tbaa !17
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.ggml_tensor, ptr %93, i32 0, i32 7
  %95 = getelementptr inbounds [10 x ptr], ptr %94, i64 0, i64 0
  store ptr %92, ptr %95, align 8, !tbaa !5
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.ggml_tensor, ptr %97, i32 0, i32 7
  %99 = getelementptr inbounds [10 x ptr], ptr %98, i64 0, i64 1
  store ptr %96, ptr %99, align 8, !tbaa !5
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #4
  ret ptr %100
}

; Function Attrs: nounwind uwtable
declare hidden void @ggml_set_op_params_i32(ptr noundef, i32 noundef, i32 noundef) #2

attributes #0 = { noreturn 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 = { 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 = { noreturn }
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, !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, !10, i64 0}
!12 = !{!"ggml_tensor", !10, i64 0, !6, i64 8, !7, i64 16, !7, i64 48, !10, i64 80, !7, i64 84, !10, i64 148, !7, i64 152, !6, i64 232, !13, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 80}


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

@.str.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @ggml_abort(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ggml_new_tensor(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @ggml_concat(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #2 {
  %5 = alloca [4 x i64], align 16
  %or.cond = icmp ult i32 %3, 4
  br i1 %or.cond, label %7, label %6

6:                                                ; preds = %4
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 2302, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.31) #3
  unreachable

7:                                                ; preds = %4
  %8 = load i32, ptr %1, align 8, !tbaa !5
  %9 = load i32, ptr %2, align 8, !tbaa !5
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 2303, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.32) #3
  unreachable

12:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #4
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = getelementptr inbounds i8, ptr %2, i64 16
  %15 = icmp eq i32 %3, 0
  %16 = load i64, ptr %13, align 8, !tbaa !12
  %17 = load i64, ptr %14, align 8, !tbaa !12
  br i1 %15, label %.thread36, label %18

18:                                               ; preds = %12
  %19 = icmp eq i64 %16, %17
  br i1 %19, label %21, label %20

20:                                               ; preds = %.thread36, %55, %40, %27, %18
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str.12, i32 noundef 2311, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.33) #3
  unreachable

21:                                               ; preds = %18
  store i64 %16, ptr %5, align 16, !tbaa !12
  %22 = icmp eq i32 %3, 1
  %23 = getelementptr inbounds i8, ptr %1, i64 24
  %24 = load i64, ptr %23, align 8, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %2, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !12
  br i1 %22, label %.thread35, label %27

27:                                               ; preds = %21
  %28 = icmp eq i64 %24, %26
  br i1 %28, label %36, label %20

.thread36:                                        ; preds = %12
  %29 = add nsw i64 %17, %16
  store i64 %29, ptr %5, align 16, !tbaa !12
  %30 = getelementptr inbounds i8, ptr %1, i64 24
  %31 = load i64, ptr %30, align 8, !tbaa !12
  %32 = getelementptr inbounds i8, ptr %2, i64 24
  %33 = load i64, ptr %32, align 8, !tbaa !12
  %34 = icmp eq i64 %31, %33
  br i1 %34, label %.sink.split, label %20

.thread35:                                        ; preds = %21
  %35 = add nsw i64 %26, %24
  br label %.sink.split

36:                                               ; preds = %27
  %37 = getelementptr inbounds i8, ptr %5, i64 8
  store i64 %24, ptr %37, align 8, !tbaa !12
  %38 = icmp eq i32 %3, 2
  br i1 %38, label %.thread38, label %40

.sink.split:                                      ; preds = %.thread36, %.thread35
  %.sink = phi i64 [ %35, %.thread35 ], [ %31, %.thread36 ]
  %39 = getelementptr inbounds i8, ptr %5, i64 8
  store i64 %.sink, ptr %39, align 8, !tbaa !12
  br label %40

40:                                               ; preds = %.sink.split, %36
  %41 = getelementptr inbounds i8, ptr %1, i64 32
  %42 = load i64, ptr %41, align 8, !tbaa !12
  %43 = getelementptr inbounds i8, ptr %2, i64 32
  %44 = load i64, ptr %43, align 8, !tbaa !12
  %45 = icmp eq i64 %42, %44
  br i1 %45, label %52, label %20

.thread38:                                        ; preds = %36
  %46 = getelementptr inbounds i8, ptr %1, i64 32
  %47 = load i64, ptr %46, align 8, !tbaa !12
  %48 = getelementptr inbounds i8, ptr %2, i64 32
  %49 = load i64, ptr %48, align 8, !tbaa !12
  %50 = add nsw i64 %49, %47
  %51 = getelementptr inbounds i8, ptr %5, i64 16
  store i64 %50, ptr %51, align 16, !tbaa !12
  br label %55

52:                                               ; preds = %40
  %53 = getelementptr inbounds i8, ptr %5, i64 16
  store i64 %42, ptr %53, align 16, !tbaa !12
  %54 = icmp eq i32 %3, 3
  br i1 %54, label %61, label %55

55:                                               ; preds = %.thread38, %52
  %56 = getelementptr inbounds i8, ptr %1, i64 40
  %57 = load i64, ptr %56, align 8, !tbaa !12
  %58 = getelementptr inbounds i8, ptr %2, i64 40
  %59 = load i64, ptr %58, align 8, !tbaa !12
  %60 = icmp eq i64 %57, %59
  br i1 %60, label %67, label %20

61:                                               ; preds = %52
  %62 = getelementptr inbounds i8, ptr %1, i64 40
  %63 = load i64, ptr %62, align 8, !tbaa !12
  %64 = getelementptr inbounds i8, ptr %2, i64 40
  %65 = load i64, ptr %64, align 8, !tbaa !12
  %66 = add nsw i64 %65, %63
  br label %67

67:                                               ; preds = %55, %61
  %.sink40 = phi i64 [ %66, %61 ], [ %57, %55 ]
  %68 = getelementptr inbounds i8, ptr %5, i64 24
  store i64 %.sink40, ptr %68, align 8, !tbaa !12
  %69 = call ptr @ggml_new_tensor(ptr noundef %0, i32 noundef %8, i32 noundef 4, ptr noundef nonnull %5)
  call void @ggml_set_op_params_i32(ptr noundef %69, i32 noundef 0, i32 noundef %3)
  %70 = getelementptr inbounds i8, ptr %69, i64 80
  store i32 20, ptr %70, align 8, !tbaa !13
  %71 = getelementptr inbounds i8, ptr %69, i64 152
  store ptr %1, ptr %71, align 8, !tbaa !14
  %72 = getelementptr inbounds i8, ptr %69, i64 160
  store ptr %2, ptr %72, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #4
  ret ptr %69
}

; Function Attrs: nounwind uwtable
declare hidden void @ggml_set_op_params_i32(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { noreturn 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { noreturn }
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 = !{!"ggml_tensor", !7, i64 0, !10, i64 8, !8, i64 16, !8, i64 48, !7, i64 80, !8, i64 84, !7, i64 148, !8, i64 152, !10, i64 232, !11, i64 240, !10, i64 248, !8, i64 256, !10, i64 320, !8, i64 328}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !7, i64 80}
!14 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass