diff -ur a/maint/local_python/binding_c.py b/maint/local_python/binding_c.py
--- a/maint/local_python/binding_c.py	2022-11-07 14:04:34.000000000 +0100
+++ b/maint/local_python/binding_c.py	2022-11-07 14:00:46.000000000 +0100
@@ -1465,10 +1465,10 @@
             replace_arg('rdispls', 'tmp_array + outdegree * 2 + indegree')
         else: # neighbor_alltoallw
             allocate_tmp_array("(outdegree + indegree)")
-            swap_one("indegree", "sendcounts")
-            swap_next("indegree", "outdegree", "recvcounts")
+            swap_one("outdegree", "sendcounts")
+            swap_next("outdegree", "indegree", "recvcounts")
             replace_arg('sendcounts', 'tmp_array')
-            replace_arg('recvcounts', 'tmp_array + indegree')
+            replace_arg('recvcounts', 'tmp_array + outdegree')
     # classical collectives
     elif RE.match(r'(mpi_i?reduce_scatter(_init)?\b)', func['name'], re.IGNORECASE):
         G.out.append("int n = comm_ptr->local_size;")
diff -ur a/src/binding/c/coll/ineighbor_alltoallw.c b/src/binding/c/coll/ineighbor_alltoallw.c
--- a/src/binding/c/coll/ineighbor_alltoallw.c	2022-11-07 16:02:54.000000000 +0100
+++ b/src/binding/c/coll/ineighbor_alltoallw.c	2022-11-07 16:03:00.000000000 +0100
@@ -118,15 +118,15 @@
     int indegree, outdegree, weighted;
     mpi_errno = MPIR_Topo_canon_nhb_count(comm_ptr, &indegree, &outdegree, &weighted);
     MPI_Aint *tmp_array = MPL_malloc((outdegree + indegree) * sizeof(MPI_Aint), MPL_MEM_OTHER);
-    for (int i = 0; i < indegree; i++) {
+    for (int i = 0; i < outdegree; i++) {
         tmp_array[i] = sendcounts[i];
     }
-    for (int i = 0; i < outdegree; i++) {
-        tmp_array[indegree + i] = recvcounts[i];
+    for (int i = 0; i < indegree; i++) {
+        tmp_array[outdegree + i] = recvcounts[i];
     }
     MPIR_Request *request_ptr = NULL;
     mpi_errno = MPIR_Ineighbor_alltoallw(sendbuf, tmp_array, sdispls, sendtypes, recvbuf,
-                                         tmp_array + indegree, rdispls, recvtypes, comm_ptr,
+                                         tmp_array + outdegree, rdispls, recvtypes, comm_ptr,
                                          &request_ptr);
     if (mpi_errno) {
         goto fn_fail;
@@ -324,7 +324,7 @@
         int indegree, outdegree, weighted;
         mpi_errno = MPIR_Topo_canon_nhb_count(comm_ptr, &indegree, &outdegree, &weighted);
         MPI_Aint *tmp_array = MPL_malloc((outdegree + indegree) * sizeof(MPI_Aint), MPL_MEM_OTHER);
-        for (int i = 0; i < indegree; i++) {
+        for (int i = 0; i < outdegree; i++) {
             if (sendcounts[i] > MPIR_AINT_MAX) {
                 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
                                                  __func__, __LINE__, MPI_ERR_OTHER,
@@ -334,7 +334,7 @@
             }
             tmp_array[i] = sendcounts[i];
         }
-        for (int i = 0; i < outdegree; i++) {
+        for (int i = 0; i < indegree; i++) {
             if (recvcounts[i] > MPIR_AINT_MAX) {
                 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
                                                  __func__, __LINE__, MPI_ERR_OTHER,
@@ -342,11 +342,11 @@
                                                  "**too_big_for_input %s", "recvcounts[i]");
                 goto fn_fail;
             }
-            tmp_array[indegree + i] = recvcounts[i];
+            tmp_array[outdegree + i] = recvcounts[i];
         }
         MPIR_Request *request_ptr = NULL;
         mpi_errno = MPIR_Ineighbor_alltoallw(sendbuf, tmp_array, sdispls, sendtypes, recvbuf,
-                                             tmp_array + indegree, rdispls, recvtypes, comm_ptr,
+                                             tmp_array + outdegree, rdispls, recvtypes, comm_ptr,
                                              &request_ptr);
         if (mpi_errno) {
             goto fn_fail;
diff -ur a/src/binding/c/coll/neighbor_alltoallw.c b/src/binding/c/coll/neighbor_alltoallw.c
--- a/src/binding/c/coll/neighbor_alltoallw.c	2022-11-07 16:02:54.000000000 +0100
+++ b/src/binding/c/coll/neighbor_alltoallw.c	2022-11-07 16:03:00.000000000 +0100
@@ -116,14 +116,14 @@
     int indegree, outdegree, weighted;
     mpi_errno = MPIR_Topo_canon_nhb_count(comm_ptr, &indegree, &outdegree, &weighted);
     MPI_Aint *tmp_array = MPL_malloc((outdegree + indegree) * sizeof(MPI_Aint), MPL_MEM_OTHER);
-    for (int i = 0; i < indegree; i++) {
+    for (int i = 0; i < outdegree; i++) {
         tmp_array[i] = sendcounts[i];
     }
-    for (int i = 0; i < outdegree; i++) {
-        tmp_array[indegree + i] = recvcounts[i];
+    for (int i = 0; i < indegree; i++) {
+        tmp_array[outdegree + i] = recvcounts[i];
     }
     mpi_errno = MPIR_Neighbor_alltoallw(sendbuf, tmp_array, sdispls, sendtypes, recvbuf,
-                                        tmp_array + indegree, rdispls, recvtypes, comm_ptr);
+                                        tmp_array + outdegree, rdispls, recvtypes, comm_ptr);
     if (mpi_errno) {
         goto fn_fail;
     }
@@ -306,7 +306,7 @@
         int indegree, outdegree, weighted;
         mpi_errno = MPIR_Topo_canon_nhb_count(comm_ptr, &indegree, &outdegree, &weighted);
         MPI_Aint *tmp_array = MPL_malloc((outdegree + indegree) * sizeof(MPI_Aint), MPL_MEM_OTHER);
-        for (int i = 0; i < indegree; i++) {
+        for (int i = 0; i < outdegree; i++) {
             if (sendcounts[i] > MPIR_AINT_MAX) {
                 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
                                                  __func__, __LINE__, MPI_ERR_OTHER,
@@ -316,7 +316,7 @@
             }
             tmp_array[i] = sendcounts[i];
         }
-        for (int i = 0; i < outdegree; i++) {
+        for (int i = 0; i < indegree; i++) {
             if (recvcounts[i] > MPIR_AINT_MAX) {
                 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
                                                  __func__, __LINE__, MPI_ERR_OTHER,
@@ -324,10 +324,10 @@
                                                  "**too_big_for_input %s", "recvcounts[i]");
                 goto fn_fail;
             }
-            tmp_array[indegree + i] = recvcounts[i];
+            tmp_array[outdegree + i] = recvcounts[i];
         }
         mpi_errno = MPIR_Neighbor_alltoallw(sendbuf, tmp_array, sdispls, sendtypes, recvbuf,
-                                            tmp_array + indegree, rdispls, recvtypes, comm_ptr);
+                                            tmp_array + outdegree, rdispls, recvtypes, comm_ptr);
         if (mpi_errno) {
             goto fn_fail;
         }
diff -ur a/src/binding/c/coll/neighbor_alltoallw_init.c b/src/binding/c/coll/neighbor_alltoallw_init.c
--- a/src/binding/c/coll/neighbor_alltoallw_init.c	2022-11-07 16:02:54.000000000 +0100
+++ b/src/binding/c/coll/neighbor_alltoallw_init.c	2022-11-07 16:03:00.000000000 +0100
@@ -131,15 +131,15 @@
     int indegree, outdegree, weighted;
     mpi_errno = MPIR_Topo_canon_nhb_count(comm_ptr, &indegree, &outdegree, &weighted);
     MPI_Aint *tmp_array = MPL_malloc((outdegree + indegree) * sizeof(MPI_Aint), MPL_MEM_OTHER);
-    for (int i = 0; i < indegree; i++) {
+    for (int i = 0; i < outdegree; i++) {
         tmp_array[i] = sendcounts[i];
     }
-    for (int i = 0; i < outdegree; i++) {
-        tmp_array[indegree + i] = recvcounts[i];
+    for (int i = 0; i < indegree; i++) {
+        tmp_array[outdegree + i] = recvcounts[i];
     }
     MPIR_Request *request_ptr = NULL;
     mpi_errno = MPIR_Neighbor_alltoallw_init(sendbuf, tmp_array, sdispls, sendtypes, recvbuf,
-                                             tmp_array + indegree, rdispls, recvtypes, comm_ptr,
+                                             tmp_array + outdegree, rdispls, recvtypes, comm_ptr,
                                              info_ptr, &request_ptr);
     if (mpi_errno) {
         goto fn_fail;
@@ -355,7 +355,7 @@
         int indegree, outdegree, weighted;
         mpi_errno = MPIR_Topo_canon_nhb_count(comm_ptr, &indegree, &outdegree, &weighted);
         MPI_Aint *tmp_array = MPL_malloc((outdegree + indegree) * sizeof(MPI_Aint), MPL_MEM_OTHER);
-        for (int i = 0; i < indegree; i++) {
+        for (int i = 0; i < outdegree; i++) {
             if (sendcounts[i] > MPIR_AINT_MAX) {
                 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
                                                  __func__, __LINE__, MPI_ERR_OTHER,
@@ -365,7 +365,7 @@
             }
             tmp_array[i] = sendcounts[i];
         }
-        for (int i = 0; i < outdegree; i++) {
+        for (int i = 0; i < indegree; i++) {
             if (recvcounts[i] > MPIR_AINT_MAX) {
                 mpi_errno = MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE,
                                                  __func__, __LINE__, MPI_ERR_OTHER,
@@ -373,11 +373,11 @@
                                                  "**too_big_for_input %s", "recvcounts[i]");
                 goto fn_fail;
             }
-            tmp_array[indegree + i] = recvcounts[i];
+            tmp_array[outdegree + i] = recvcounts[i];
         }
         MPIR_Request *request_ptr = NULL;
         mpi_errno = MPIR_Neighbor_alltoallw_init(sendbuf, tmp_array, sdispls, sendtypes, recvbuf,
-                                                 tmp_array + indegree, rdispls, recvtypes, comm_ptr,
+                                                 tmp_array + outdegree, rdispls, recvtypes, comm_ptr,
                                                  info_ptr, &request_ptr);
         if (mpi_errno) {
             goto fn_fail;
