; LLVM IR from tsotchke/quantum_geometric_tensor :: tests (test_quantum_geometric_tensor_init)

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

@.str.25 = external hidden unnamed_addr constant [44 x i8], align 1
@__const.test_geometric_tensor_init.dims_1d = external hidden unnamed_addr constant [1 x i64], align 8
@__const.test_geometric_tensor_init.dims_2d = external hidden unnamed_addr constant [2 x i64], align 16
@__const.test_geometric_tensor_init.dims_2d_large = external hidden unnamed_addr constant [2 x i64], align 16
@__const.test_geometric_tensor_init.dims_3d = external hidden unnamed_addr constant [3 x i64], align 16
@__const.test_geometric_tensor_init.dims_4d = external hidden unnamed_addr constant [4 x i64], align 16
@__const.test_geometric_tensor_init.dims_mixed = external hidden unnamed_addr constant [3 x i64], align 16
@.str.26 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @test_tensor_config(ptr noundef) #0

declare i32 @printf(ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_geometric_tensor_init() #0 {
  %1 = alloca [1 x i64], align 8
  %2 = alloca [2 x i64], align 16
  %3 = alloca [2 x i64], align 16
  %4 = alloca [3 x i64], align 16
  %5 = alloca [4 x i64], align 16
  %6 = alloca [3 x i64], align 16
  %7 = alloca [6 x %struct.tensor_test_config_t], align 16
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.25)
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %1, ptr align 8 @__const.test_geometric_tensor_init.dims_1d, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_geometric_tensor_init.dims_2d, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %3, ptr align 16 @__const.test_geometric_tensor_init.dims_2d_large, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.test_geometric_tensor_init.dims_3d, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %5, ptr align 16 @__const.test_geometric_tensor_init.dims_4d, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 @__const.test_geometric_tensor_init.dims_mixed, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 192, ptr %7) #4
  %11 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i32 0, i32 0
  %12 = getelementptr inbounds [1 x i64], ptr %1, i64 0, i64 0
  store ptr %12, ptr %11, align 16, !tbaa !5
  %13 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i32 0, i32 1
  store i64 1, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i32 0, i32 2
  store i32 1, ptr %14, align 16, !tbaa !13
  %15 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i32 0, i32 3
  store ptr @.str.26, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i64 1
  %17 = getelementptr inbounds %struct.tensor_test_config_t, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds [2 x i64], ptr %2, i64 0, i64 0
  store ptr %18, ptr %17, align 16, !tbaa !5
  %19 = getelementptr inbounds %struct.tensor_test_config_t, ptr %16, i32 0, i32 1
  store i64 2, ptr %19, align 8, !tbaa !12
  %20 = getelementptr inbounds %struct.tensor_test_config_t, ptr %16, i32 0, i32 2
  store i32 6, ptr %20, align 16, !tbaa !13
  %21 = getelementptr inbounds %struct.tensor_test_config_t, ptr %16, i32 0, i32 3
  store ptr @.str.27, ptr %21, align 8, !tbaa !14
  %22 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i64 2
  %23 = getelementptr inbounds %struct.tensor_test_config_t, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds [2 x i64], ptr %3, i64 0, i64 0
  store ptr %24, ptr %23, align 16, !tbaa !5
  %25 = getelementptr inbounds %struct.tensor_test_config_t, ptr %22, i32 0, i32 1
  store i64 2, ptr %25, align 8, !tbaa !12
  %26 = getelementptr inbounds %struct.tensor_test_config_t, ptr %22, i32 0, i32 2
  store i32 5, ptr %26, align 16, !tbaa !13
  %27 = getelementptr inbounds %struct.tensor_test_config_t, ptr %22, i32 0, i32 3
  store ptr @.str.28, ptr %27, align 8, !tbaa !14
  %28 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i64 3
  %29 = getelementptr inbounds %struct.tensor_test_config_t, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds [3 x i64], ptr %4, i64 0, i64 0
  store ptr %30, ptr %29, align 16, !tbaa !5
  %31 = getelementptr inbounds %struct.tensor_test_config_t, ptr %28, i32 0, i32 1
  store i64 3, ptr %31, align 8, !tbaa !12
  %32 = getelementptr inbounds %struct.tensor_test_config_t, ptr %28, i32 0, i32 2
  store i32 7, ptr %32, align 16, !tbaa !13
  %33 = getelementptr inbounds %struct.tensor_test_config_t, ptr %28, i32 0, i32 3
  store ptr @.str.29, ptr %33, align 8, !tbaa !14
  %34 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i64 4
  %35 = getelementptr inbounds %struct.tensor_test_config_t, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds [4 x i64], ptr %5, i64 0, i64 0
  store ptr %36, ptr %35, align 16, !tbaa !5
  %37 = getelementptr inbounds %struct.tensor_test_config_t, ptr %34, i32 0, i32 1
  store i64 4, ptr %37, align 8, !tbaa !12
  %38 = getelementptr inbounds %struct.tensor_test_config_t, ptr %34, i32 0, i32 2
  store i32 8, ptr %38, align 16, !tbaa !13
  %39 = getelementptr inbounds %struct.tensor_test_config_t, ptr %34, i32 0, i32 3
  store ptr @.str.30, ptr %39, align 8, !tbaa !14
  %40 = getelementptr inbounds %struct.tensor_test_config_t, ptr %7, i64 5
  %41 = getelementptr inbounds %struct.tensor_test_config_t, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds [3 x i64], ptr %6, i64 0, i64 0
  store ptr %42, ptr %41, align 16, !tbaa !5
  %43 = getelementptr inbounds %struct.tensor_test_config_t, ptr %40, i32 0, i32 1
  store i64 3, ptr %43, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.tensor_test_config_t, ptr %40, i32 0, i32 2
  store i32 4, ptr %44, align 16, !tbaa !13
  %45 = getelementptr inbounds %struct.tensor_test_config_t, ptr %40, i32 0, i32 3
  store ptr @.str.31, ptr %45, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 6, ptr %8, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !15
  br label %46

