#include <iostream>
#include <cuda_runtime.h>
#include <cooperative_groups.h>
#include <curand_kernel.h>

namespace cg = cooperative_groups;

#define BLOCK_SIZE 256
#define NUM_NODES 8192

__device__ int d_community[NUM_NODES];
__device__ float d_modularity;
__device__ int d_max_community;

// Simple graph structure with adjacency list
struct Graph {
    int* d_edges;
    int* d_edge_weights;
    int* d_degree;
};

// Kernel to initialize communities
__global__ void initializeCommunities() {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        d_community[idx] = idx;
    }
}

// Kernel to compute the total degree of each node
__global__ void computeTotalDegree(Graph graph) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        int start = 0;
        int end = graph.d_degree[idx];
        graph.d_degree[idx] = 0;
        for (int i = start; i < end; i++) {
            graph.d_degree[idx] += graph.d_edge_weights[i];
        }
    }
}

// Kernel to compute modularity gain
__global__ void computeModularityGain(Graph graph, float* d_gain, int* d_new_community) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        int current_community = d_community[idx];
        int start = 0;
        int end = graph.d_degree[idx];
        float total_weight = 0.0f;
        float community_weight = 0.0f;
        float total_degree = 0.0f;

        for (int i = 0; i < NUM_NODES; i++) {
            total_degree += graph.d_degree[i];
        }

        for (int i = start; i < end; i++) {
            int neighbor = graph.d_edges[i];
            int weight = graph.d_edge_weights[i];
            total_weight += weight;
            if (d_community[neighbor] == current_community) {
                community_weight += weight;
            }
        }

        float k_i = graph.d_degree[idx];
        float m = total_degree / 2.0f;
        float gain = (community_weight / m) - (k_i * k_i / (m * m));

        d_gain[idx] = gain;
        d_new_community[idx] = current_community;

        // Check all neighbors for better community
        for (int i = start; i < end; i++) {
            int neighbor = graph.d_edges[i];
            int neighbor_community = d_community[neighbor];
            if (neighbor_community != current_community) {
                float neighbor_community_weight = 0.0f;
                for (int j = 0; j < NUM_NODES; j++) {
                    if (d_community[j] == neighbor_community) {
                        neighbor_community_weight += graph.d_degree[j];
                    }
                }
                float new_gain = (neighbor_community_weight / m) - (k_i * k_i / (m * m));
                if (new_gain > gain) {
                    gain = new_gain;
                    d_new_community[idx] = neighbor_community;
                }
            }
        }
    }
}

// Kernel to update communities
__global__ void updateCommunities(int* d_new_community) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        d_community[idx] = d_new_community[idx];
    }
}

// Function to check for errors in CUDA calls
void checkCudaError(cudaError_t err, const char* msg) {
    if (err != cudaSuccess) {
        std::cerr << "CUDA error: " << msg << " (" << cudaGetErrorString(err) << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    // Initialize random number generator
    curandGenerator_t gen;
    curandCreateGenerator(&gen, CURAND_RNG_PSEUDO_DEFAULT);
    curandSetPseudoRandomGeneratorSeed(gen, 1234ULL);

    // Allocate and initialize graph data on device
    Graph d_graph;
    int* h_edges = new int[NUM_NODES * 16]; // Example adjacency list
    int* h_edge_weights = new int[NUM_NODES * 16]; // Example edge weights
    int* h_degree = new int[NUM_NODES]; // Example degrees

    // Initialize edges and weights randomly
    curandGenerate(gen, (unsigned int*)h_edges, NUM_NODES * 16);
    curandGenerate(gen, (unsigned int*)h_edge_weights, NUM_NODES * 16);
    for (int i = 0; i < NUM_NODES; i++) {
        h_degree[i] = 16; // Each node has 16 edges
    }

    checkCudaError(cudaMalloc((void**)&d_graph.d_edges, NUM_NODES * 16 * sizeof(int)), "Allocating d_graph.d_edges");
    checkCudaError(cudaMalloc((void**)&d_graph.d_edge_weights, NUM_NODES * 16 * sizeof(int)), "Allocating d_graph.d_edge_weights");
    checkCudaError(cudaMalloc((void**)&d_graph.d_degree, NUM_NODES * sizeof(int)), "Allocating d_graph.d_degree");

    checkCudaError(cudaMemcpy(d_graph.d_edges, h_edges, NUM_NODES * 16 * sizeof(int), cudaMemcpyHostToDevice), "Copying h_edges to d_graph.d_edges");
    checkCudaError(cudaMemcpy(d_graph.d_edge_weights, h_edge_weights, NUM_NODES * 16 * sizeof(int), cudaMemcpyHostToDevice), "Copying h_edge_weights to d_graph.d_edge_weights");
    checkCudaError(cudaMemcpy(d_graph.d_degree, h_degree, NUM_NODES * sizeof(int), cudaMemcpyHostToDevice), "Copying h_degree to d_graph.d_degree");

    // Allocate and initialize other device data
    float* d_gain;
    int* d_new_community;
    checkCudaError(cudaMalloc((void**)&d_gain, NUM_NODES * sizeof(float)), "Allocating d_gain");
    checkCudaError(cudaMalloc((void**)&d_new_community, NUM_NODES * sizeof(int)), "Allocating d_new_community");

    // Initialize communities
    int numBlocks = (NUM_NODES + BLOCK_SIZE - 1) / BLOCK_SIZE;
    initializeCommunities<<<numBlocks, BLOCK_SIZE>>>();
    checkCudaError(cudaGetLastError(), "Kernel launch failed: initializeCommunities");

    // Compute total degree
    computeTotalDegree<<<numBlocks, BLOCK_SIZE>>>(d_graph);
    checkCudaError(cudaGetLastError(), "Kernel launch failed: computeTotalDegree");

    // Main loop for community detection
    bool changed = true;
    while (changed) {
        changed = false;

        // Compute modularity gain
        computeModularityGain<<<numBlocks, BLOCK_SIZE>>>(d_graph, d_gain, d_new_community);
        checkCudaError(cudaGetLastError(), "Kernel launch failed: computeModularityGain");

        // Update communities
        updateCommunities<<<numBlocks, BLOCK_SIZE>>>(d_new_community);
        checkCudaError(cudaGetLastError(), "Kernel launch failed: updateCommunities");

        // Check if any community changed
        int* h_new_community = new int[NUM_NODES];
        checkCudaError(cudaMemcpy(h_new_community, d_new_community, NUM_NODES * sizeof(int), cudaMemcpyDeviceToHost), "Copying d_new_community to h_new_community");

        for (int i = 0; i < NUM_NODES; i++) {
            if (h_new_community[i] != d_community[i]) {
                changed = true;
                break;
            }
        }

        delete[] h_new_community;
    }

    // Free device memory
    cudaFree(d_graph.d_edges);
    cudaFree(d_graph.d_edge_weights);
    cudaFree(d_graph.d_degree);
    cudaFree(d_gain);
    cudaFree(d_new_community);

    // Free host memory
    delete[] h_edges;
    delete[] h_edge_weights;
    delete[] h_degree;

    // Destroy random number generator
    curandDestroyGenerator(gen);

    std::cout << "Community detection completed." << std::endl;
    return 0;
}
	.file	"tmpxft_0014db57_00000000-6_cuda_code_086306.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB7039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE7039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"CUDA error: "
.LC1:
	.string	" ("
.LC2:
	.string	")"
	.text
	.globl	_Z14checkCudaError9cudaErrorPKc
	.type	_Z14checkCudaError9cudaErrorPKc, @function
_Z14checkCudaError9cudaErrorPKc:
.LFB7035:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %rbp
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE7035:
	.size	_Z14checkCudaError9cudaErrorPKc, .-_Z14checkCudaError9cudaErrorPKc
	.globl	_Z40__device_stub__Z21initializeCommunitiesvv
	.type	_Z40__device_stub__Z21initializeCommunitiesvv, @function
_Z40__device_stub__Z21initializeCommunitiesvv:
.LFB7061:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$4294967297, %rax
	leaq	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z21initializeCommunitiesv(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L8:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7061:
	.size	_Z40__device_stub__Z21initializeCommunitiesvv, .-_Z40__device_stub__Z21initializeCommunitiesvv
	.globl	_Z21initializeCommunitiesv
	.type	_Z21initializeCommunitiesv, @function
_Z21initializeCommunitiesv:
.LFB7062:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z21initializeCommunitiesvv
	.cfi_endproc
.LFE7062:
	.size	_Z21initializeCommunitiesv, .-_Z21initializeCommunitiesv
	.globl	_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph
	.type	_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph, @function
_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph:
.LFB7063:
	.cfi_startproc
	endbr64
	subq	$88, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rcx
	movq	%rdi, 64(%rsp)
	movq	%rsp, %rdx
	movabsq	$4294967297, %rax
	leaq	28(%rsp), %rsi
	leaq	16(%rsp), %rdi
	movl	$1, 24(%rsp)
	movq	%rax, 16(%rsp)
	movq	%rax, 28(%rsp)
	movl	$1, 36(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	8(%rsp)
	.cfi_def_cfa_offset 104
	leaq	_Z18computeTotalDegree5Graph(%rip), %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 112
	movq	44(%rsp), %rcx
	movl	52(%rsp), %r8d
	movq	32(%rsp), %rsi
	movl	40(%rsp), %edx
	leaq	80(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 104
	popq	%rdx
	.cfi_def_cfa_offset 96
.L13:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$88, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7063:
	.size	_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph, .-_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph
	.globl	_Z18computeTotalDegree5Graph
	.type	_Z18computeTotalDegree5Graph, @function
_Z18computeTotalDegree5Graph:
.LFB7064:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	16(%rsp), %rdi
	call	_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7064:
	.size	_Z18computeTotalDegree5Graph, .-_Z18computeTotalDegree5Graph
	.globl	_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi
	.type	_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi, @function
_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi:
.LFB7065:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rsi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	44(%rsp), %rsi
	movq	%rdx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movq	%rdi, 80(%rsp)
	leaq	32(%rsp), %rdi
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L19
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z21computeModularityGain5GraphPfPi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L19:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7065:
	.size	_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi, .-_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi
	.globl	_Z21computeModularityGain5GraphPfPi
	.type	_Z21computeModularityGain5GraphPfPi, @function
_Z21computeModularityGain5GraphPfPi:
.LFB7066:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rsi, %rdx
	movq	%rdi, %rsi
	leaq	16(%rsp), %rdi
	call	_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7066:
	.size	_Z21computeModularityGain5GraphPfPi, .-_Z21computeModularityGain5GraphPfPi
	.globl	_Z37__device_stub__Z17updateCommunitiesPiPi
	.type	_Z37__device_stub__Z17updateCommunitiesPiPi, @function
_Z37__device_stub__Z17updateCommunitiesPiPi:
.LFB7067:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z17updateCommunitiesPi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L25:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7067:
	.size	_Z37__device_stub__Z17updateCommunitiesPiPi, .-_Z37__device_stub__Z17updateCommunitiesPiPi
	.globl	_Z17updateCommunitiesPi
	.type	_Z17updateCommunitiesPi, @function
_Z17updateCommunitiesPi:
.LFB7068:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z17updateCommunitiesPiPi
	.cfi_endproc
.LFE7068:
	.size	_Z17updateCommunitiesPi, .-_Z17updateCommunitiesPi
	.section	.rodata.str1.1
.LC3:
	.string	"Allocating d_graph.d_edges"
.LC4:
	.string	"Allocating d_graph.d_edge_weights"
.LC5:
	.string	"Allocating d_graph.d_degree"
.LC6:
	.string	"Copying h_edges to d_graph.d_edges"
.LC7:
	.string	"Copying h_edge_weights to d_graph.d_edge_weights"
.LC8:
	.string	"Copying h_degree to d_graph.d_degree"
.LC9:
	.string	"Allocating d_gain"
.LC10:
	.string	"Allocating d_new_community"
.LC11:
	.string	"Kernel launch failed: initializeCommunities"
.LC12:
	.string	"Kernel launch failed: computeTotalDegree"
.LC13:
	.string	"Kernel launch failed: computeModularityGain"
.LC14:
	.string	"Kernel launch failed: updateCommunities"
.LC15:
	.string	"Copying d_new_community to h_new_community"
.LC16:
	.string	"Community detection completed."
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB7036:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$100, %esi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rdi
	call	curandCreateGenerator@PLT
	movq	24(%rsp), %rdi
	movl	$1234, %esi
	call	curandSetPseudoRandomGeneratorSeed@PLT
	movl	$524288, %edi
	call	_Znam@PLT
	movl	$524288, %edi
	movq	%rax, (%rsp)
	call	_Znam@PLT
	movl	$32768, %edi
	movq	%rax, 8(%rsp)
	call	_Znam@PLT
	movq	(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	$131072, %edx
	movq	%rax, %rbx
	call	curandGenerate@PLT
	movq	8(%rsp), %rsi
	movq	24(%rsp), %rdi
	movl	$131072, %edx
	call	curandGenerate@PLT
	xorl	%eax, %eax
.L31:
	movl	$16, (%rbx,%rax,4)
	incq	%rax
	cmpq	$8192, %rax
	jne	.L31
	leaq	72(%rsp), %rdi
	movl	$524288, %esi
	call	cudaMalloc@PLT
	leaq	.LC3(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	80(%rsp), %rdi
	movl	$524288, %esi
	call	cudaMalloc@PLT
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	88(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	leaq	.LC5(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	(%rsp), %rsi
	movq	72(%rsp), %rdi
	movl	$1, %ecx
	movl	$524288, %edx
	call	cudaMemcpy@PLT
	leaq	.LC6(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	8(%rsp), %rsi
	movq	80(%rsp), %rdi
	movl	$1, %ecx
	movl	$524288, %edx
	call	cudaMemcpy@PLT
	leaq	.LC7(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	movq	88(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	leaq	.LC8(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	32(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	leaq	.LC9(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	leaq	40(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	leaq	.LC10(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$134217729, %edi
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$5, %rdi
	movq	%rdx, 96(%rsp)
	movl	$1, 104(%rsp)
	movq	%rdi, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	call	_Z40__device_stub__Z21initializeCommunitiesvv
.L32:
	call	cudaGetLastError@PLT
	leaq	.LC11(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$16777217, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$134217729, %edi
	salq	$8, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	salq	$5, %rdi
	movq	%rdx, 60(%rsp)
	movl	$1, 68(%rsp)
	movq	%rdi, 48(%rsp)
	movl	$1, 56(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L33
	movups	72(%rsp), %xmm0
	movq	88(%rsp), %rax
	leaq	96(%rsp), %rdi
	movq	%rax, 112(%rsp)
	movups	%xmm0, 96(%rsp)
	call	_Z42__device_stub__Z18computeTotalDegree5GraphR5Graph
.L33:
	call	cudaGetLastError@PLT
	leaq	.LC12(%rip), %rsi
	movabsq	$4294967552, %r12
	movabsq	$4294967328, %r13
	movl	%eax, %edi
	leaq	.LC14(%rip), %r15
	call	_Z14checkCudaError9cudaErrorPKc
.L38:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movl	$1, %ecx
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, 60(%rsp)
	movl	$1, 68(%rsp)
	movq	%r13, 48(%rsp)
	movl	$1, 56(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L34
	movups	72(%rsp), %xmm1
	movq	88(%rsp), %rax
	leaq	96(%rsp), %rdi
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	%rax, 112(%rsp)
	movups	%xmm1, 96(%rsp)
	call	_Z49__device_stub__Z21computeModularityGain5GraphPfPiR5GraphPfPi
.L34:
	call	cudaGetLastError@PLT
	leaq	.LC13(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movl	$1, %ecx
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, 96(%rsp)
	movl	$1, 104(%rsp)
	movq	%r13, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movq	40(%rsp), %rdi
	call	_Z37__device_stub__Z17updateCommunitiesPiPi
.L35:
	call	cudaGetLastError@PLT
	movq	%r15, %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	movl	$32768, %edi
	call	_Znam@PLT
	movq	40(%rsp), %rsi
	movl	$32768, %edx
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %r14
	call	cudaMemcpy@PLT
	leaq	.LC15(%rip), %rsi
	movl	%eax, %edi
	call	_Z14checkCudaError9cudaErrorPKc
	xorl	%eax, %eax
	leaq	_ZL11d_community(%rip), %rdx
.L37:
	movl	(%rdx,%rax), %ecx
	cmpl	%ecx, (%r14,%rax)
	jne	.L40
	addq	$4, %rax
	cmpq	$32768, %rax
	jne	.L37
	xorl	%ebp, %ebp
	jmp	.L36
.L40:
	movb	$1, %bpl
.L36:
	movq	%r14, %rdi
	call	_ZdaPv@PLT
	testb	%bpl, %bpl
	jne	.L38
	movq	72(%rsp), %rdi
	call	cudaFree@PLT
	movq	80(%rsp), %rdi
	call	cudaFree@PLT
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	8(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZdaPv@PLT
	movq	24(%rsp), %rdi
	call	curandDestroyGenerator@PLT
	leaq	_ZSt4cout(%rip), %rdi
	leaq	.LC16(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE7036:
	.size	main, .-main
	.section	.rodata.str1.1
.LC17:
	.string	"_Z17updateCommunitiesPi"
.LC18:
	.string	"_Z21computeModularityGain5GraphPfPi"
.LC19:
	.string	"_Z18computeTotalDegree5Graph"
.LC20:
	.string	"_Z21initializeCommunitiesv"
.LC21:
	.string	"precalc_xorwow_matrix"
.LC22:
	.string	"precalc_xorwow_offset_matrix"
.LC23:
	.string	"mrg32k3aM1"
.LC24:
	.string	"mrg32k3aM2"
.LC25:
	.string	"mrg32k3aM1SubSeq"
.LC26:
	.string	"mrg32k3aM2SubSeq"
.LC27:
	.string	"mrg32k3aM1Seq"
.LC28:
	.string	"mrg32k3aM2Seq"
.LC29:
	.string	"__cr_lgamma_table"
.LC30:
	.string	"d_community"
.LC31:
	.string	"d_modularity"
.LC32:
	.string	"d_max_community"
.LC33:
	.string	"_ZN50_INTERNAL_4dc990b2_19_cuda_code_086306_cu_07eb87644cuda3std3__419piecewise_constructE"
.LC34:
	.string	"_ZN50_INTERNAL_4dc990b2_19_cuda_code_086306_cu_07eb87644cuda3std6ranges3__45__cpo4swapE"
.LC35:
	.string	"_ZN50_INTERNAL_4dc990b2_19_cuda_code_086306_cu_07eb87644cuda3std6ranges3__45__cpo9iter_moveE"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB7070:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC17(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z17updateCommunitiesPi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC18(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z21computeModularityGain5GraphPfPi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC19(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z18computeTotalDegree5Graph(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC20(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z21initializeCommunitiesv(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC21(%rip), %rdx
	movl	$102400, %r9d
	leaq	_ZL21precalc_xorwow_matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC22(%rip), %rdx
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	movq	%rdx, %rcx
	movl	$102400, %r9d
	leaq	_ZL28precalc_xorwow_offset_matrix(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC23(%rip), %rdx
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM1(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC24(%rip), %rdx
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL10mrg32k3aM2(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC25(%rip), %rdx
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM1SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC26(%rip), %rdx
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	movq	%rdx, %rcx
	movl	$2016, %r9d
	leaq	_ZL16mrg32k3aM2SubSeq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC27(%rip), %rdx
	xorl	%r8d, %r8d
	movq	%rbx, %rdi
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM1Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC28(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$2304, %r9d
	leaq	_ZL13mrg32k3aM2Seq(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC29(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$72, %r9d
	leaq	_ZL17__cr_lgamma_table(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC30(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$32768, %r9d
	leaq	_ZL11d_community(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rax
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC31(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL12d_modularity(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC32(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL15d_max_community(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC33(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$1, %r9d
	leaq	_ZN4cuda3std3__419piecewise_constructE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC34(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$1, %r9d
	leaq	_ZN4cuda3std6ranges3__45__cpo4swapE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC35(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$1, %r9d
	movq	%rdx, %rcx
	leaq	_ZN4cuda3std6ranges3__45__cpo9iter_moveE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE7070:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL15d_max_community
	.comm	_ZL15d_max_community,4,4
	.local	_ZL12d_modularity
	.comm	_ZL12d_modularity,4,4
	.local	_ZL11d_community
	.comm	_ZL11d_community,32768,32
	.local	_ZL17__cr_lgamma_table
	.comm	_ZL17__cr_lgamma_table,72,32
	.local	_ZL13mrg32k3aM2Seq
	.comm	_ZL13mrg32k3aM2Seq,2304,32
	.local	_ZL13mrg32k3aM1Seq
	.comm	_ZL13mrg32k3aM1Seq,2304,32
	.local	_ZL16mrg32k3aM2SubSeq
	.comm	_ZL16mrg32k3aM2SubSeq,2016,32
	.local	_ZL16mrg32k3aM1SubSeq
	.comm	_ZL16mrg32k3aM1SubSeq,2016,32
	.local	_ZL10mrg32k3aM2
	.comm	_ZL10mrg32k3aM2,2304,32
	.local	_ZL10mrg32k3aM1
	.comm	_ZL10mrg32k3aM1,2304,32
	.local	_ZL28precalc_xorwow_offset_matrix
	.comm	_ZL28precalc_xorwow_offset_matrix,102400,32
	.local	_ZL21precalc_xorwow_matrix
	.comm	_ZL21precalc_xorwow_matrix,102400,32
	.weak	_ZN4cuda3std3__419piecewise_constructE
	.section	.rodata._ZN4cuda3std3__419piecewise_constructE,"aG",@progbits,_ZN4cuda3std3__419piecewise_constructE,comdat
	.type	_ZN4cuda3std3__419piecewise_constructE, @gnu_unique_object
	.size	_ZN4cuda3std3__419piecewise_constructE, 1
_ZN4cuda3std3__419piecewise_constructE:
	.zero	1
	.weak	_ZN4cuda3std6ranges3__45__cpo9iter_moveE
	.section	.rodata._ZN4cuda3std6ranges3__45__cpo9iter_moveE,"aG",@progbits,_ZN4cuda3std6ranges3__45__cpo9iter_moveE,comdat
	.type	_ZN4cuda3std6ranges3__45__cpo9iter_moveE, @gnu_unique_object
	.size	_ZN4cuda3std6ranges3__45__cpo9iter_moveE, 1
_ZN4cuda3std6ranges3__45__cpo9iter_moveE:
	.zero	1
	.weak	_ZN4cuda3std6ranges3__45__cpo4swapE
	.section	.rodata._ZN4cuda3std6ranges3__45__cpo4swapE,"aG",@progbits,_ZN4cuda3std6ranges3__45__cpo4swapE,comdat
	.type	_ZN4cuda3std6ranges3__45__cpo4swapE, @gnu_unique_object
	.size	_ZN4cuda3std6ranges3__45__cpo4swapE, 1
_ZN4cuda3std6ranges3__45__cpo4swapE:
	.zero	1
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <iostream>
#include <hip/hip_runtime.h>
#include <hip/hip_cooperative_groups.h>
#include <hiprand/hiprand_kernel.h>

namespace cg = cooperative_groups;

#define BLOCK_SIZE 256
#define NUM_NODES 8192

__device__ int d_community[NUM_NODES];
__device__ float d_modularity;
__device__ int d_max_community;

// Simple graph structure with adjacency list
struct Graph {
    int* d_edges;
    int* d_edge_weights;
    int* d_degree;
};

// Kernel to initialize communities
__global__ void initializeCommunities() {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        d_community[idx] = idx;
    }
}

// Kernel to compute the total degree of each node
__global__ void computeTotalDegree(Graph graph) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        int start = 0;
        int end = graph.d_degree[idx];
        graph.d_degree[idx] = 0;
        for (int i = start; i < end; i++) {
            graph.d_degree[idx] += graph.d_edge_weights[i];
        }
    }
}

// Kernel to compute modularity gain
__global__ void computeModularityGain(Graph graph, float* d_gain, int* d_new_community) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        int current_community = d_community[idx];
        int start = 0;
        int end = graph.d_degree[idx];
        float total_weight = 0.0f;
        float community_weight = 0.0f;
        float total_degree = 0.0f;

        for (int i = 0; i < NUM_NODES; i++) {
            total_degree += graph.d_degree[i];
        }

        for (int i = start; i < end; i++) {
            int neighbor = graph.d_edges[i];
            int weight = graph.d_edge_weights[i];
            total_weight += weight;
            if (d_community[neighbor] == current_community) {
                community_weight += weight;
            }
        }

        float k_i = graph.d_degree[idx];
        float m = total_degree / 2.0f;
        float gain = (community_weight / m) - (k_i * k_i / (m * m));

        d_gain[idx] = gain;
        d_new_community[idx] = current_community;

        // Check all neighbors for better community
        for (int i = start; i < end; i++) {
            int neighbor = graph.d_edges[i];
            int neighbor_community = d_community[neighbor];
            if (neighbor_community != current_community) {
                float neighbor_community_weight = 0.0f;
                for (int j = 0; j < NUM_NODES; j++) {
                    if (d_community[j] == neighbor_community) {
                        neighbor_community_weight += graph.d_degree[j];
                    }
                }
                float new_gain = (neighbor_community_weight / m) - (k_i * k_i / (m * m));
                if (new_gain > gain) {
                    gain = new_gain;
                    d_new_community[idx] = neighbor_community;
                }
            }
        }
    }
}

// Kernel to update communities
__global__ void updateCommunities(int* d_new_community) {
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    if (idx < NUM_NODES) {
        d_community[idx] = d_new_community[idx];
    }
}

// Function to check for errors in CUDA calls
void checkCudaError(hipError_t err, const char* msg) {
    if (err != hipSuccess) {
        std::cerr << "CUDA error: " << msg << " (" << hipGetErrorString(err) << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main() {
    // Initialize random number generator
    hiprandGenerator_t gen;
    hiprandCreateGenerator(&gen, HIPRAND_RNG_PSEUDO_DEFAULT);
    hiprandSetPseudoRandomGeneratorSeed(gen, 1234ULL);

    // Allocate and initialize graph data on device
    Graph d_graph;
    int* h_edges = new int[NUM_NODES * 16]; // Example adjacency list
    int* h_edge_weights = new int[NUM_NODES * 16]; // Example edge weights
    int* h_degree = new int[NUM_NODES]; // Example degrees

    // Initialize edges and weights randomly
    hiprandGenerate(gen, (unsigned int*)h_edges, NUM_NODES * 16);
    hiprandGenerate(gen, (unsigned int*)h_edge_weights, NUM_NODES * 16);
    for (int i = 0; i < NUM_NODES; i++) {
        h_degree[i] = 16; // Each node has 16 edges
    }

    checkCudaError(hipMalloc((void**)&d_graph.d_edges, NUM_NODES * 16 * sizeof(int)), "Allocating d_graph.d_edges");
    checkCudaError(hipMalloc((void**)&d_graph.d_edge_weights, NUM_NODES * 16 * sizeof(int)), "Allocating d_graph.d_edge_weights");
    checkCudaError(hipMalloc((void**)&d_graph.d_degree, NUM_NODES * sizeof(int)), "Allocating d_graph.d_degree");

    checkCudaError(hipMemcpy(d_graph.d_edges, h_edges, NUM_NODES * 16 * sizeof(int), hipMemcpyHostToDevice), "Copying h_edges to d_graph.d_edges");
    checkCudaError(hipMemcpy(d_graph.d_edge_weights, h_edge_weights, NUM_NODES * 16 * sizeof(int), hipMemcpyHostToDevice), "Copying h_edge_weights to d_graph.d_edge_weights");
    checkCudaError(hipMemcpy(d_graph.d_degree, h_degree, NUM_NODES * sizeof(int), hipMemcpyHostToDevice), "Copying h_degree to d_graph.d_degree");

    // Allocate and initialize other device data
    float* d_gain;
    int* d_new_community;
    checkCudaError(hipMalloc((void**)&d_gain, NUM_NODES * sizeof(float)), "Allocating d_gain");
    checkCudaError(hipMalloc((void**)&d_new_community, NUM_NODES * sizeof(int)), "Allocating d_new_community");

    // Initialize communities
    int numBlocks = (NUM_NODES + BLOCK_SIZE - 1) / BLOCK_SIZE;
    initializeCommunities<<<numBlocks, BLOCK_SIZE>>>();
    checkCudaError(hipGetLastError(), "Kernel launch failed: initializeCommunities");

    // Compute total degree
    computeTotalDegree<<<numBlocks, BLOCK_SIZE>>>(d_graph);
    checkCudaError(hipGetLastError(), "Kernel launch failed: computeTotalDegree");

    // Main loop for community detection
    bool changed = true;
    while (changed) {
        changed = false;

        // Compute modularity gain
        computeModularityGain<<<numBlocks, BLOCK_SIZE>>>(d_graph, d_gain, d_new_community);
        checkCudaError(hipGetLastError(), "Kernel launch failed: computeModularityGain");

        // Update communities
        updateCommunities<<<numBlocks, BLOCK_SIZE>>>(d_new_community);
        checkCudaError(hipGetLastError(), "Kernel launch failed: updateCommunities");

        // Check if any community changed
        int* h_new_community = new int[NUM_NODES];
        checkCudaError(hipMemcpy(h_new_community, d_new_community, NUM_NODES * sizeof(int), hipMemcpyDeviceToHost), "Copying d_new_community to h_new_community");

        for (int i = 0; i < NUM_NODES; i++) {
            if (h_new_community[i] != d_community[i]) {
                changed = true;
                break;
            }
        }

        delete[] h_new_community;
    }

    // Free device memory
    hipFree(d_graph.d_edges);
    hipFree(d_graph.d_edge_weights);
    hipFree(d_graph.d_degree);
    hipFree(d_gain);
    hipFree(d_new_community);

    // Free host memory
    delete[] h_edges;
    delete[] h_edge_weights;
    delete[] h_degree;

    // Destroy random number generator
    hiprandDestroyGenerator(gen);

    std::cout << "Community detection completed." << std::endl;
    return 0;
}
	.text
	.file	"cuda_code_086306.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z36__device_stub__initializeCommunitiesv # -- Begin function _Z36__device_stub__initializeCommunitiesv
	.type	_Z36__device_stub__initializeCommunitiesv,@function
_Z36__device_stub__initializeCommunitiesv: # @_Z36__device_stub__initializeCommunitiesv
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rbx
	leaq	24(%rsp), %r14
	leaq	16(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	__hipPopCallConfiguration
	movq	(%rbx), %rsi
	movl	8(%rbx), %edx
	movq	(%r14), %rcx
	movl	8(%r14), %r8d
	movq	%rsp, %r9
	movl	$_Z21initializeCommunitiesv, %edi
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	pushq	(%r15)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z36__device_stub__initializeCommunitiesv, .Lfunc_end0-_Z36__device_stub__initializeCommunitiesv
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__computeTotalDegree5Graph # -- Begin function _Z33__device_stub__computeTotalDegree5Graph
	.type	_Z33__device_stub__computeTotalDegree5Graph,@function
_Z33__device_stub__computeTotalDegree5Graph: # @_Z33__device_stub__computeTotalDegree5Graph
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	112(%rsp), %rax
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z18computeTotalDegree5Graph, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z33__device_stub__computeTotalDegree5Graph, .Lfunc_end1-_Z33__device_stub__computeTotalDegree5Graph
	.cfi_endproc
                                        # -- End function
	.globl	_Z36__device_stub__computeModularityGain5GraphPfPi # -- Begin function _Z36__device_stub__computeModularityGain5GraphPfPi
	.type	_Z36__device_stub__computeModularityGain5GraphPfPi,@function
_Z36__device_stub__computeModularityGain5GraphPfPi: # @_Z36__device_stub__computeModularityGain5GraphPfPi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	144(%rsp), %rdx
	leaq	64(%rsp), %rbx
	movq	%rdx, (%rbx)
	movq	%rax, 8(%rbx)
	movq	%rcx, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%rsp, %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z21computeModularityGain5GraphPfPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z36__device_stub__computeModularityGain5GraphPfPi, .Lfunc_end2-_Z36__device_stub__computeModularityGain5GraphPfPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__updateCommunitiesPi # -- Begin function _Z32__device_stub__updateCommunitiesPi
	.type	_Z32__device_stub__updateCommunitiesPi,@function
_Z32__device_stub__updateCommunitiesPi: # @_Z32__device_stub__updateCommunitiesPi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z17updateCommunitiesPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z32__device_stub__updateCommunitiesPi, .Lfunc_end3-_Z32__device_stub__updateCommunitiesPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z14checkCudaError10hipError_tPKc # -- Begin function _Z14checkCudaError10hipError_tPKc
	.type	_Z14checkCudaError10hipError_tPKc,@function
_Z14checkCudaError10hipError_tPKc:      # @_Z14checkCudaError10hipError_tPKc
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB4_2
# %bb.1:
	retq
.LBB4_2:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %r14
	movl	%edi, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.1, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %r14
	movl	%ebx, %edi
	callq	hipGetErrorString
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	_Z14checkCudaError10hipError_tPKc, .Lfunc_end4-_Z14checkCudaError10hipError_tPKc
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	64(%rsp), %r12
	movq	%r12, %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hiprandCreateGenerator
	movq	(%r12), %rdi
	movl	$1234, %esi                     # imm = 0x4D2
	callq	hiprandSetPseudoRandomGeneratorSeed
	movl	$524288, %edi                   # imm = 0x80000
	callq	_Znam
	movq	%rax, %rbx
	movl	$524288, %edi                   # imm = 0x80000
	callq	_Znam
	movq	%rax, %r14
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znam
	movq	%rax, %r15
	movq	(%r12), %rdi
	movl	$131072, %edx                   # imm = 0x20000
	movq	%rbx, %rsi
	callq	hiprandGenerate
	movq	(%r12), %rdi
	movl	$131072, %edx                   # imm = 0x20000
	movq	%r14, %rsi
	callq	hiprandGenerate
	xorl	%eax, %eax
.LBB5_1:                                # =>This Inner Loop Header: Depth=1
	movl	$16, (%r15,%rax,4)
	incq	%rax
	cmpq	$8192, %rax                     # imm = 0x2000
	jne	.LBB5_1
# %bb.2:
	movabsq	$4294967328, %r12               # imm = 0x100000020
	leaq	32(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	callq	hipMalloc
	movl	$.L.str.3, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	leaq	40(%rsp), %rdi
	movl	$524288, %esi                   # imm = 0x80000
	callq	hipMalloc
	movl	$.L.str.4, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	leaq	48(%rsp), %r13
	movl	$32768, %esi                    # imm = 0x8000
	movq	%r13, %rdi
	callq	hipMalloc
	movl	$.L.str.5, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	movq	-16(%r13), %rdi
	movl	$524288, %edx                   # imm = 0x80000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.6, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	movq	-8(%r13), %rdi
	movl	$524288, %edx                   # imm = 0x80000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.7, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	movq	(%r13), %rdi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.8, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	leaq	56(%rsp), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movl	$.L.str.9, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	leaq	24(%rsp), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movl	$.L.str.10, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	leaq	224(%r12), %r13
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_4
# %bb.3:
	callq	_Z36__device_stub__initializeCommunitiesv
.LBB5_4:
	callq	hipGetLastError
	movl	$.L.str.11, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.5:
	movq	48(%rsp), %rax
	movq	%rax, 16(%rsp)
	movups	32(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z33__device_stub__computeTotalDegree5Graph
.LBB5_6:                                # %.critedge
	callq	hipGetLastError
	movl	$.L.str.12, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
.LBB5_7:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_13 Depth 2
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_9
# %bb.8:                                #   in Loop: Header=BB5_7 Depth=1
	movq	56(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	48(%rsp), %rax
	movq	%rax, 16(%rsp)
	movups	32(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	callq	_Z36__device_stub__computeModularityGain5GraphPfPi
.LBB5_9:                                #   in Loop: Header=BB5_7 Depth=1
	callq	hipGetLastError
	movl	$.L.str.13, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_11
# %bb.10:                               #   in Loop: Header=BB5_7 Depth=1
	movq	24(%rsp), %rdi
	callq	_Z32__device_stub__updateCommunitiesPi
.LBB5_11:                               #   in Loop: Header=BB5_7 Depth=1
	callq	hipGetLastError
	movl	$.L.str.14, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znam
	movq	%rax, %rbp
	movq	24(%rsp), %rsi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rax, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.15, %esi
	movl	%eax, %edi
	callq	_Z14checkCudaError10hipError_tPKc
	xorl	%eax, %eax
.LBB5_13:                               #   Parent Loop BB5_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rbp,%rax), %ecx
	cmpl	d_community(%rax), %ecx
	jne	.LBB5_14
# %bb.12:                               #   in Loop: Header=BB5_13 Depth=2
	addq	$4, %rax
	cmpq	$32768, %rax                    # imm = 0x8000
	jne	.LBB5_13
	jmp	.LBB5_15
.LBB5_14:                               #   in Loop: Header=BB5_7 Depth=1
	movq	%rbp, %rdi
	callq	_ZdaPv
	jmp	.LBB5_7
.LBB5_15:
	movq	%rbp, %rdi
	callq	_ZdaPv
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	56(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	%r15, %rdi
	callq	_ZdaPv
	movq	64(%rsp), %rdi
	callq	hiprandDestroyGenerator
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.16, %esi
	movl	$30, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z21initializeCommunitiesv, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18computeTotalDegree5Graph, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z21computeModularityGain5GraphPfPi, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17updateCommunitiesPi, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$d_community, %esi
	movl	$.L__unnamed_5, %edx
	movl	$.L__unnamed_5, %ecx
	movl	$32768, %r9d                    # imm = 0x8000
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$d_modularity, %esi
	movl	$.L__unnamed_6, %edx
	movl	$.L__unnamed_6, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$d_max_community, %esi
	movl	$.L__unnamed_7, %edx
	movl	$.L__unnamed_7, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	d_community,@object             # @d_community
	.local	d_community
	.comm	d_community,32768,16
	.type	d_modularity,@object            # @d_modularity
	.local	d_modularity
	.comm	d_modularity,4,4
	.type	d_max_community,@object         # @d_max_community
	.local	d_max_community
	.comm	d_max_community,4,4
	.type	_Z21initializeCommunitiesv,@object # @_Z21initializeCommunitiesv
	.section	.rodata,"a",@progbits
	.globl	_Z21initializeCommunitiesv
	.p2align	3, 0x0
_Z21initializeCommunitiesv:
	.quad	_Z36__device_stub__initializeCommunitiesv
	.size	_Z21initializeCommunitiesv, 8

	.type	_Z18computeTotalDegree5Graph,@object # @_Z18computeTotalDegree5Graph
	.globl	_Z18computeTotalDegree5Graph
	.p2align	3, 0x0
_Z18computeTotalDegree5Graph:
	.quad	_Z33__device_stub__computeTotalDegree5Graph
	.size	_Z18computeTotalDegree5Graph, 8

	.type	_Z21computeModularityGain5GraphPfPi,@object # @_Z21computeModularityGain5GraphPfPi
	.globl	_Z21computeModularityGain5GraphPfPi
	.p2align	3, 0x0
_Z21computeModularityGain5GraphPfPi:
	.quad	_Z36__device_stub__computeModularityGain5GraphPfPi
	.size	_Z21computeModularityGain5GraphPfPi, 8

	.type	_Z17updateCommunitiesPi,@object # @_Z17updateCommunitiesPi
	.globl	_Z17updateCommunitiesPi
	.p2align	3, 0x0
_Z17updateCommunitiesPi:
	.quad	_Z32__device_stub__updateCommunitiesPi
	.size	_Z17updateCommunitiesPi, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CUDA error: "
	.size	.L.str, 13

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" ("
	.size	.L.str.1, 3

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	")"
	.size	.L.str.2, 2

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Allocating d_graph.d_edges"
	.size	.L.str.3, 27

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Allocating d_graph.d_edge_weights"
	.size	.L.str.4, 34

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Allocating d_graph.d_degree"
	.size	.L.str.5, 28

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Copying h_edges to d_graph.d_edges"
	.size	.L.str.6, 35

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Copying h_edge_weights to d_graph.d_edge_weights"
	.size	.L.str.7, 49

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Copying h_degree to d_graph.d_degree"
	.size	.L.str.8, 37

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Allocating d_gain"
	.size	.L.str.9, 18

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Allocating d_new_community"
	.size	.L.str.10, 27

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Kernel launch failed: initializeCommunities"
	.size	.L.str.11, 44

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Kernel launch failed: computeTotalDegree"
	.size	.L.str.12, 41

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Kernel launch failed: computeModularityGain"
	.size	.L.str.13, 44

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Kernel launch failed: updateCommunities"
	.size	.L.str.14, 40

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Copying d_new_community to h_new_community"
	.size	.L.str.15, 43

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Community detection completed."
	.size	.L.str.16, 31

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z21initializeCommunitiesv"
	.size	.L__unnamed_1, 27

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z18computeTotalDegree5Graph"
	.size	.L__unnamed_2, 29

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z21computeModularityGain5GraphPfPi"
	.size	.L__unnamed_3, 36

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_Z17updateCommunitiesPi"
	.size	.L__unnamed_4, 24

	.type	.L__unnamed_5,@object           # @4
.L__unnamed_5:
	.asciz	"d_community"
	.size	.L__unnamed_5, 12

	.type	.L__unnamed_6,@object           # @5
.L__unnamed_6:
	.asciz	"d_modularity"
	.size	.L__unnamed_6, 13

	.type	.L__unnamed_7,@object           # @6
.L__unnamed_7:
	.asciz	"d_max_community"
	.size	.L__unnamed_7, 16

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z36__device_stub__initializeCommunitiesv
	.addrsig_sym _Z33__device_stub__computeTotalDegree5Graph
	.addrsig_sym _Z36__device_stub__computeModularityGain5GraphPfPi
	.addrsig_sym _Z32__device_stub__updateCommunitiesPi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym d_community
	.addrsig_sym d_modularity
	.addrsig_sym d_max_community
	.addrsig_sym _Z21initializeCommunitiesv
	.addrsig_sym _Z18computeTotalDegree5Graph
	.addrsig_sym _Z21computeModularityGain5GraphPfPi
	.addrsig_sym _Z17updateCommunitiesPi
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z21initializeCommunitiesv ; -- Begin function _Z21initializeCommunitiesv
	.globl	_Z21initializeCommunitiesv
	.p2align	8
	.type	_Z21initializeCommunitiesv,@function
_Z21initializeCommunitiesv:             ; @_Z21initializeCommunitiesv
; %bb.0:
	s_load_b32 s0, s[0:1], 0xc
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s0, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	s_mov_b32 s0, exec_lo
	v_cmpx_gt_i32_e32 0x2000, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_ashrrev_i32_e32 v2, 31, v1
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_community@rel32@lo+4
	s_addc_u32 s1, s1, d_community@rel32@hi+12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, v2, s0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	global_store_b32 v[2:3], v1, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21initializeCommunitiesv
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 256
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 4
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z21initializeCommunitiesv, .Lfunc_end0-_Z21initializeCommunitiesv
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 120
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z18computeTotalDegree5Graph ; -- Begin function _Z18computeTotalDegree5Graph
	.globl	_Z18computeTotalDegree5Graph
	.p2align	8
	.type	_Z18computeTotalDegree5Graph,@function
_Z18computeTotalDegree5Graph:           ; @_Z18computeTotalDegree5Graph
; %bb.0:
	s_load_b32 s2, s[0:1], 0x24
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e32 0x2000, v1
	s_cbranch_execz .LBB1_4
; %bb.1:
	s_load_b64 s[2:3], s[0:1], 0x10
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v3, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_load_b32 v2, v[0:1], off
	global_store_b32 v[0:1], v3, off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 0, v2
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_4
; %bb.2:                                ; %.lr.ph.preheader
	s_load_b64 s[0:1], s[0:1], 0x8
	v_mov_b32_e32 v4, 0
	s_mov_b32 s2, 0
.LBB1_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_waitcnt lgkmcnt(0)
	global_load_b32 v5, v3, s[0:1]
	v_add_nc_u32_e32 v2, -1, v2
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v2
	s_or_b32 s2, vcc_lo, s2
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v4, v4, v5
	global_store_b32 v[0:1], v4, off
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB1_3
.LBB1_4:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18computeTotalDegree5Graph
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z18computeTotalDegree5Graph, .Lfunc_end1-_Z18computeTotalDegree5Graph
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 216
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z21computeModularityGain5GraphPfPi ; -- Begin function _Z21computeModularityGain5GraphPfPi
	.globl	_Z21computeModularityGain5GraphPfPi
	.p2align	8
	.type	_Z21computeModularityGain5GraphPfPi,@function
_Z21computeModularityGain5GraphPfPi:    ; @_Z21computeModularityGain5GraphPfPi
; %bb.0:
	s_load_b32 s2, s[0:1], 0x34
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e32 0x2000, v1
	s_cbranch_execz .LBB2_20
; %bb.1:
	s_load_b256 s[4:11], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, d_community@rel32@lo+4
	s_addc_u32 s3, s3, d_community@rel32@hi+12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, v0, s2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v1, vcc_lo
	s_load_b64 s[2:3], s[0:1], 0x20
	s_mov_b64 s[0:1], 0
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	v_mov_b32_e32 v4, 0
.LBB2_2:                                ; =>This Inner Loop Header: Depth=1
	s_add_u32 s12, s8, s0
	s_addc_u32 s13, s9, s1
	s_add_u32 s0, s0, 4
	s_load_b32 s12, s[12:13], 0x0
	s_addc_u32 s1, s1, 0
	s_cmpk_eq_u32 s0, 0x8000
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_i32_e32 v5, s12
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v4, v4, v5
	s_cbranch_scc0 .LBB2_2
; %bb.3:                                ; %.preheader78
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e64 s0, 0, v3
	v_mov_b32_e32 v5, 0
	s_mov_b32 s14, 0
	s_delay_alu instid0(VALU_DEP_2)
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB2_9
; %bb.4:                                ; %.lr.ph.preheader
	v_dual_mov_b32 v5, 0 :: v_dual_mov_b32 v6, v3
	s_mov_b64 s[12:13], s[4:5]
	s_getpc_b64 s[18:19]
	s_add_u32 s18, s18, d_community@rel32@lo+4
	s_addc_u32 s19, s19, d_community@rel32@hi+12
.LBB2_5:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s16, s[12:13], 0x0
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s17, s16, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[16:17], s[16:17], 2
	s_add_u32 s16, s16, s18
	s_addc_u32 s17, s17, s19
	s_load_b32 s15, s[16:17], 0x0
	s_waitcnt lgkmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, s15, v2
	s_and_saveexec_b32 s15, vcc_lo
	s_cbranch_execz .LBB2_7
; %bb.6:                                ;   in Loop: Header=BB2_5 Depth=1
	s_load_b32 s16, s[6:7], 0x0
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_i32_e32 v7, s16
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v5, v5, v7
.LBB2_7:                                ;   in Loop: Header=BB2_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s15
	v_add_nc_u32_e32 v6, -1, v6
	s_add_u32 s12, s12, 4
	s_addc_u32 s13, s13, 0
	s_add_u32 s6, s6, 4
	s_addc_u32 s7, s7, 0
	v_cmp_eq_u32_e32 vcc_lo, 0, v6
	s_or_b32 s14, vcc_lo, s14
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s14
	s_cbranch_execnz .LBB2_5
; %bb.8:                                ; %Flow114
	s_or_b32 exec_lo, exec_lo, s14
.LBB2_9:                                ; %Flow115
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s1
	v_cvt_f32_i32_e32 v6, v3
	v_mul_f32_e32 v4, 0.5, v4
	v_dual_mul_f32 v6, v6, v6 :: v_dual_mul_f32 v7, v4, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_scale_f32 v9, null, v7, v7, v6
	v_rcp_f32_e32 v11, v9
	s_waitcnt_depctr 0xfff
	v_fma_f32 v13, -v9, v11, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_fmac_f32_e32 v11, v13, v11
	v_div_scale_f32 v8, null, v4, v4, v5
	v_div_scale_f32 v14, vcc_lo, v5, v4, v5
	v_rcp_f32_e32 v10, v8
	s_waitcnt_depctr 0xfff
	v_fma_f32 v12, -v8, v10, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v10, v12, v10
	v_div_scale_f32 v12, s1, v6, v7, v6
	v_mul_f32_e32 v15, v12, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v17, -v9, v15, v12
	v_fmac_f32_e32 v15, v17, v11
	v_mul_f32_e32 v13, v14, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v9, -v9, v15, v12
	v_fma_f32 v16, -v8, v13, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v13, v16, v10
	v_fma_f32 v8, -v8, v13, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_div_fmas_f32 v8, v8, v10, v13
	s_mov_b32 vcc_lo, s1
	v_div_fmas_f32 v9, v9, v11, v15
	v_div_fixup_f32 v10, v8, v4, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_div_fixup_f32 v5, v9, v7, v6
	v_add_co_u32 v7, vcc_lo, s10, v0
	v_add_co_ci_u32_e32 v8, vcc_lo, s11, v1, vcc_lo
	v_sub_f32_e32 v6, v10, v5
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[7:8], v6, off
	global_store_b32 v[0:1], v2, off
	s_and_b32 exec_lo, exec_lo, s0
	s_cbranch_execz .LBB2_20
; %bb.10:                               ; %.lr.ph88.preheader
	v_mov_b32_e32 v7, 0
	s_mov_b32 s1, 0
	s_mov_b32 s6, 0
	s_mov_b32 s0, s1
.LBB2_11:                               ; %.lr.ph88
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB2_13 Depth 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b64 s[2:3], s[0:1], 2
	s_mov_b32 s7, exec_lo
	s_add_u32 s2, s4, s2
	s_addc_u32 s3, s5, s3
	global_load_b32 v8, v7, s[2:3]
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, d_community@rel32@lo+4
	s_addc_u32 s3, s3, d_community@rel32@hi+12
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v9, 31, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[8:9], 2, v[8:9]
	v_add_co_u32 v8, vcc_lo, v8, s2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v9, vcc_lo, s3, v9, vcc_lo
	global_load_b32 v8, v[8:9], off
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u32_e64 v8, v2
	s_cbranch_execz .LBB2_19
; %bb.12:                               ; %.preheader.preheader
                                        ;   in Loop: Header=BB2_11 Depth=1
	v_mov_b32_e32 v9, 0
	s_mov_b64 s[2:3], 0
.LBB2_13:                               ; %.preheader
                                        ;   Parent Loop BB2_11 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_getpc_b64 s[10:11]
	s_add_u32 s10, s10, d_community@rel32@lo+4
	s_addc_u32 s11, s11, d_community@rel32@hi+12
	s_add_u32 s10, s2, s10
	s_addc_u32 s11, s3, s11
	global_load_b32 v10, v7, s[10:11]
	s_waitcnt vmcnt(0)
	v_cmp_ne_u32_e32 vcc_lo, v10, v8
	s_cbranch_vccnz .LBB2_15
; %bb.14:                               ;   in Loop: Header=BB2_13 Depth=2
	s_add_u32 s10, s8, s2
	s_addc_u32 s11, s9, s3
	global_load_b32 v10, v7, s[10:11]
	s_waitcnt vmcnt(0)
	v_cvt_f32_i32_e32 v10, v10
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v9, v9, v10
.LBB2_15:                               ;   in Loop: Header=BB2_13 Depth=2
	s_add_u32 s2, s2, 4
	s_addc_u32 s3, s3, 0
	s_cmpk_eq_u32 s2, 0x8000
	s_cbranch_scc0 .LBB2_13
; %bb.16:                               ;   in Loop: Header=BB2_11 Depth=1
	v_div_scale_f32 v10, null, v4, v4, v9
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v11, v10
	s_waitcnt_depctr 0xfff
	v_fma_f32 v12, -v10, v11, 1.0
	v_fmac_f32_e32 v11, v12, v11
	v_div_scale_f32 v12, vcc_lo, v9, v4, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v13, v12, v11
	v_fma_f32 v14, -v10, v13, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v13, v14, v11
	v_fma_f32 v10, -v10, v13, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fmas_f32 v10, v10, v11, v13
	v_div_fixup_f32 v9, v10, v4, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v9, v9, v5
	v_cmpx_gt_f32_e32 v9, v6
	s_cbranch_execz .LBB2_18
; %bb.17:                               ;   in Loop: Header=BB2_11 Depth=1
	v_mov_b32_e32 v6, v9
	global_store_b32 v[0:1], v8, off
.LBB2_18:                               ; %Flow
                                        ;   in Loop: Header=BB2_11 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
.LBB2_19:                               ; %Flow111
                                        ;   in Loop: Header=BB2_11 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s7
	s_add_i32 s0, s0, 1
	v_cmp_eq_u32_e32 vcc_lo, s0, v3
	s_or_b32 s6, vcc_lo, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s6
	s_cbranch_execnz .LBB2_11
.LBB2_20:                               ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z21computeModularityGain5GraphPfPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 18
		.amdhsa_next_free_sgpr 20
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z21computeModularityGain5GraphPfPi, .Lfunc_end2-_Z21computeModularityGain5GraphPfPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1060
; NumSgprs: 22
; NumVgprs: 18
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 22
; NumVGPRsForWavesPerEU: 18
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z17updateCommunitiesPi ; -- Begin function _Z17updateCommunitiesPi
	.globl	_Z17updateCommunitiesPi
	.p2align	8
	.type	_Z17updateCommunitiesPi,@function
_Z17updateCommunitiesPi:                ; @_Z17updateCommunitiesPi
; %bb.0:
	s_load_b32 s2, s[0:1], 0x14
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e32 0x2000, v1
	s_cbranch_execz .LBB3_2
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, d_community@rel32@lo+4
	s_addc_u32 s1, s1, d_community@rel32@hi+12
	v_add_co_u32 v0, vcc_lo, v0, s0
	global_load_b32 v2, v[2:3], off
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b32 v[0:1], v2, off
.LBB3_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17updateCommunitiesPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 4
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end3:
	.size	_Z17updateCommunitiesPi, .Lfunc_end3-_Z17updateCommunitiesPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 156
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	d_community             ; @d_community
	.type	d_community,@object
	.section	.bss,"aw",@nobits
	.globl	d_community
	.p2align	4, 0x0
d_community:
	.zero	32768
	.size	d_community, 32768

	.protected	d_modularity            ; @d_modularity
	.type	d_modularity,@object
	.globl	d_modularity
	.p2align	2, 0x0
d_modularity:
	.long	0x00000000                      ; float 0
	.size	d_modularity, 4

	.protected	d_max_community         ; @d_max_community
	.type	d_max_community,@object
	.globl	d_max_community
	.p2align	2, 0x0
d_max_community:
	.long	0                               ; 0x0
	.size	d_max_community, 4

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym d_community
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         4
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         12
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         14
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         16
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         18
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         20
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         22
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         40
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         64
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 256
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z21initializeCommunitiesv
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z21initializeCommunitiesv.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           24
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18computeTotalDegree5Graph
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z18computeTotalDegree5Graph.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           24
        .value_kind:     by_value
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z21computeModularityGain5GraphPfPi
    .private_segment_fixed_size: 0
    .sgpr_count:     22
    .sgpr_spill_count: 0
    .symbol:         _Z21computeModularityGain5GraphPfPi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     18
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17updateCommunitiesPi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17updateCommunitiesPi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
