; LLVM IR from cvxgrp/scs :: src/cones.ll (scs_deep_copy_cone)

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

; Function Attrs: nounwind uwtable
define dso_local void @_scs_deep_copy_cone(ptr noundef %0, ptr noundef %1) #0 {
  %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 %3, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %6, i64 88, i1 false)
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.ScsCone, ptr %7, i32 0, i32 4
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp sgt i32 %9, 1
  br i1 %10, label %11, label %52

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ScsCone, ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = sub nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = call noalias ptr @calloc(i64 noundef %16, i64 noundef 8) #3
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ScsCone, ptr %18, i32 0, i32 2
  store ptr %17, ptr %19, align 8, !tbaa !12
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ScsCone, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ScsCone, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ScsCone, ptr %26, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = sub nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = mul i64 %30, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %22, ptr align 8 %25, i64 %31, i1 false)
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ScsCone, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = call noalias ptr @calloc(i64 noundef %36, i64 noundef 8) #3
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ScsCone, ptr %38, i32 0, i32 3
  store ptr %37, ptr %39, align 8, !tbaa !13
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ScsCone, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ScsCone, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ScsCone, ptr %46, i32 0, i32 4
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = sub nsw i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = mul i64 %50, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %42, ptr align 8 %45, i64 %51, i1 false)
  br label %57

52:                                               ; preds = %2
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ScsCone, ptr %53, i32 0, i32 2
  store ptr null, ptr %54, align 8, !tbaa !12
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ScsCone, ptr %55, i32 0, i32 3
  store ptr null, ptr %56, align 8, !tbaa !13
  br label %57

57:                                               ; preds = %52, %11
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ScsCone, ptr %58, i32 0, i32 6
  %60 = load i32, ptr %59, align 8, !tbaa !14
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %62, label %81

62:                                               ; preds = %57
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ScsCone, ptr %63, i32 0, i32 6
  %65 = load i32, ptr %64, align 8, !tbaa !14
  %66 = sext i32 %65 to i64
  %67 = call noalias ptr @calloc(i64 noundef %66, i64 noundef 4) #3
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ScsCone, ptr %68, i32 0, i32 5
  store ptr %67, ptr %69, align 8, !tbaa !15
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ScsCone, ptr %70, i32 0, i32 5
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ScsCone, ptr %73, i32 0, i32 5
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ScsCone, ptr %76, i32 0, i32 6
  %78 = load i32, ptr %77, align 8, !tbaa !14
  %79 = sext i32 %78 to i64
  %80 = mul i64 %79, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %72, ptr align 4 %75, i64 %80, i1 false)
  br label %84

81:                                               ; preds = %57
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ScsCone, ptr %82, i32 0, i32 5
  store ptr null, ptr %83, align 8, !tbaa !15
  br label %84

84:                                               ; preds = %81, %62
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ScsCone, ptr %85, i32 0, i32 8
  %87 = load i32, ptr %86, align 8, !tbaa !16
  %88 = icmp sgt i32 %87, 0
  br i1 %88, label %89, label %108

89:                                               ; preds = %84
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ScsCone, ptr %90, i32 0, i32 8
  %92 = load i32, ptr %91, align 8, !tbaa !16
  %93 = sext i32 %92 to i64
  %94 = call noalias ptr @calloc(i64 noundef %93, i64 noundef 4) #3
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.ScsCone, ptr %95, i32 0, i32 7
  store ptr %94, ptr %96, align 8, !tbaa !17
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.ScsCone, ptr %97, i32 0, i32 7
  %99 = load ptr, ptr %98, align 8, !tbaa !17
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.ScsCone, ptr %100, i32 0, i32 7
  %102 = load ptr, ptr %101, align 8, !tbaa !17
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.ScsCone, ptr %103, i32 0, i32 8
  %105 = load i32, ptr %104, align 8, !tbaa !16
  %106 = sext i32 %105 to i64
  %107 = mul i64 %106, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %99, ptr align 4 %102, i64 %107, i1 false)
  br label %111

108:                                              ; preds = %84
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.ScsCone, ptr %109, i32 0, i32 7
  store ptr null, ptr %110, align 8, !tbaa !17
  br label %111

111:                                              ; preds = %108, %89
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.ScsCone, ptr %112, i32 0, i32 12
  %114 = load i32, ptr %113, align 8, !tbaa !18
  %115 = icmp sgt i32 %114, 0
  br i1 %115, label %116, label %135