46:                                               ; preds = %54, %0
  %47 = load i64, ptr %9, align 8, !tbaa !15
  %48 = load i64, ptr %8, align 8, !tbaa !15
  %49 = icmp ult i64 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %57

51:                                               ; preds = %46
  %52 = load i64, ptr %9, align 8, !tbaa !15
  %53 = getelementptr inbounds [6 x %struct.tensor_test_config_t], ptr %7, i64 0, i64 %52
  call void @test_tensor_config(ptr noundef %53)
  br label %54

54:                                               ; preds = %51
  %55 = load i64, ptr %9, align 8, !tbaa !15
  %56 = add i64 %55, 1
  store i64 %56, ptr %9, align 8, !tbaa !15
  br label %46, !llvm.loop !16

57:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 192, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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" }
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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !7, i64 24}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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

@.str.25 = external hidden unnamed_addr constant [44 x i8], align 1
@__const.test_geometric_tensor_init.dims_1d = external hidden unnamed_addr constant [1 x i64], align 8
@__const.test_geometric_tensor_init.dims_2d = external hidden unnamed_addr constant [2 x i64], align 16
@__const.test_geometric_tensor_init.dims_2d_large = external hidden unnamed_addr constant [2 x i64], align 16
@__const.test_geometric_tensor_init.dims_3d = external hidden unnamed_addr constant [3 x i64], align 16
@__const.test_geometric_tensor_init.dims_4d = external hidden unnamed_addr constant [4 x i64], align 16
@__const.test_geometric_tensor_init.dims_mixed = external hidden unnamed_addr constant [3 x i64], align 16
@.str.26 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [17 x i8], align 1

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_geometric_tensor_init() local_unnamed_addr #0 {
  %1 = alloca [1 x i64], align 8
  %2 = alloca [2 x i64], align 16
  %3 = alloca [2 x i64], align 16
  %4 = alloca [3 x i64], align 16
  %5 = alloca [4 x i64], align 16
  %6 = alloca [3 x i64], align 16
  %7 = alloca [6 x %struct.tensor_test_config_t], align 16
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.25)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %9 = load i64, ptr @__const.test_geometric_tensor_init.dims_1d, align 8
  store i64 %9, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %2, ptr noundef nonnull align 16 dereferenceable(16) @__const.test_geometric_tensor_init.dims_2d, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %3, ptr noundef nonnull align 16 dereferenceable(16) @__const.test_geometric_tensor_init.dims_2d_large, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %4, ptr noundef nonnull align 16 dereferenceable(24) @__const.test_geometric_tensor_init.dims_3d, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %5, ptr noundef nonnull align 16 dereferenceable(32) @__const.test_geometric_tensor_init.dims_4d, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %6, ptr noundef nonnull align 16 dereferenceable(24) @__const.test_geometric_tensor_init.dims_mixed, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %7) #4
  store ptr %1, ptr %7, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %7, i64 8
  store i64 1, ptr %10, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 1, ptr %11, align 16, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr @.str.26, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr %2, ptr %13, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %7, i64 40
  store i64 2, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %7, i64 48
  store i32 6, ptr %15, align 16, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %7, i64 56
  store ptr @.str.27, ptr %16, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %7, i64 64
  store ptr %3, ptr %17, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %7, i64 72
  store i64 2, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %7, i64 80
  store i32 5, ptr %19, align 16, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %7, i64 88
  store ptr @.str.28, ptr %20, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %7, i64 96
  store ptr %4, ptr %21, align 16, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %7, i64 104
  store i64 3, ptr %22, align 8, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %7, i64 112
  store i32 7, ptr %23, align 16, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %7, i64 120
  store ptr @.str.29, ptr %24, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %7, i64 128
  store ptr %5, ptr %25, align 16, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %7, i64 136
  store i64 4, ptr %26, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %7, i64 144
  store i32 8, ptr %27, align 16, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %7, i64 152
  store ptr @.str.30, ptr %28, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %7, i64 160
  store ptr %6, ptr %29, align 16, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %7, i64 168
  store i64 3, ptr %30, align 8, !tbaa !12
  %31 = getelementptr inbounds i8, ptr %7, i64 176
  store i32 4, ptr %31, align 16, !tbaa !13
  %32 = getelementptr inbounds i8, ptr %7, i64 184
  store ptr @.str.31, ptr %32, align 8, !tbaa !14
  call void @test_tensor_config(ptr noundef nonnull %7)
  call void @test_tensor_config(ptr noundef nonnull %13)
  call void @test_tensor_config(ptr noundef nonnull %17)
  call void @test_tensor_config(ptr noundef nonnull %21)
  call void @test_tensor_config(ptr noundef nonnull %25)
  call void @test_tensor_config(ptr noundef nonnull %29)
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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" }
attributes #1 = { nofree nounwind "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !7, i64 24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass