; LLVM IR from ekoontz/graphlab :: src/graphlab/extern/metis/libmetis/graph.ll_libmetis (RandomizeGraph)

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

; 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: nounwind uwtable
define dso_local void @libmetis__RandomizeGraph(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, 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
  %11 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.graphdef, ptr %12, i32 0, i32 0
  %14 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %14, ptr %8, align 8, !tbaa !13
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.graphdef, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.graphdef, ptr %18, i32 0, i32 5
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  store ptr %20, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.graphdef, ptr %21, i32 0, i32 6
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  store ptr %23, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %3, align 8, !tbaa !13
  br label %24

24:                                               ; preds = %105, %1
  %25 = load i64, ptr %3, align 8, !tbaa !13
  %26 = load i64, ptr %8, align 8, !tbaa !13
  %27 = icmp slt i64 %25, %26
  br i1 %27, label %28, label %108

28:                                               ; preds = %24
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i64, ptr %3, align 8, !tbaa !13
  %31 = add nsw i64 %30, 1
  %32 = getelementptr inbounds i64, ptr %29, i64 %31
  %33 = load i64, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i64, ptr %3, align 8, !tbaa !13
  %36 = getelementptr inbounds i64, ptr %34, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !13
  %38 = sub nsw i64 %33, %37
  store i64 %38, ptr %6, align 8, !tbaa !13
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i64, ptr %3, align 8, !tbaa !13
  %41 = getelementptr inbounds i64, ptr %39, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !13
  store i64 %42, ptr %4, align 8, !tbaa !13
  br label %43

43:                                               ; preds = %101, %28
  %44 = load i64, ptr %4, align 8, !tbaa !13
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load i64, ptr %3, align 8, !tbaa !13
  %47 = add nsw i64 %46, 1
  %48 = getelementptr inbounds i64, ptr %45, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !13
  %50 = icmp slt i64 %44, %49
  br i1 %50, label %51, label %104

51:                                               ; preds = %43
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load i64, ptr %3, align 8, !tbaa !13
  %54 = getelementptr inbounds i64, ptr %52, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !13
  %56 = load i64, ptr %6, align 8, !tbaa !13
  %57 = sitofp i64 %56 to double
  %58 = fmul double 0x3E00000000000000, %57
  %59 = call i32 @rand() #3
  %60 = sitofp i32 %59 to double
  %61 = fmul double %58, %60
  %62 = fptosi double %61 to i32
  %63 = sext i32 %62 to i64
  %64 = add nsw i64 %55, %63
  store i64 %64, ptr %5, align 8, !tbaa !13
  br label %65

65:                                               ; preds = %51
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load i64, ptr %4, align 8, !tbaa !13
  %68 = getelementptr inbounds i64, ptr %66, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !13
  store i64 %69, ptr %7, align 8, !tbaa !13
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load i64, ptr %5, align 8, !tbaa !13
  %72 = getelementptr inbounds i64, ptr %70, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !13
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = load i64, ptr %4, align 8, !tbaa !13
  %76 = getelementptr inbounds i64, ptr %74, i64 %75
  store i64 %73, ptr %76, align 8, !tbaa !13
  %77 = load i64, ptr %7, align 8, !tbaa !13
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = load i64, ptr %5, align 8, !tbaa !13
  %80 = getelementptr inbounds i64, ptr %78, i64 %79
  store i64 %77, ptr %80, align 8, !tbaa !13
  br label %81

81:                                               ; preds = %65
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = load i64, ptr %4, align 8, !tbaa !13
  %86 = getelementptr inbounds i64, ptr %84, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !13
  store i64 %87, ptr %7, align 8, !tbaa !13
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load i64, ptr %5, align 8, !tbaa !13
  %90 = getelementptr inbounds i64, ptr %88, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !13
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = load i64, ptr %4, align 8, !tbaa !13
  %94 = getelementptr inbounds i64, ptr %92, i64 %93
  store i64 %91, ptr %94, align 8, !tbaa !13
  %95 = load i64, ptr %7, align 8, !tbaa !13
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = load i64, ptr %5, align 8, !tbaa !13
  %98 = getelementptr inbounds i64, ptr %96, i64 %97
  store i64 %95, ptr %98, align 8, !tbaa !13
  br label %99

99:                                               ; preds = %83
  br label %100

100:                                              ; preds = %99
  br label %101

101:                                              ; preds = %100
  %102 = load i64, ptr %4, align 8, !tbaa !13
  %103 = add nsw i64 %102, 1
  store i64 %103, ptr %4, align 8, !tbaa !13
  br label %43, !llvm.loop !17

104:                                              ; preds = %43
  br label %105

105:                                              ; preds = %104
  %106 = load i64, ptr %3, align 8, !tbaa !13
  %107 = add nsw i64 %106, 1
  store i64 %107, ptr %3, align 8, !tbaa !13
  br label %24, !llvm.loop !19

108:                                              ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() #2

attributes #0 = { nocallback nofree nosync 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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"graphdef", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !12, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !11, i64 112, !11, i64 120, !6, i64 128, !6, i64 136, !11, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !11, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !6, i64 48}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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 @libmetis__RandomizeGraph(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = icmp sgt i64 %2, 0
  br i1 %9, label %.lr.ph40.preheader, label %._crit_edge

.lr.ph40.preheader:                               ; preds = %1
  %.pre = load i64, ptr %4, align 8, !tbaa !15
  br label %.lr.ph40

.loopexit:                                        ; preds = %20, %.lr.ph40
  %10 = phi i64 [ %15, %.lr.ph40 ], [ %37, %20 ]
  %exitcond.not = icmp eq i64 %12, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph40, !llvm.loop !16

.lr.ph40:                                         ; preds = %.lr.ph40.preheader, %.loopexit
  %11 = phi i64 [ %10, %.loopexit ], [ %.pre, %.lr.ph40.preheader ]
  %.039 = phi i64 [ %12, %.loopexit ], [ 0, %.lr.ph40.preheader ]
  %12 = add nuw nsw i64 %.039, 1
  %13 = getelementptr inbounds i64, ptr %4, i64 %12
  %14 = getelementptr inbounds i64, ptr %4, i64 %.039
  %15 = load i64, ptr %13, align 8, !tbaa !15
  %16 = icmp slt i64 %11, %15
  br i1 %16, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph40
  %17 = sub nsw i64 %15, %11
  %18 = sitofp i64 %17 to double
  %19 = fmul double %18, 0x3E00000000000000
  br label %20

20:                                               ; preds = %.lr.ph, %20
  %.03738 = phi i64 [ %11, %.lr.ph ], [ %36, %20 ]
  %21 = load i64, ptr %14, align 8, !tbaa !15
  %22 = tail call i32 @rand() #2
  %23 = sitofp i32 %22 to double
  %24 = fmul double %19, %23
  %25 = fptosi double %24 to i32
  %26 = sext i32 %25 to i64
  %27 = add nsw i64 %21, %26
  %28 = getelementptr inbounds i64, ptr %6, i64 %.03738
  %29 = load i64, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds i64, ptr %6, i64 %27
  %31 = load i64, ptr %30, align 8, !tbaa !15
  store i64 %31, ptr %28, align 8, !tbaa !15
  store i64 %29, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds i64, ptr %8, i64 %.03738
  %33 = load i64, ptr %32, align 8, !tbaa !15
  %34 = getelementptr inbounds i64, ptr %8, i64 %27
  %35 = load i64, ptr %34, align 8, !tbaa !15
  store i64 %35, ptr %32, align 8, !tbaa !15
  store i64 %33, ptr %34, align 8, !tbaa !15
  %36 = add nsw i64 %.03738, 1
  %37 = load i64, ptr %13, align 8, !tbaa !15
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %20, label %.loopexit, !llvm.loop !18

._crit_edge:                                      ; preds = %.loopexit, %1
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

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 = { 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 #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 0}
!6 = !{!"graphdef", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !7, i64 112, !7, i64 120, !10, i64 128, !10, i64 136, !7, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !7, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 48}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass