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

; 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 }
%struct.SCS_CONE_WORK = type { ptr, ptr, i32, i32, ptr, i32, double }
%struct.ScsScaling = type { ptr, ptr, i32, i32, double, double }

; Function Attrs: nounwind uwtable
define dso_local void @scale_box_cone(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %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 ne i32 %9, 0
  br i1 %10, label %11, label %44

11:                                               ; preds = %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ScsCone, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %44

16:                                               ; preds = %11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ScsCone, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %44

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.SCS_CONE_WORK, ptr %22, i32 0, i32 6
  store double 1.000000e+00, ptr %23, align 8, !tbaa !14
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %43

26:                                               ; preds = %21
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ScsScaling, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ScsCone, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !19
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ScsCone, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 4, !tbaa !20
  %37 = add nsw i32 %33, %36
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %30, i64 %38
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ScsCone, ptr %40, i32 0, i32 4
  %42 = load i32, ptr %41, align 8, !tbaa !9
  call void @normalize_box_cone(ptr noundef %27, ptr noundef %39, i32 noundef %42)
  br label %43

43:                                               ; preds = %26, %21
  br label %44

44:                                               ; preds = %43, %16, %11, %3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @normalize_box_cone(ptr noundef, ptr noundef, i32 noundef) #0

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

!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 = !{!15, !16, i64 40}
!15 = !{!"SCS_CONE_WORK", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !6, i64 24, !11, i64 32, !16, i64 40}
!16 = !{!"double", !7, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !16, i64 24, !16, i64 32}
!19 = !{!10, !11, i64 0}
!20 = !{!10, !11, i64 4}


; 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: nounwind uwtable
define dso_local void @scale_box_cone(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %22, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %.not10 = icmp eq ptr %8, null
  br i1 %.not10, label %22, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %.not11 = icmp eq ptr %11, null
  br i1 %.not11, label %22, label %12

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %1, i64 40
  store double 1.000000e+00, ptr %13, align 8, !tbaa !13
  %.not12 = icmp eq ptr %2, null
  br i1 %.not12, label %22, label %14

14:                                               ; preds = %12
  %15 = load ptr, ptr %2, align 8, !tbaa !16
  %16 = load i32, ptr %0, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !19
  %19 = add nsw i32 %18, %16
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds double, ptr %15, i64 %20
  tail call void @normalize_box_cone(ptr noundef nonnull %0, ptr noundef %21, i32 noundef %5)
  br label %22

22:                                               ; preds = %12, %14, %9, %6, %3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @normalize_box_cone(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

!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 = !{!14, !15, i64 40}
!14 = !{!"SCS_CONE_WORK", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !10, i64 24, !7, i64 32, !15, i64 40}
!15 = !{!"double", !8, i64 0}
!16 = !{!17, !10, i64 0}
!17 = !{!"", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 20, !15, i64 24, !15, i64 32}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !7, i64 4}


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