; LLVM IR from ggml-org/ggml :: tests (test-dup)

; 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 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare i64 @ggml_nelements(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @dup_to(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.ggml_tensor, ptr %5, i32 0, i32 4
  %7 = load i32, ptr %6, align 8, !tbaa !9
  %8 = icmp eq i32 %7, 35
  br i1 %8, label %10, label %9

9:                                                ; preds = %2
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 15, ptr noundef @.str.1, ptr noundef @.str.3) #3
  unreachable

10:                                               ; preds = %2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call i64 @ggml_nelements(ptr noundef %11)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call i64 @ggml_nelements(ptr noundef %13)
  %15 = icmp eq i64 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef @.str, i32 noundef 16, ptr noundef @.str.1, ptr noundef @.str.4) #3
  unreachable

17:                                               ; preds = %10
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ggml_tensor, ptr %18, i32 0, i32 4
  store i32 1, ptr %19, align 8, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ggml_tensor, ptr %21, i32 0, i32 7
  %23 = getelementptr inbounds [10 x ptr], ptr %22, i64 0, i64 0
  store ptr %20, ptr %23, align 8, !tbaa !5
  ret void
}

attributes #0 = { noreturn "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 = { 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 }

!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, !11, i64 80}
!10 = !{!"ggml_tensor", !11, i64 0, !6, i64 8, !7, i64 16, !7, i64 48, !11, i64 80, !7, i64 84, !11, i64 148, !7, i64 152, !6, i64 232, !12, i64 240, !6, i64 248, !7, i64 256, !6, i64 320, !7, i64 328}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, 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"

@.str = external hidden unnamed_addr constant [64 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare i64 @ggml_nelements(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @dup_to(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 80
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 35
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 15, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.3) #3
  unreachable

7:                                                ; preds = %2
  %8 = tail call i64 @ggml_nelements(ptr noundef %0) #4
  %9 = tail call i64 @ggml_nelements(ptr noundef nonnull %1) #4
  %10 = icmp eq i64 %8, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %7
  tail call void (ptr, i32, ptr, ...) @ggml_abort(ptr noundef nonnull @.str, i32 noundef 16, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.4) #3
  unreachable

12:                                               ; preds = %7
  store i32 1, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 152
  store ptr %0, ptr %13, align 8, !tbaa !12
  ret void
}

attributes #0 = { noreturn "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 = { 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 nounwind }
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 80}
!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 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass