; LLVM IR from tsotchke/quantum_geometric_tensor :: src/quantum_geometric/core (quantum_geometric_core)

; 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.Block = type { i64, i32, i8, i16, ptr, ptr, [40 x i8], ptr, [48 x i8] }

@is_initialized = external hidden global i8, align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [51 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: 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) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @get_block(ptr noundef) #2

declare void @geometric_log_error(ptr noundef, ...) #3

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

13:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  br label %77

14:                                               ; preds = %3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i32 -1, ptr %4, align 4
  br label %77

18:                                               ; preds = %14
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = icmp ugt i64 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  store i32 -1, ptr %4, align 4
  br label %77

22:                                               ; preds = %18
  %23 = load i8, ptr @is_initialized, align 1, !tbaa !11, !range !13, !noundef !14
  %24 = trunc i8 %23 to i1
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 -4, ptr %4, align 4
  br label %77

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call ptr @get_block(ptr noundef %27)
  store ptr %28, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call ptr @get_block(ptr noundef %29)
  store ptr %30, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %36

33:                                               ; preds = %26
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %33, %26
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.4)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %76

37:                                               ; preds = %33
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.Block, ptr %38, i32 0, i32 2
  %40 = load i8, ptr %39, align 4, !tbaa !15, !range !13, !noundef !14
  %41 = trunc i8 %40 to i1
  br i1 %41, label %47, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Block, ptr %43, i32 0, i32 2
  %45 = load i8, ptr %44, align 4, !tbaa !15, !range !13, !noundef !14
  %46 = trunc i8 %45 to i1
  br i1 %46, label %47, label %48

47:                                               ; preds = %42, %37
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.5)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %76

48:                                               ; preds = %42
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Block, ptr %49, i32 0, i32 0
  %51 = load i64, ptr %50, align 64, !tbaa !19
  %52 = load i64, ptr %7, align 8, !tbaa !9
  %53 = icmp ult i64 %51, %52
  br i1 %53, label %60, label %54

54:                                               ; preds = %48
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Block, ptr %55, i32 0, i32 0
  %57 = load i64, ptr %56, align 64, !tbaa !19
  %58 = load i64, ptr %7, align 8, !tbaa !9
  %59 = icmp ult i64 %57, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %54, %48
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.6)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %76

61:                                               ; preds = %54
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = ptrtoint ptr %62 to i64
  %64 = and i64 %63, 63
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %71, label %66

66:                                               ; preds = %61
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = ptrtoint ptr %67 to i64
  %69 = and i64 %68, 63
  %70 = icmp ne i64 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %66, %61
  call void (ptr, ...) @geometric_log_error(ptr noundef @.str.7)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %76

72:                                               ; preds = %66
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %73, ptr align 1 %74, i64 %75, i1 false)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %76

76:                                               ; preds = %72, %71, %60, %47, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %77

77:                                               ; preds = %76, %25, %21, %17, %13
  %78 = load i32, ptr %4, align 4
  ret i32 %78
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { "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, !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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !12, i64 12}
!16 = !{!"Block", !10, i64 0, !17, i64 8, !12, i64 12, !18, i64 14, !6, i64 16, !6, i64 24, !7, i64 32, !6, i64 72}
!17 = !{!"int", !7, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!16, !10, 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"

@is_initialized = external hidden local_unnamed_addr global i8, align 1
@.str.4 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [51 x i8], align 1

; 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) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @get_block(ptr noundef) local_unnamed_addr #1

declare void @geometric_log_error(ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -4, 1) i32 @geometric_core_memcpy(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond28 = or i1 %4, %5
  %.not = icmp eq i64 %2, 0
  %or.cond29 = or i1 %or.cond28, %.not
  br i1 %or.cond29, label %38, label %6

6:                                                ; preds = %3
  %7 = load i8, ptr @is_initialized, align 1, !tbaa !5, !range !9, !noundef !10
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %9, label %38

9:                                                ; preds = %6
  %10 = tail call ptr @get_block(ptr noundef nonnull %1)
  %11 = tail call ptr @get_block(ptr noundef nonnull %0)
  %12 = icmp ne ptr %10, null
  %13 = icmp ne ptr %11, null
  %or.cond = select i1 %12, i1 %13, i1 false
  br i1 %or.cond, label %15, label %14

14:                                               ; preds = %9
  tail call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.4) #3
  br label %38

15:                                               ; preds = %9
  %16 = getelementptr inbounds i8, ptr %10, i64 12
  %17 = load i8, ptr %16, align 4, !tbaa !11, !range !9, !noundef !10
  %18 = trunc nuw i8 %17 to i1
  br i1 %18, label %23, label %19

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %11, i64 12
  %21 = load i8, ptr %20, align 4, !tbaa !11, !range !9, !noundef !10
  %22 = trunc nuw i8 %21 to i1
  br i1 %22, label %23, label %24

23:                                               ; preds = %19, %15
  tail call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.5) #3
  br label %38

24:                                               ; preds = %19
  %25 = load i64, ptr %10, align 64, !tbaa !17
  %26 = icmp ult i64 %25, %2
  br i1 %26, label %30, label %27

27:                                               ; preds = %24
  %28 = load i64, ptr %11, align 64, !tbaa !17
  %29 = icmp ult i64 %28, %2
  br i1 %29, label %30, label %31

30:                                               ; preds = %27, %24
  tail call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.6) #3
  br label %38

31:                                               ; preds = %27
  %32 = ptrtoint ptr %0 to i64
  %33 = ptrtoint ptr %1 to i64
  %34 = or i64 %33, %32
  %35 = and i64 %34, 63
  %or.cond27 = icmp eq i64 %35, 0
  br i1 %or.cond27, label %37, label %36

36:                                               ; preds = %31
  tail call void (ptr, ...) @geometric_log_error(ptr noundef nonnull @.str.7) #3
  br label %38

37:                                               ; preds = %31
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %0, ptr nonnull align 1 %1, i64 %2, i1 false)
  br label %38

38:                                               ; preds = %14, %23, %30, %36, %37, %6, %3
  %.1 = phi i32 [ -1, %3 ], [ -4, %6 ], [ -1, %23 ], [ -1, %30 ], [ -1, %36 ], [ 0, %37 ], [ -1, %14 ]
  ret i32 %.1
}

attributes #0 = { mustprogress nocallback nofree 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 = { "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 = { 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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !6, i64 12}
!12 = !{!"Block", !13, i64 0, !14, i64 8, !6, i64 12, !15, i64 14, !16, i64 16, !16, i64 24, !7, i64 32, !16, i64 72}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!12, !13, i64 0}


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