116:                                              ; preds = %111
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.ScsCone, ptr %117, i32 0, i32 12
  %119 = load i32, ptr %118, align 8, !tbaa !18
  %120 = sext i32 %119 to i64
  %121 = call noalias ptr @calloc(i64 noundef %120, i64 noundef 8) #3
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.ScsCone, ptr %122, i32 0, i32 11
  store ptr %121, ptr %123, align 8, !tbaa !19
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.ScsCone, ptr %124, i32 0, i32 11
  %126 = load ptr, ptr %125, align 8, !tbaa !19
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.ScsCone, ptr %127, i32 0, i32 11
  %129 = load ptr, ptr %128, align 8, !tbaa !19
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.ScsCone, ptr %130, i32 0, i32 12
  %132 = load i32, ptr %131, align 8, !tbaa !18
  %133 = sext i32 %132 to i64
  %134 = mul i64 %133, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %126, ptr align 8 %129, i64 %134, i1 false)
  br label %138

135:                                              ; preds = %111
  %136 = load ptr, ptr %3, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.ScsCone, ptr %136, i32 0, i32 11
  store ptr null, ptr %137, align 8, !tbaa !19
  br label %138

138:                                              ; preds = %135, %116
  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) #1

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(0,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 #3 = { nounwind allocsize(0,1) }

!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 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !6, i64 72, !11, i64 80}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !11, i64 40}
!15 = !{!10, !6, i64 32}
!16 = !{!10, !11, i64 56}
!17 = !{!10, !6, i64 48}
!18 = !{!10, !11, i64 80}
!19 = !{!10, !6, i64 72}


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

; Function Attrs: mustprogress nofree nounwind willreturn uwtable
define dso_local void @_scs_deep_copy_cone(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, i64 88, i1 false)
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, 1
  br i1 %5, label %6, label %18

6:                                                ; preds = %2
  %7 = add nsw i32 %4, -1
  %8 = zext nneg i32 %7 to i64
  %9 = tail call noalias ptr @calloc(i64 noundef %8, i64 noundef 8) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %9, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = shl nuw nsw i64 %8, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %12, i64 %13, i1 false)
  %14 = tail call noalias ptr @calloc(i64 noundef %8, i64 noundef 8) #4
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %14, ptr %15, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %17, i64 %13, i1 false)
  br label %20

18:                                               ; preds = %2
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  br label %20

20:                                               ; preds = %18, %6
  %21 = getelementptr inbounds i8, ptr %1, i64 40
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %31

24:                                               ; preds = %20
  %25 = zext nneg i32 %22 to i64
  %26 = tail call noalias ptr @calloc(i64 noundef %25, i64 noundef 4) #4
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %26, ptr %27, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %1, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = shl nuw nsw i64 %25, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %29, i64 %30, i1 false)
  br label %33

31:                                               ; preds = %20
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr null, ptr %32, align 8, !tbaa !14
  br label %33

33:                                               ; preds = %31, %24
  %34 = getelementptr inbounds i8, ptr %1, i64 56
  %35 = load i32, ptr %34, align 8, !tbaa !15
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %37, label %44

37:                                               ; preds = %33
  %38 = zext nneg i32 %35 to i64
  %39 = tail call noalias ptr @calloc(i64 noundef %38, i64 noundef 4) #4
  %40 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %39, ptr %40, align 8, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %1, i64 48
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = shl nuw nsw i64 %38, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %39, ptr align 4 %42, i64 %43, i1 false)
  br label %46

44:                                               ; preds = %33
  %45 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr null, ptr %45, align 8, !tbaa !16
  br label %46

46:                                               ; preds = %44, %37
  %47 = getelementptr inbounds i8, ptr %1, i64 80
  %48 = load i32, ptr %47, align 8, !tbaa !17
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %50, label %57

50:                                               ; preds = %46
  %51 = zext nneg i32 %48 to i64
  %52 = tail call noalias ptr @calloc(i64 noundef %51, i64 noundef 8) #4
  %53 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %52, ptr %53, align 8, !tbaa !18
  %54 = getelementptr inbounds i8, ptr %1, i64 72
  %55 = load ptr, ptr %54, align 8, !tbaa !18
  %56 = shl nuw nsw i64 %51, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %52, ptr align 8 %55, i64 %56, i1 false)
  br label %59

57:                                               ; preds = %46
  %58 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr null, ptr %58, align 8, !tbaa !18
  br label %59

59:                                               ; preds = %57, %50
  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) #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nofree nounwind willreturn 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind allocsize(0,1) }

!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 24}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !7, i64 40, !10, i64 48, !7, i64 56, !7, i64 60, !7, i64 64, !10, i64 72, !7, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !7, i64 40}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !7, i64 56}
!16 = !{!6, !10, i64 48}
!17 = !{!6, !7, i64 80}
!18 = !{!6, !10, i64 72}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass