; LLVM IR from siconos/siconos :: externals/lbl/metis4/refine.ll_ (Refine2Way)

; 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.controldef = type { i32, i32, i32, i32, i32, i32, float, i32, i32, i32, i32, %struct.workspacedef, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%struct.workspacedef = type { ptr, i32, i32, ptr, ptr, i32, ptr, ptr }
%struct.graphdef = type { ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @__Refine2Way(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, float noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store float %4, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.controldef, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = and i32 %13, 1
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %22

16:                                               ; preds = %5
  %17 = call double @__seconds()
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.controldef, ptr %18, i32 0, i32 17
  %20 = load double, ptr %19, align 8, !tbaa !16
  %21 = fsub double %20, %17
  store double %21, ptr %19, align 8, !tbaa !16
  br label %22

22:                                               ; preds = %16, %5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  call void @__Compute2WayPartitionParams(ptr noundef %23, ptr noundef %24)
  br label %25

25:                                               ; preds = %99, %22
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.controldef, ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = and i32 %28, 1
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %37

31:                                               ; preds = %25
  %32 = call double @__seconds()
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.controldef, ptr %33, i32 0, i32 19
  %35 = load double, ptr %34, align 8, !tbaa !17
  %36 = fsub double %35, %32
  store double %36, ptr %34, align 8, !tbaa !17
  br label %37

37:                                               ; preds = %31, %25
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.controldef, ptr %38, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !18
  switch i32 %40, label %49 [
    i32 1, label %41
  ]

41:                                               ; preds = %37
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load float, ptr %10, align 4, !tbaa !9
  call void @__Balance2Way(ptr noundef %42, ptr noundef %43, ptr noundef %44, float noundef %45)
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  call void @__FM_2WayEdgeRefine(ptr noundef %46, ptr noundef %47, ptr noundef %48, i32 noundef 8)
  br label %53

49:                                               ; preds = %37
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.controldef, ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 8, !tbaa !18
  call void (ptr, ...) @__errexit(ptr noundef @.str, i32 noundef %52)
  br label %53

53:                                               ; preds = %49, %41
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.controldef, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = and i32 %56, 1
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %65

59:                                               ; preds = %53
  %60 = call double @__seconds()
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.controldef, ptr %61, i32 0, i32 19
  %63 = load double, ptr %62, align 8, !tbaa !17
  %64 = fadd double %63, %60
  store double %64, ptr %62, align 8, !tbaa !17
  br label %65

65:                                               ; preds = %59, %53
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = icmp eq ptr %66, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %65
  br label %100

70:                                               ; preds = %65
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.graphdef, ptr %71, i32 0, i32 28
  %73 = load ptr, ptr %72, align 8, !tbaa !19
  store ptr %73, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.controldef, ptr %74, i32 0, i32 1
  %76 = load i32, ptr %75, align 4, !tbaa !11
  %77 = and i32 %76, 1
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %85

79:                                               ; preds = %70
  %80 = call double @__seconds()
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.controldef, ptr %81, i32 0, i32 20
  %83 = load double, ptr %82, align 8, !tbaa !21
  %84 = fsub double %83, %80
  store double %84, ptr %82, align 8, !tbaa !21
  br label %85

85:                                               ; preds = %79, %70
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  call void @__Project2WayPartition(ptr noundef %86, ptr noundef %87)
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.controldef, ptr %88, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = and i32 %90, 1
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %99

93:                                               ; preds = %85
  %94 = call double @__seconds()
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.controldef, ptr %95, i32 0, i32 20
  %97 = load double, ptr %96, align 8, !tbaa !21
  %98 = fadd double %97, %94
  store double %98, ptr %96, align 8, !tbaa !21
  br label %99

99:                                               ; preds = %93, %85
  br label %25

100:                                              ; preds = %69
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.controldef, ptr %101, i32 0, i32 1
  %103 = load i32, ptr %102, align 4, !tbaa !11
  %104 = and i32 %103, 1
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %112

106:                                              ; preds = %100
  %107 = call double @__seconds()
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.controldef, ptr %108, i32 0, i32 17
  %110 = load double, ptr %109, align 8, !tbaa !16
  %111 = fadd double %110, %107
  store double %111, ptr %109, align 8, !tbaa !16
  br label %112

112:                                              ; preds = %106, %100
  ret void
}

declare double @__seconds() #1

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

declare void @__Balance2Way(ptr noundef, ptr noundef, ptr noundef, float noundef) #1

declare void @__FM_2WayEdgeRefine(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare void @__errexit(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @__Project2WayPartition(ptr noundef, ptr 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" }
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" }

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"controldef", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !10, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !14, i64 48, !15, i64 104, !15, i64 112, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !15, i64 160, !15, i64 168, !15, i64 176, !15, i64 184, !15, i64 192, !15, i64 200, !15, i64 208, !15, i64 216, !15, i64 224}
!13 = !{!"int", !7, i64 0}
!14 = !{!"workspacedef", !6, i64 0, !13, i64 8, !13, i64 12, !6, i64 16, !6, i64 24, !13, i64 32, !6, i64 40, !6, i64 48}
!15 = !{!"double", !7, i64 0}
!16 = !{!12, !15, i64 144}
!17 = !{!12, !15, i64 160}
!18 = !{!12, !13, i64 16}
!19 = !{!20, !6, i64 208}
!20 = !{!"graphdef", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !13, i64 88, !13, i64 92, !6, i64 96, !6, i64 104, !13, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !13, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208}
!21 = !{!12, !15, i64 168}


; 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 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @__Refine2Way(ptr noundef %0, ptr noundef readnone %1, ptr noundef %2, ptr noundef %3, float noundef %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = and i32 %7, 1
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %14, label %9

9:                                                ; preds = %5
  %10 = tail call double @__seconds() #2
  %11 = getelementptr inbounds i8, ptr %0, i64 144
  %12 = load double, ptr %11, align 8, !tbaa !14
  %13 = fsub double %12, %10
  store double %13, ptr %11, align 8, !tbaa !14
  br label %14

14:                                               ; preds = %9, %5
  tail call void @__Compute2WayPartitionParams(ptr noundef nonnull %0, ptr noundef %2)
  %15 = getelementptr inbounds i8, ptr %0, i64 160
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = getelementptr inbounds i8, ptr %0, i64 168
  br label %18

18:                                               ; preds = %.backedge, %14
  %.0 = phi ptr [ %2, %14 ], [ %40, %.backedge ]
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = and i32 %19, 1
  %.not29 = icmp eq i32 %20, 0
  br i1 %.not29, label %25, label %21

21:                                               ; preds = %18
  %22 = tail call double @__seconds() #2
  %23 = load double, ptr %15, align 8, !tbaa !15
  %24 = fsub double %23, %22
  store double %24, ptr %15, align 8, !tbaa !15
  br label %25

25:                                               ; preds = %21, %18
  %26 = load i32, ptr %16, align 8, !tbaa !16
  %cond = icmp eq i32 %26, 1
  br i1 %cond, label %27, label %28

27:                                               ; preds = %25
  tail call void @__Balance2Way(ptr noundef nonnull %0, ptr noundef %.0, ptr noundef %3, float noundef %4) #2
  tail call void @__FM_2WayEdgeRefine(ptr noundef nonnull %0, ptr noundef %.0, ptr noundef %3, i32 noundef 8) #2
  br label %29

28:                                               ; preds = %25
  tail call void (ptr, ...) @__errexit(ptr noundef nonnull @.str, i32 noundef %26) #2
  br label %29

29:                                               ; preds = %28, %27
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = and i32 %30, 1
  %.not30 = icmp eq i32 %31, 0
  br i1 %.not30, label %36, label %32

32:                                               ; preds = %29
  %33 = tail call double @__seconds() #2
  %34 = load double, ptr %15, align 8, !tbaa !15
  %35 = fadd double %33, %34
  store double %35, ptr %15, align 8, !tbaa !15
  br label %36

36:                                               ; preds = %32, %29
  %37 = icmp eq ptr %.0, %1
  br i1 %37, label %54, label %38

38:                                               ; preds = %36
  %39 = getelementptr inbounds i8, ptr %.0, i64 208
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = and i32 %41, 1
  %.not31 = icmp eq i32 %42, 0
  br i1 %.not31, label %47, label %43

43:                                               ; preds = %38
  %44 = tail call double @__seconds() #2
  %45 = load double, ptr %17, align 8, !tbaa !19
  %46 = fsub double %45, %44
  store double %46, ptr %17, align 8, !tbaa !19
  br label %47

47:                                               ; preds = %43, %38
  tail call void @__Project2WayPartition(ptr noundef nonnull %0, ptr noundef %40)
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = and i32 %48, 1
  %.not32 = icmp eq i32 %49, 0
  br i1 %.not32, label %.backedge, label %50

50:                                               ; preds = %47
  %51 = tail call double @__seconds() #2
  %52 = load double, ptr %17, align 8, !tbaa !19
  %53 = fadd double %51, %52
  store double %53, ptr %17, align 8, !tbaa !19
  br label %.backedge

.backedge:                                        ; preds = %50, %47
  br label %18

54:                                               ; preds = %36
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = and i32 %55, 1
  %.not33 = icmp eq i32 %56, 0
  br i1 %.not33, label %62, label %57

57:                                               ; preds = %54
  %58 = tail call double @__seconds() #2
  %59 = getelementptr inbounds i8, ptr %0, i64 144
  %60 = load double, ptr %59, align 8, !tbaa !14
  %61 = fadd double %58, %60
  store double %61, ptr %59, align 8, !tbaa !14
  br label %62

62:                                               ; preds = %57, %54
  ret void
}

declare double @__seconds() local_unnamed_addr #1

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

declare void @__Balance2Way(ptr noundef, ptr noundef, ptr noundef, float noundef) local_unnamed_addr #1

declare void @__FM_2WayEdgeRefine(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @__errexit(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @__Project2WayPartition(ptr noundef, ptr 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" }
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 = { 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 4}
!6 = !{!"controldef", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !11, i64 48, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !13, i64 184, !13, i64 192, !13, i64 200, !13, i64 208, !13, i64 216, !13, i64 224}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"workspacedef", !12, i64 0, !7, i64 8, !7, i64 12, !12, i64 16, !12, i64 24, !7, i64 32, !12, i64 40, !12, i64 48}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!6, !13, i64 144}
!15 = !{!6, !13, i64 160}
!16 = !{!6, !7, i64 16}
!17 = !{!18, !12, i64 208}
!18 = !{!"graphdef", !12, i64 0, !12, i64 8, !7, i64 16, !7, i64 20, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !7, i64 88, !7, i64 92, !12, i64 96, !12, i64 104, !7, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !7, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208}
!19 = !{!6, !13, i64 168}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass