; LLVM IR from maksimandrianov/cdcontainers :: src (circular-array)

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

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.cdc_circular_array_swap = external hidden unnamed_addr constant [69 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, 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
define dso_local void @cdc_circular_array_swap(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  br label %15

14:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 453, ptr noundef @__PRETTY_FUNCTION__.cdc_circular_array_swap) #3
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 454, ptr noundef @__PRETTY_FUNCTION__.cdc_circular_array_swap) #3
  unreachable

20:                                               ; preds = %18
  br label %21

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.cdc_circular_array, ptr %22, i32 0, i32 3
  %24 = load i64, ptr %23, align 8, !tbaa !9
  store i64 %24, ptr %5, align 8, !tbaa !12
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.cdc_circular_array, ptr %25, i32 0, i32 3
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.cdc_circular_array, ptr %28, i32 0, i32 3
  store i64 %27, ptr %29, align 8, !tbaa !9
  %30 = load i64, ptr %5, align 8, !tbaa !12
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.cdc_circular_array, ptr %31, i32 0, i32 3
  store i64 %30, ptr %32, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %33

33:                                               ; preds = %21
  br label %34

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.cdc_circular_array, ptr %35, i32 0, i32 4
  %37 = load i64, ptr %36, align 8, !tbaa !13
  store i64 %37, ptr %6, align 8, !tbaa !12
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.cdc_circular_array, ptr %38, i32 0, i32 4
  %40 = load i64, ptr %39, align 8, !tbaa !13
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.cdc_circular_array, ptr %41, i32 0, i32 4
  store i64 %40, ptr %42, align 8, !tbaa !13
  %43 = load i64, ptr %6, align 8, !tbaa !12
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.cdc_circular_array, ptr %44, i32 0, i32 4
  store i64 %43, ptr %45, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %46

46:                                               ; preds = %34
  br label %47

47:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.cdc_circular_array, ptr %48, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !14
  store i64 %50, ptr %7, align 8, !tbaa !12
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.cdc_circular_array, ptr %51, i32 0, i32 1
  %53 = load i64, ptr %52, align 8, !tbaa !14
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.cdc_circular_array, ptr %54, i32 0, i32 1
  store i64 %53, ptr %55, align 8, !tbaa !14
  %56 = load i64, ptr %7, align 8, !tbaa !12
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.cdc_circular_array, ptr %57, i32 0, i32 1
  store i64 %56, ptr %58, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %59

59:                                               ; preds = %47
  br label %60

60:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.cdc_circular_array, ptr %61, i32 0, i32 2
  %63 = load i64, ptr %62, align 8, !tbaa !15
  store i64 %63, ptr %8, align 8, !tbaa !12
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.cdc_circular_array, ptr %64, i32 0, i32 2
  %66 = load i64, ptr %65, align 8, !tbaa !15
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.cdc_circular_array, ptr %67, i32 0, i32 2
  store i64 %66, ptr %68, align 8, !tbaa !15
  %69 = load i64, ptr %8, align 8, !tbaa !12
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.cdc_circular_array, ptr %70, i32 0, i32 2
  store i64 %69, ptr %71, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %72

72:                                               ; preds = %60
  br label %73

73:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.cdc_circular_array, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !16
  store ptr %76, ptr %9, align 8, !tbaa !5
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.cdc_circular_array, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !16
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.cdc_circular_array, ptr %80, i32 0, i32 0
  store ptr %79, ptr %81, align 8, !tbaa !16
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.cdc_circular_array, ptr %83, i32 0, i32 0
  store ptr %82, ptr %84, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %85

85:                                               ; preds = %73
  br label %86

86:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.cdc_circular_array, ptr %87, i32 0, i32 5
  %89 = load ptr, ptr %88, align 8, !tbaa !17
  store ptr %89, ptr %10, align 8, !tbaa !5
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.cdc_circular_array, ptr %90, i32 0, i32 5
  %92 = load ptr, ptr %91, align 8, !tbaa !17
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.cdc_circular_array, ptr %93, i32 0, i32 5
  store ptr %92, ptr %94, align 8, !tbaa !17
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.cdc_circular_array, ptr %96, i32 0, i32 5
  store ptr %95, ptr %97, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %98

98:                                               ; preds = %86
  ret void
}

attributes #0 = { noreturn 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 #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 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 24}
!10 = !{!"cdc_circular_array", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !6, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 16}
!16 = !{!10, !6, i64 0}
!17 = !{!10, !6, i64 40}


; 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.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.cdc_circular_array_swap = external hidden unnamed_addr constant [69 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @cdc_circular_array_swap(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

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

4:                                                ; preds = %2
  %.not32 = icmp eq ptr %1, null
  br i1 %.not32, label %5, label %6

5:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 454, ptr noundef nonnull @__PRETTY_FUNCTION__.cdc_circular_array_swap) #2
  unreachable

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = getelementptr inbounds i8, ptr %1, i64 24
  %9 = load <2 x i64>, ptr %8, align 8, !tbaa !5
  %10 = load <2 x i64>, ptr %7, align 8, !tbaa !5
  store <2 x i64> %9, ptr %7, align 8, !tbaa !5
  store <2 x i64> %10, ptr %8, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load <2 x i64>, ptr %12, align 8, !tbaa !5
  %14 = load <2 x i64>, ptr %11, align 8, !tbaa !5
  store <2 x i64> %13, ptr %11, align 8, !tbaa !5
  store <2 x i64> %14, ptr %12, align 8, !tbaa !5
  %15 = load ptr, ptr %0, align 8, !tbaa !9
  %16 = load ptr, ptr %1, align 8, !tbaa !9
  store ptr %16, ptr %0, align 8, !tbaa !9
  store ptr %15, ptr %1, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %1, i64 40
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  store ptr %20, ptr %17, align 8, !tbaa !12
  store ptr %18, ptr %19, align 8, !tbaa !12
  ret void
}

attributes #0 = { noreturn 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 #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 = { noreturn 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"cdc_circular_array", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 40}


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