{"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
 "version": "2.1.0",
 "runs": [{"tool": {"driver": {"name": "GNU C23",
                               "fullName": "GNU C23 (GCC) version 16.1.1 20260703 (Red Hat 16.1.1-4) (x86_64-redhat-linux)",
                               "version": "16.1.1 20260703 (Red Hat 16.1.1-4)",
                               "informationUri": "https://gcc.gnu.org/gcc-16/",
                               "rules": [{"id": "-Wanalyzer-possible-null-dereference",
                                          "helpUri": "https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-possible-null-dereference"},
                                         {"id": "-Wanalyzer-use-after-free",
                                          "helpUri": "https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-use-after-free"},
                                         {"id": "-Wanalyzer-double-free",
                                          "helpUri": "https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-double-free"}]}},
           "taxonomies": [{"name": "CWE",
                           "version": "4.7",
                           "organization": "MITRE",
                           "shortDescription": {"text": "The MITRE Common Weakness Enumeration"},
                           "taxa": [{"id": "416",
                                     "helpUri": "https://cwe.mitre.org/data/definitions/416.html"},
                                    {"id": "690",
                                     "helpUri": "https://cwe.mitre.org/data/definitions/690.html"},
                                    {"id": "415",
                                     "helpUri": "https://cwe.mitre.org/data/definitions/415.html"}]}],
           "invocations": [{"arguments": ["/usr/libexec/gcc/x86_64-redhat-linux/16/cc1",
                                          "-quiet",
                                          "-I",
                                          "../src/include/",
                                          "-D",
                                          "_GNU_SOURCE",
                                          "proxy.c",
                                          "-quiet",
                                          "-dumpbase",
                                          "proxy.c",
                                          "-dumpbase-ext",
                                          ".c",
                                          "-m64",
                                          "-mtune=generic",
                                          "-march=x86-64",
                                          "-mtls-dialect=gnu2",
                                          "-O2",
                                          "-Wno-unknown-pragmas",
                                          "-flto=auto",
                                          "-ffat-lto-objects",
                                          "-fexceptions",
                                          "-fstack-protector-strong",
                                          "-fasynchronous-unwind-tables",
                                          "-fstack-clash-protection",
                                          "-fcf-protection=full",
                                          "-fno-omit-frame-pointer",
                                          "-fanalyzer",
                                          "-fdiagnostics-path-format=separate-events",
                                          "-fno-diagnostics-show-caret",
                                          "-fno-lto",
                                          "-fanalyzer-assume-nothrow",
                                          "-fdiagnostics-text-art-charset=none",
                                          "-fdiagnostics-set-output=sarif:file=/builddir/gcc-results/6357-HJU1.sarif",
                                          "-o",
                                          "/tmp/cca53ETB.s"],
                            "workingDirectory": {"uri": "/builddir/build/BUILD/liburing-2.13-build/liburing-2.13/examples"},
                            "startTimeUtc": "2026-08-03T18:02:16Z",
                            "executionSuccessful": true,
                            "toolExecutionNotifications": [],
                            "endTimeUtc": "2026-08-03T18:02:20Z"}],
           "originalUriBaseIds": {"PWD": {"uri": "file:///builddir/build/BUILD/liburing-2.13-build/liburing-2.13/examples/"}},
           "artifacts": [{"location": {"uri": "proxy.c",
                                       "uriBaseId": "PWD"},
                          "sourceLanguage": "c",
                          "contents": {"text": "/* SPDX-License-Identifier: MIT */\n/*\n * Sample program that can act either as a packet sink, where it just receives\n * packets and doesn't do anything with them, or it can act as a proxy where it\n * receives packets and then sends them to a new destination. The proxy can\n * be unidirectional (-B0), or bi-direction (-B1).\n * \n * Examples:\n *\n * Act as a proxy, listening on port 4444, and send data to 192.168.2.6 on port\n * 4445. Use multishot receive, DEFER_TASKRUN, and fixed files\n *\n * \t./proxy -m1 -r4444 -H 192.168.2.6 -p4445\n *\n * Same as above, but utilize send bundles (-C1, requires -u1 send_ring) as well\n * with ring provided send buffers, and recv bundles (-c1).\n *\n * \t./proxy -m1 -c1 -u1 -C1 -r4444 -H 192.168.2.6 -p4445\n *\n * Act as a bi-directional proxy, listening on port 8888, and send data back\n * and forth between host and 192.168.2.6 on port 22. Use multishot receive,\n * DEFER_TASKRUN, fixed files, and buffers of size 1500.\n *\n * \t./proxy -m1 -B1 -b1500 -r8888 -H 192.168.2.6 -p22\n *\n * Act a sink, listening on port 4445, using multishot receive, DEFER_TASKRUN,\n * and fixed files:\n *\n * \t./proxy -m1 -s1 -r4445\n *\n * Run with -h to see a list of options, and their defaults.\n *\n * (C) 2024 Jens Axboe <axboe@kernel.dk>\n *\n */\n#include <fcntl.h>\n#include <stdint.h>\n#include <netinet/in.h>\n#include <netinet/tcp.h>\n#include <arpa/inet.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/socket.h>\n#include <sys/time.h>\n#include <unistd.h>\n#include <sys/mman.h>\n#include <linux/mman.h>\n#include <locale.h>\n#include <assert.h>\n#include <pthread.h>\n#include <liburing.h>\n\n#include \"proxy.h\"\n#include \"helpers.h\"\n\n/*\n * Will go away once/if bundles are upstreamed and we put the generic\n * definitions in the kernel header.\n */\n#ifndef IORING_RECVSEND_BUNDLE\n#define IORING_RECVSEND_BUNDLE\t\t(1U << 4)\n#endif\n#ifndef IORING_FEAT_SEND_BUF_SELECT\n#define IORING_FEAT_SEND_BUF_SELECT\t(1U << 14)\n#endif\n\nstatic int cur_bgid = 1;\nstatic int nr_conns;\nstatic int open_conns;\nstatic long page_size;\n\nstatic unsigned long event_loops;\nstatic unsigned long events;\n\nstatic int recv_mshot = 1;\nstatic int sqpoll;\nstatic int defer_tw = 1;\nstatic int is_sink;\nstatic int fixed_files = 1;\nstatic char *host = \"192.168.3.2\";\nstatic int send_port = 4445;\nstatic int receive_port = 4444;\nstatic int buf_size = 32;\nstatic int buf_ring_inc;\nstatic int bidi;\nstatic int ipv6;\nstatic int napi;\nstatic int napi_timeout;\nstatic int wait_batch = 1;\nstatic int wait_usec = 1000000;\nstatic int rcv_msg;\nstatic int snd_msg;\nstatic int snd_zc;\nstatic int send_ring = -1;\nstatic int snd_bundle;\nstatic int rcv_bundle;\nstatic int use_huge;\nstatic int ext_stat;\nstatic int verbose;\n\nstatic int nr_bufs = 256;\nstatic int br_mask;\n\nstatic int ring_size = 128;\n\nstatic pthread_mutex_t thread_lock;\nstatic struct timeval last_housekeeping;\n\n/*\n * For sendmsg/recvmsg. recvmsg just has a single vec, sendmsg will have\n * two vecs - one that is currently submitted and being sent, and one that\n * is being prepared. When a new sendmsg is issued, we'll swap which one we\n * use. For send, even though we don't pass in the iovec itself, we use the\n * vec to serialize the sends to avoid reordering.\n */\nstruct msg_vec {\n\tstruct iovec *iov;\n\t/* length of allocated vec */\n\tint vec_size;\n\t/* length currently being used */\n\tint iov_len;\n\t/* only for send, current index we're processing */\n\tint cur_iov;\n};\n\nstruct io_msg {\n\tstruct msghdr msg;\n\tstruct msg_vec vecs[2];\n\t/* current msg_vec being prepared */\n\tint vec_index;\n};\n\n/*\n * Per socket stats per connection. For bi-directional, we'll have both\n * sends and receives on each socket, this helps track them separately.\n * For sink or one directional, each of the two stats will be only sends\n * or receives, not both.\n */\nstruct conn_dir {\n\tint index;\n\n\tint pending_shutdown;\n\tint pending_send;\n\tint pending_recv;\n\n\tint snd_notif;\n\n\tint out_buffers;\n\n\tint rcv, rcv_shrt, rcv_enobufs, rcv_mshot;\n\tint snd, snd_shrt, snd_enobufs, snd_busy, snd_mshot;\n\n\tint snd_next_bid;\n\tint rcv_next_bid;\n\n\tint *rcv_bucket;\n\tint *snd_bucket;\n\n\tunsigned long in_bytes, out_bytes;\n\n\t/* only ever have a single recv pending */\n\tstruct io_msg io_rcv_msg;\n\n\t/* one send that is inflight, and one being prepared for the next one */\n\tstruct io_msg io_snd_msg;\n};\n\nenum {\n\tCONN_F_STARTED\t\t= 1,\n\tCONN_F_DISCONNECTING\t= 2,\n\tCONN_F_DISCONNECTED\t= 4,\n\tCONN_F_PENDING_SHUTDOWN\t= 8,\n\tCONN_F_STATS_SHOWN\t= 16,\n\tCONN_F_END_TIME\t\t= 32,\n\tCONN_F_REAPED\t\t= 64,\n};\n\n/*\n * buffer ring belonging to a connection\n */\nstruct conn_buf_ring {\n\tstruct io_uring_buf_ring *br;\n\tvoid *buf;\n\tint bgid;\n};\n\nstruct conn {\n\tstruct io_uring ring;\n\n\t/* receive side buffer ring, new data arrives here */\n\tstruct conn_buf_ring in_br;\n\t/* if send_ring is used, outgoing data to send */\n\tstruct conn_buf_ring out_br;\n\n\tint tid;\n\tint in_fd, out_fd;\n\tint pending_cancels;\n\tint flags;\n\n\tstruct conn_dir cd[2];\n\n\tstruct timeval start_time, end_time;\n\n\tunion {\n\t\tstruct sockaddr_in addr;\n\t\tstruct sockaddr_in6 addr6;\n\t};\n\n\tpthread_t thread;\n\tpthread_barrier_t startup_barrier;\n};\n\n#define MAX_CONNS\t1024\nstatic struct conn conns[MAX_CONNS];\n\n#define vlog(str, ...) do {\t\t\t\t\t\t\\\n\tif (verbose)\t\t\t\t\t\t\t\\\n\t\tprintf(str, ##__VA_ARGS__);\t\t\t\t\\\n} while (0)\n\nstatic int prep_next_send(struct io_uring *ring, struct conn *c,\n\t\t\t  struct conn_dir *cd, int fd);\nstatic void *thread_main(void *data);\n\nstatic struct conn *cqe_to_conn(struct io_uring_cqe *cqe)\n{\n\tstruct userdata ud = { .val = cqe->user_data };\n\n\treturn &conns[ud.op_tid & TID_MASK];\n}\n\nstatic struct conn_dir *cqe_to_conn_dir(struct conn *c,\n\t\t\t\t\tstruct io_uring_cqe *cqe)\n{\n\tint fd = cqe_to_fd(cqe);\n\n\treturn &c->cd[fd != c->in_fd];\n}\n\nstatic int other_dir_fd(struct conn *c, int fd)\n{\n\tif (c->in_fd == fd)\n\t\treturn c->out_fd;\n\treturn c->in_fd;\n}\n\n/* currently active msg_vec */\nstatic struct msg_vec *msg_vec(struct io_msg *imsg)\n{\n\treturn &imsg->vecs[imsg->vec_index];\n}\n\nstatic struct msg_vec *snd_msg_vec(struct conn_dir *cd)\n{\n\treturn msg_vec(&cd->io_snd_msg);\n}\n\n/*\n * Goes from accept new connection -> create socket, connect to end\n * point, prepare recv, on receive do send (unless sink). If either ends\n * disconnects, we transition to shutdown and then close.\n */\nenum {\n\t__ACCEPT\t= 1,\n\t__SOCK\t\t= 2,\n\t__CONNECT\t= 3,\n\t__RECV\t\t= 4,\n\t__RECVMSG\t= 5,\n\t__SEND\t\t= 6,\n\t__SENDMSG\t= 7,\n\t__SHUTDOWN\t= 8,\n\t__CANCEL\t= 9,\n\t__CLOSE\t\t= 10,\n\t__FD_PASS\t= 11,\n\t__NOP\t\t= 12,\n\t__STOP\t\t= 13,\n};\n\nstruct error_handler {\n\tconst char *name;\n\tint (*error_fn)(struct error_handler *, struct io_uring *, struct io_uring_cqe *);\n};\n\nstatic int recv_error(struct error_handler *err, struct io_uring *ring,\n\t\t      struct io_uring_cqe *cqe);\nstatic int send_error(struct error_handler *err, struct io_uring *ring,\n\t\t      struct io_uring_cqe *cqe);\n\nstatic int default_error(struct error_handler *err,\n\t\t\t struct io_uring __attribute__((__unused__)) *ring,\n\t\t\t struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\n\tfprintf(stderr, \"%d: %s error %s\\n\", c->tid, err->name, strerror(-cqe->res));\n\tfprintf(stderr, \"fd=%d, bid=%d\\n\", cqe_to_fd(cqe), cqe_to_bid(cqe));\n\treturn 1;\n}\n\n/*\n * Move error handling out of the normal handling path, cleanly separating\n * them. If an opcode doesn't need any error handling, set it to NULL. If\n * it wants to stop the connection at that point and not do anything else,\n * then the default handler can be used. Only receive has proper error\n * handling, as we can get -ENOBUFS which is not a fatal condition. It just\n * means we need to wait on buffer replenishing before re-arming the receive.\n */\nstatic struct error_handler error_handlers[] = {\n\t{ .name = \"NULL\",\t.error_fn = NULL, },\n\t{ .name = \"ACCEPT\",\t.error_fn = default_error, },\n\t{ .name = \"SOCK\",\t.error_fn = default_error, },\n\t{ .name = \"CONNECT\",\t.error_fn = default_error, },\n\t{ .name = \"RECV\",\t.error_fn = recv_error, },\n\t{ .name = \"RECVMSG\",\t.error_fn = recv_error, },\n\t{ .name = \"SEND\",\t.error_fn = send_error, },\n\t{ .name = \"SENDMSG\",\t.error_fn = send_error, },\n\t{ .name = \"SHUTDOWN\",\t.error_fn = NULL, },\n\t{ .name = \"CANCEL\",\t.error_fn = NULL, },\n\t{ .name = \"CLOSE\",\t.error_fn = NULL, },\n\t{ .name = \"FD_PASS\",\t.error_fn = default_error, },\n\t{ .name = \"NOP\",\t.error_fn = NULL, },\n\t{ .name = \"STOP\",\t.error_fn = default_error, },\n};\n\nstatic void free_buffer_ring(struct io_uring *ring, struct conn_buf_ring *cbr)\n{\n\tif (!cbr->br)\n\t\treturn;\n\n\tio_uring_free_buf_ring(ring, cbr->br, nr_bufs, cbr->bgid);\n\tcbr->br = NULL;\n\tif (use_huge)\n\t\tmunmap(cbr->buf, buf_size * nr_bufs);\n\telse\n\t\tfree(cbr->buf);\n}\n\nstatic void free_buffer_rings(struct io_uring *ring, struct conn *c)\n{\n\tfree_buffer_ring(ring, &c->in_br);\n\tfree_buffer_ring(ring, &c->out_br);\n}\n\n/*\n * Setup a ring provided buffer ring for each connection. If we get -ENOBUFS\n * on receive, for multishot receive we'll wait for half the provided buffers\n * to be returned by pending sends, then re-arm the multishot receive. If\n * this happens too frequently (see enobufs= stat), then the ring size is\n * likely too small. Use -nXX to make it bigger. See recv_enobufs().\n *\n * The alternative here would be to use the older style provided buffers,\n * where you simply setup a buffer group and use SQEs with\n * io_urign_prep_provide_buffers() to add to the pool. But that approach is\n * slower and has been deprecated by using the faster ring provided buffers.\n */\nstatic int setup_recv_ring(struct io_uring *ring, struct conn *c)\n{\n\tstruct conn_buf_ring *cbr = &c->in_br;\n\tint br_flags = 0;\n\tint ret, i;\n\tsize_t len;\n\tvoid *ptr;\n\n\tlen = buf_size * nr_bufs;\n\tif (use_huge) {\n\t\tcbr->buf = mmap(NULL, len, PROT_READ|PROT_WRITE,\n\t\t\t\tMAP_PRIVATE|MAP_HUGETLB|MAP_HUGE_2MB|MAP_ANONYMOUS,\n\t\t\t\t-1, 0);\n\t\tif (cbr->buf == MAP_FAILED) {\n\t\t\tperror(\"mmap\");\n\t\t\treturn 1;\n\t\t}\n\t} else {\n\t\tif (posix_memalign(&cbr->buf, page_size, len)) {\n\t\t\tperror(\"posix memalign\");\n\t\t\treturn 1;\n\t\t}\n\t}\n\tif (buf_ring_inc)\n\t\tbr_flags = IOU_PBUF_RING_INC;\n\tcbr->br = io_uring_setup_buf_ring(ring, nr_bufs, cbr->bgid, br_flags, &ret);\n\tif (!cbr->br) {\n\t\tfprintf(stderr, \"Buffer ring register failed %d\\n\", ret);\n\t\treturn 1;\n\t}\n\n\tptr = cbr->buf;\n\tfor (i = 0; i < nr_bufs; i++) {\n\t\tvlog(\"%d: add bid %d, data %p\\n\", c->tid, i, ptr);\n\t\tio_uring_buf_ring_add(cbr->br, ptr, buf_size, i, br_mask, i);\n\t\tptr += buf_size;\n\t}\n\tio_uring_buf_ring_advance(cbr->br, nr_bufs);\n\tprintf(\"%d: recv buffer ring bgid %d, bufs %d\\n\", c->tid, cbr->bgid, nr_bufs);\n\treturn 0;\n}\n\n/*\n * If 'send_ring' is used and the kernel supports it, we can skip serializing\n * sends as the data will be ordered regardless. This reduces the send handling\n * complexity, as buffers can always be added to the outgoing ring and will be\n * processed in the order in which they were added.\n */\nstatic int setup_send_ring(struct io_uring *ring, struct conn *c)\n{\n\tstruct conn_buf_ring *cbr = &c->out_br;\n\tint br_flags = 0;\n\tint ret;\n\n\tif (buf_ring_inc)\n\t\tbr_flags = IOU_PBUF_RING_INC;\n\tcbr->br = io_uring_setup_buf_ring(ring, nr_bufs, cbr->bgid, br_flags, &ret);\n\tif (!cbr->br) {\n\t\tfprintf(stderr, \"Buffer ring register failed %d\\n\", ret);\n\t\treturn 1;\n\t}\n\n\tprintf(\"%d: send buffer ring bgid %d, bufs %d\\n\", c->tid, cbr->bgid, nr_bufs);\n\treturn 0;\n}\n\nstatic int setup_send_zc(struct io_uring *ring, struct conn *c)\n{\n\tstruct iovec *iovs;\n\tvoid *buf;\n\tint i, ret;\n\n\tif (snd_msg)\n\t\treturn 0;\n\n\tbuf = c->in_br.buf;\n\tiovs = calloc(nr_bufs, sizeof(struct iovec));\n\tfor (i = 0; i < nr_bufs; i++) {\n\t\tiovs[i].iov_base = buf;\n\t\tiovs[i].iov_len = buf_size;\n\t\tbuf += buf_size;\n\t}\n\n\tret = io_uring_register_buffers(ring, iovs, nr_bufs);\n\tif (ret) {\n\t\tfprintf(stderr, \"failed registering buffers: %d\\n\", ret);\n\t\tfree(iovs);\n\t\treturn ret;\n\t}\n\tfree(iovs);\n\treturn 0;\n}\n\n/*\n * Setup an input and output buffer ring.\n */\nstatic int setup_buffer_rings(struct io_uring *ring, struct conn *c)\n{\n\tint ret;\n\n\t/* no locking needed on cur_bgid, parent serializes setup */\n\tc->in_br.bgid = cur_bgid++;\n\tc->out_br.bgid = cur_bgid++;\n\tc->out_br.br = NULL;\n\n\tret = setup_recv_ring(ring, c);\n\tif (ret)\n\t\treturn ret;\n\tif (is_sink)\n\t\treturn 0;\n\tif (snd_zc) {\n\t\tret = setup_send_zc(ring, c);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\tif (send_ring) {\n\t\tret = setup_send_ring(ring, c);\n\t\tif (ret) {\n\t\t\tfree_buffer_ring(ring, &c->in_br);\n\t\t\treturn ret;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nstruct bucket_stat {\n\tint nr_packets;\n\tint count;\n};\n\nstatic int stat_cmp(const void *p1, const void *p2)\n{\n\tconst struct bucket_stat *b1 = p1;\n\tconst struct bucket_stat *b2 = p2;\n\n\tif (b1->count < b2->count)\n\t\treturn 1;\n\telse if (b1->count > b2->count)\n\t\treturn -1;\n\treturn 0;\n}\n\nstatic void show_buckets(struct conn_dir *cd)\n{\n\tunsigned long snd_total, rcv_total;\n\tstruct bucket_stat *rstat, *sstat;\n\tint i;\n\n\tif (!cd->rcv_bucket || !cd->snd_bucket)\n\t\treturn;\n\n\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n\tsstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n\n\tsnd_total = rcv_total = 0;\n\tfor (i = 0; i <= nr_bufs; i++) {\n\t\tsnd_total += cd->snd_bucket[i];\n\t\tsstat[i].nr_packets = i;\n\t\tsstat[i].count = cd->snd_bucket[i];\n\t\trcv_total += cd->rcv_bucket[i];\n\t\trstat[i].nr_packets = i;\n\t\trstat[i].count = cd->rcv_bucket[i];\n\t}\n\n\tif (!snd_total && !rcv_total) {\n\t\tfree(sstat);\n\t\tfree(rstat);\n\t}\n\tif (snd_total)\n\t\tqsort(sstat, nr_bufs, sizeof(struct bucket_stat), stat_cmp);\n\tif (rcv_total)\n\t\tqsort(rstat, nr_bufs, sizeof(struct bucket_stat), stat_cmp);\n\n\tprintf(\"\\t Packets per recv/send:\\n\");\n\tfor (i = 0; i <= nr_bufs; i++) {\n\t\tdouble snd_prc = 0.0, rcv_prc = 0.0;\n\t\tif (!rstat[i].count && !sstat[i].count)\n\t\t\tcontinue;\n\t\tif (rstat[i].count)\n\t\t\trcv_prc = 100.0 * (rstat[i].count / (double) rcv_total);\n\t\tif (sstat[i].count)\n\t\t\tsnd_prc = 100.0 * (sstat[i].count / (double) snd_total);\n\t\tprintf(\"\\t bucket(%3d/%3d): rcv=%u (%.2f%%) snd=%u (%.2f%%)\\n\",\n\t\t\t\trstat[i].nr_packets, sstat[i].nr_packets,\n\t\t\t\trstat[i].count, rcv_prc,\n\t\t\t\tsstat[i].count, snd_prc);\n\t}\n\n\tfree(sstat);\n\tfree(rstat);\n}\n\nstatic void __show_stats(struct conn *c)\n{\n\tunsigned long msec, qps;\n\tunsigned long bytes, bw;\n\tstruct conn_dir *cd;\n\tint i;\n\n\tif (c->flags & (CONN_F_STATS_SHOWN | CONN_F_REAPED))\n\t\treturn;\n\tif (!(c->flags & CONN_F_STARTED))\n\t\treturn;\n\n\tif (!(c->flags & CONN_F_END_TIME))\n\t\tgettimeofday(&c->end_time, NULL);\n\n\tmsec = (c->end_time.tv_sec - c->start_time.tv_sec) * 1000;\n\tmsec += (c->end_time.tv_usec - c->start_time.tv_usec) / 1000;\n\n\tqps = 0;\n\tfor (i = 0; i < 2; i++)\n\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n\n\tif (!qps)\n\t\treturn;\n\n\tif (msec)\n\t\tqps = (qps * 1000) / msec;\n\n\tprintf(\"Conn %d/(in_fd=%d, out_fd=%d): qps=%lu, msec=%lu\\n\", c->tid,\n\t\t\t\t\tc->in_fd, c->out_fd, qps, msec);\n\n\tbytes = 0;\n\tfor (i = 0; i < 2; i++) {\n\t\tcd = &c->cd[i];\n\n\t\tif (!cd->in_bytes && !cd->out_bytes && !cd->snd && !cd->rcv)\n\t\t\tcontinue;\n\n\t\tbytes += cd->in_bytes;\n\t\tbytes += cd->out_bytes;\n\n\t\tprintf(\"\\t%3d: rcv=%u (short=%u, enobufs=%d), snd=%u (short=%u,\"\n\t\t\t\" busy=%u, enobufs=%d)\\n\", i, cd->rcv, cd->rcv_shrt,\n\t\t\tcd->rcv_enobufs, cd->snd, cd->snd_shrt, cd->snd_busy,\n\t\t\tcd->snd_enobufs);\n\t\tprintf(\"\\t   : in_bytes=%lu (Kb %lu), out_bytes=%lu (Kb %lu)\\n\",\n\t\t\tcd->in_bytes, cd->in_bytes >> 10,\n\t\t\tcd->out_bytes, cd->out_bytes >> 10);\n\t\tprintf(\"\\t   : mshot_rcv=%d, mshot_snd=%d\\n\", cd->rcv_mshot,\n\t\t\tcd->snd_mshot);\n\t\tshow_buckets(cd);\n\n\t}\n\tif (msec) {\n\t\tbytes *= 8UL;\n\t\tbw = bytes / 1000;\n\t\tbw /= msec;\n\t\tprintf(\"\\tBW=%'luMbit\\n\", bw);\n\t}\n\n\tc->flags |= CONN_F_STATS_SHOWN;\n}\n\nstatic void show_stats(void)\n{\n\tfloat events_per_loop = 0.0;\n\tstatic int stats_shown;\n\tint i;\n\n\tif (stats_shown)\n\t\treturn;\n\n\tif (events)\n\t\tevents_per_loop = (float) events / (float) event_loops;\n\n\tprintf(\"Event loops: %lu, events %lu, events per loop %.2f\\n\", event_loops,\n\t\t\t\t\t\t\tevents, events_per_loop);\n\n\tfor (i = 0; i < MAX_CONNS; i++) {\n\t\tstruct conn *c = &conns[i];\n\n\t\t__show_stats(c);\n\t}\n\tstats_shown = 1;\n}\n\nstatic void sig_int(int __attribute__((__unused__)) sig)\n{\n\tprintf(\"\\n\");\n\tshow_stats();\n\texit(1);\n}\n\n/*\n * Special cased for SQPOLL only, as we don't control when SQEs are consumed if\n * that is used. Hence we may need to wait for the SQPOLL thread to keep up\n * until we can get a new SQE. All other cases will break immediately, with a\n * fresh SQE.\n *\n * If we grossly undersized our SQ ring, getting a NULL sqe can happen even\n * for the !SQPOLL case if we're handling a lot of CQEs in our event loop\n * and multishot isn't used. We can do io_uring_submit() to flush what we\n * have here. Only caveat here is that if linked requests are used, SQEs\n * would need to be allocated upfront as a link chain is only valid within\n * a single submission cycle.\n */\nstatic struct io_uring_sqe *get_sqe(struct io_uring *ring)\n{\n\tstruct io_uring_sqe *sqe;\n\n\tdo {\n\t\tsqe = io_uring_get_sqe(ring);\n\t\tif (sqe)\n\t\t\tbreak;\n\t\tif (!sqpoll)\n\t\t\tio_uring_submit(ring);\n\t\telse\n\t\t\tio_uring_sqring_wait(ring);\n\t} while (1);\n\n\treturn sqe;\n}\n\n/*\n * See __encode_userdata() for how we encode sqe->user_data, which is passed\n * back as cqe->user_data at completion time.\n */\nstatic void encode_userdata(struct io_uring_sqe *sqe, struct conn *c, int op,\n\t\t\t    int bid, int fd)\n{\n\t__encode_userdata(sqe, c->tid, op, bid, fd);\n}\n\nstatic void __submit_receive(struct io_uring *ring, struct conn *c,\n\t\t\t     struct conn_dir *cd, int fd)\n{\n\tstruct conn_buf_ring *cbr = &c->in_br;\n\tstruct io_uring_sqe *sqe;\n\n\tvlog(\"%d: submit receive fd=%d\\n\", c->tid, fd);\n\n\tassert(!cd->pending_recv);\n\tcd->pending_recv = 1;\n\n\t/*\n\t * For both recv and multishot receive, we use the ring provided\n\t * buffers. These are handed to the application ahead of time, and\n\t * are consumed when a receive triggers. Note that the address and\n\t * length of the receive are set to NULL/0, and we assign the\n\t * sqe->buf_group to tell the kernel which buffer group ID to pick\n\t * a buffer from. Finally, IOSQE_BUFFER_SELECT is set to tell the\n\t * kernel that we want a buffer picked for this request, we are not\n\t * passing one in with the request.\n\t */\n\tsqe = get_sqe(ring);\n\tif (rcv_msg) {\n\t\tstruct io_msg *imsg = &cd->io_rcv_msg;\n\t\tstruct msghdr *msg = &imsg->msg;\n\n\t\tmemset(msg, 0, sizeof(*msg));\n\t\tmsg->msg_iov = msg_vec(imsg)->iov;\n\t\tmsg->msg_iovlen = msg_vec(imsg)->iov_len;\n\n\t\tif (recv_mshot) {\n\t\t\tcd->rcv_mshot++;\n\t\t\tio_uring_prep_recvmsg_multishot(sqe, fd, &imsg->msg, 0);\n\t\t} else {\n\t\t\tio_uring_prep_recvmsg(sqe, fd, &imsg->msg, 0);\n\t\t}\n\t} else {\n\t\tif (recv_mshot) {\n\t\t\tcd->rcv_mshot++;\n\t\t\tio_uring_prep_recv_multishot(sqe, fd, NULL, 0, 0);\n\t\t} else {\n\t\t\tio_uring_prep_recv(sqe, fd, NULL, 0, 0);\n\t\t}\n\t}\n\tencode_userdata(sqe, c, __RECV, 0, fd);\n\tsqe->buf_group = cbr->bgid;\n\tsqe->flags |= IOSQE_BUFFER_SELECT;\n\tif (fixed_files)\n\t\tsqe->flags |= IOSQE_FIXED_FILE;\n\tif (rcv_bundle)\n\t\tsqe->ioprio |= IORING_RECVSEND_BUNDLE;\n}\n\n/*\n * One directional just arms receive on our in_fd\n */\nstatic void submit_receive(struct io_uring *ring, struct conn *c)\n{\n\t__submit_receive(ring, c, &c->cd[0], c->in_fd);\n}\n\n/*\n * Bi-directional arms receive on both in and out fd\n */\nstatic void submit_bidi_receive(struct io_uring *ring, struct conn *c)\n{\n\t__submit_receive(ring, c, &c->cd[0], c->in_fd);\n\t__submit_receive(ring, c, &c->cd[1], c->out_fd);\n}\n\n/*\n * We hit -ENOBUFS, which means that we ran out of buffers in our current\n * provided buffer group. This can happen if there's an imbalance between the\n * receives coming in and the sends being processed, particularly with multishot\n * receive as they can trigger very quickly. If this happens, defer arming a\n * new receive until we've replenished half of the buffer pool by processing\n * pending sends.\n */\nstatic void recv_enobufs(struct io_uring *ring, struct conn *c,\n\t\t\t struct conn_dir *cd, int fd)\n{\n\tvlog(\"%d: enobufs hit\\n\", c->tid);\n\n\tcd->rcv_enobufs++;\n\n\t/*\n\t * If we're a sink, mark rcv as rearm. If we're not, then mark us as\n\t * needing a rearm for receive and send. The completing send will\n\t * kick the recv rearm.\n\t */\n\tif (!is_sink) {\n\t\tint do_recv_arm = 1;\n\n\t\tif (!cd->pending_send)\n\t\t\tdo_recv_arm = !prep_next_send(ring, c, cd, fd);\n\t\tif (do_recv_arm)\n\t\t\t__submit_receive(ring, c, &c->cd[0], c->in_fd);\n\t} else {\n\t\t__submit_receive(ring, c, &c->cd[0], c->in_fd);\n\t}\n}\n\n/*\n * Kill this socket - submit a shutdown and link a close to it. We don't\n * care about shutdown status, so mark it as not needing to post a CQE unless\n * it fails.\n */\nstatic void queue_shutdown_close(struct io_uring *ring, struct conn *c, int fd)\n{\n\tstruct io_uring_sqe *sqe1, *sqe2;\n\n\t/*\n\t * On the off chance that we run out of SQEs after the first one,\n\t * grab two upfront. This it to prevent our link not working if\n\t * get_sqe() ends up doing submissions to free up an SQE, as links\n\t * are not valid across separate submissions.\n\t */\n\tsqe1 = get_sqe(ring);\n\tsqe2 = get_sqe(ring);\n\n\tio_uring_prep_shutdown(sqe1, fd, SHUT_RDWR);\n\tif (fixed_files)\n\t\tsqe1->flags |= IOSQE_FIXED_FILE;\n\tsqe1->flags |= IOSQE_IO_LINK | IOSQE_CQE_SKIP_SUCCESS;\n\tencode_userdata(sqe1, c, __SHUTDOWN, 0, fd);\n\n\tif (fixed_files)\n\t\tio_uring_prep_close_direct(sqe2, fd);\n\telse\n\t\tio_uring_prep_close(sqe2, fd);\n\tencode_userdata(sqe2, c, __CLOSE, 0, fd);\n}\n\n/*\n * This connection is going away, queue a cancel for any pending recv, for\n * example, we have pending for this ring. For completeness, we issue a cancel\n * for any request we have pending for both in_fd and out_fd.\n */\nstatic void queue_cancel(struct io_uring *ring, struct conn *c)\n{\n\tstruct io_uring_sqe *sqe;\n\tint flags = 0;\n\n\tif (fixed_files)\n\t\tflags |= IORING_ASYNC_CANCEL_FD_FIXED;\n\n\tsqe = get_sqe(ring);\n\tio_uring_prep_cancel_fd(sqe, c->in_fd, flags);\n\tencode_userdata(sqe, c, __CANCEL, 0, c->in_fd);\n\tc->pending_cancels++;\n\n\tif (c->out_fd != -1) {\n\t\tsqe = get_sqe(ring);\n\t\tio_uring_prep_cancel_fd(sqe, c->out_fd, flags);\n\t\tencode_userdata(sqe, c, __CANCEL, 0, c->out_fd);\n\t\tc->pending_cancels++;\n\t}\n\n\tio_uring_submit(ring);\n}\n\nstatic int pending_shutdown(struct conn *c)\n{\n\treturn c->cd[0].pending_shutdown + c->cd[1].pending_shutdown;\n}\n\nstatic bool should_shutdown(struct conn *c)\n{\n\tint i;\n\n\tif (!pending_shutdown(c))\n\t\treturn false;\n\tif (is_sink)\n\t\treturn true;\n\tif (!bidi)\n\t\treturn c->cd[0].in_bytes == c->cd[1].out_bytes;\n\n\tfor (i = 0; i < 2; i++) {\n\t\tif (c->cd[0].rcv != c->cd[1].snd)\n\t\t\treturn false;\n\t\tif (c->cd[1].rcv != c->cd[0].snd)\n\t\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/*\n * Close this connection - send a ring message to the connection with intent\n * to stop. When the client gets the message, it will initiate the stop.\n */\nstatic void __close_conn(struct io_uring *ring, struct conn *c)\n{\n\tstruct io_uring_sqe *sqe;\n\tuint64_t user_data;\n\n\tprintf(\"Client %d: queueing stop\\n\", c->tid);\n\n\tuser_data = __raw_encode(c->tid, __STOP, 0, 0);\n\tsqe = io_uring_get_sqe(ring);\n\tio_uring_prep_msg_ring(sqe, c->ring.ring_fd, 0, user_data, 0);\n\tencode_userdata(sqe, c, __NOP, 0, 0);\n\tio_uring_submit(ring);\n}\n\nstatic void close_cd(struct conn *c, struct conn_dir *cd)\n{\n\tcd->pending_shutdown = 1;\n\n\tif (cd->pending_send)\n\t\treturn;\n\n\tif (!(c->flags & CONN_F_PENDING_SHUTDOWN)) {\n\t\tgettimeofday(&c->end_time, NULL);\n\t\tc->flags |= CONN_F_PENDING_SHUTDOWN | CONN_F_END_TIME;\n\t}\n}\n\n/*\n * We're done with this buffer, add it back to our pool so the kernel is\n * free to use it again.\n */\nstatic int replenish_buffer(struct conn_buf_ring *cbr, int bid, int offset)\n{\n\tvoid *this_buf = cbr->buf + bid * buf_size;\n\n\tassert(bid < nr_bufs);\n\n\tio_uring_buf_ring_add(cbr->br, this_buf, buf_size, bid, br_mask, offset);\n\treturn buf_size;\n}\n\n/*\n * Iterate buffers from '*bid' and with a total size of 'bytes' and add them\n * back to our receive ring so they can be reused for new receives.\n */\nstatic int replenish_buffers(struct conn *c, int *bid, int bytes)\n{\n\tstruct conn_buf_ring *cbr = &c->in_br;\n\tint nr_packets = 0;\n\n\twhile (bytes) {\n\t\tint this_len = replenish_buffer(cbr, *bid, nr_packets);\n\n\t\tif (this_len > bytes)\n\t\t\tthis_len = bytes;\n\t\tbytes -= this_len;\n\n\t\t*bid = (*bid + 1) & (nr_bufs - 1);\n\t\tnr_packets++;\n\t}\n\n\tio_uring_buf_ring_advance(cbr->br, nr_packets);\n\treturn nr_packets;\n}\n\nstatic void free_mvec(struct msg_vec *mvec)\n{\n\tfree(mvec->iov);\n\tmvec->iov = NULL;\n}\n\nstatic void init_mvec(struct msg_vec *mvec)\n{\n\tmemset(mvec, 0, sizeof(*mvec));\n\tmvec->iov = malloc(sizeof(struct iovec));\n\tmvec->vec_size = 1;\n}\n\nstatic void init_msgs(struct conn_dir *cd)\n{\n\tmemset(&cd->io_snd_msg, 0, sizeof(cd->io_snd_msg));\n\tmemset(&cd->io_rcv_msg, 0, sizeof(cd->io_rcv_msg));\n\tinit_mvec(&cd->io_snd_msg.vecs[0]);\n\tinit_mvec(&cd->io_snd_msg.vecs[1]);\n\tinit_mvec(&cd->io_rcv_msg.vecs[0]);\n}\n\nstatic void free_msgs(struct conn_dir *cd)\n{\n\tfree_mvec(&cd->io_snd_msg.vecs[0]);\n\tfree_mvec(&cd->io_snd_msg.vecs[1]);\n\tfree_mvec(&cd->io_rcv_msg.vecs[0]);\n}\n\n/*\n * Multishot accept completion triggered. If we're acting as a sink, we're\n * good to go. Just issue a receive for that case. If we're acting as a proxy,\n * then start opening a socket that we can use to connect to the other end.\n */\nstatic int handle_accept(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c;\n\tint i;\n\n\tif (nr_conns == MAX_CONNS) {\n\t\tfprintf(stderr, \"max clients reached %d\\n\", nr_conns);\n\t\treturn 1;\n\t}\n\n\t/* main thread handles this, which is obviously serialized */\n\tc = &conns[nr_conns];\n\tc->tid = nr_conns++;\n\tc->in_fd = -1;\n\tc->out_fd = -1;\n\n\tfor (i = 0; i < 2; i++) {\n\t\tstruct conn_dir *cd = &c->cd[i];\n\n\t\tcd->index = i;\n\t\tcd->snd_next_bid = -1;\n\t\tcd->rcv_next_bid = -1;\n\t\tif (ext_stat) {\n\t\t\tcd->rcv_bucket = calloc(nr_bufs + 1, sizeof(int));\n\t\t\tcd->snd_bucket = calloc(nr_bufs + 1, sizeof(int));\n\t\t}\n\t\tinit_msgs(cd);\n\t}\n\n\tprintf(\"New client: id=%d, in=%d\\n\", c->tid, c->in_fd);\n\tgettimeofday(&c->start_time, NULL);\n\n\tpthread_barrier_init(&c->startup_barrier, NULL, 2);\n\tpthread_create(&c->thread, NULL, thread_main, c);\n\n\t/*\n\t * Wait for thread to have its ring setup, then either assign the fd\n\t * if it's non-fixed, or pass the fixed one\n\t */\n\tpthread_barrier_wait(&c->startup_barrier);\n\tif (!fixed_files) {\n\t\tc->in_fd = cqe->res;\n\t} else {\n\t\tstruct io_uring_sqe *sqe;\n\t\tuint64_t user_data;\n\n\t\t/*\n\t\t * Ring has just been setup, we'll use index 0 as the descriptor\n\t\t * value.\n\t\t */\n\t\tuser_data = __raw_encode(c->tid, __FD_PASS, 0, 0);\n\t\tsqe = io_uring_get_sqe(ring);\n\t\tio_uring_prep_msg_ring_fd(sqe, c->ring.ring_fd, cqe->res, 0,\n\t\t\t\t\t\tuser_data, 0);\n\t\tencode_userdata(sqe, c, __NOP, 0, cqe->res);\n\t}\n\n\treturn 0;\n}\n\n/*\n * Our socket request completed, issue a connect request to the other end.\n */\nstatic int handle_sock(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tstruct io_uring_sqe *sqe;\n\tint ret;\n\n\tvlog(\"%d: sock: res=%d\\n\", c->tid, cqe->res);\n\n\tc->out_fd = cqe->res;\n\n\tif (ipv6) {\n\t\tmemset(&c->addr6, 0, sizeof(c->addr6));\n\t\tc->addr6.sin6_family = AF_INET6;\n\t\tc->addr6.sin6_port = htons(send_port);\n\t\tret = inet_pton(AF_INET6, host, &c->addr6.sin6_addr);\n\t} else {\n\t\tmemset(&c->addr, 0, sizeof(c->addr));\n\t\tc->addr.sin_family = AF_INET;\n\t\tc->addr.sin_port = htons(send_port);\n\t\tret = inet_pton(AF_INET, host, &c->addr.sin_addr);\n\t}\n\tif (ret <= 0) {\n\t\tif (!ret)\n\t\t\tfprintf(stderr, \"host not in right format\\n\");\n\t\telse\n\t\t\tperror(\"inet_pton\");\n\t\treturn 1;\n\t}\n\n\tsqe = get_sqe(ring);\n\tif (ipv6) {\n\t\tio_uring_prep_connect(sqe, c->out_fd,\n\t\t\t\t\t(struct sockaddr *) &c->addr6,\n\t\t\t\t\tsizeof(c->addr6));\n\t} else {\n\t\tio_uring_prep_connect(sqe, c->out_fd,\n\t\t\t\t\t(struct sockaddr *) &c->addr,\n\t\t\t\t\tsizeof(c->addr));\n\t}\n\tencode_userdata(sqe, c, __CONNECT, 0, c->out_fd);\n\tif (fixed_files)\n\t\tsqe->flags |= IOSQE_FIXED_FILE;\n\treturn 0;\n}\n\n/*\n * Connection to the other end is done, submit a receive to start receiving\n * data. If we're a bidirectional proxy, issue a receive on both ends. If not,\n * then just a single recv will do.\n */\nstatic int handle_connect(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\n\tpthread_mutex_lock(&thread_lock);\n\topen_conns++;\n\tpthread_mutex_unlock(&thread_lock);\n\n\tif (bidi)\n\t\tsubmit_bidi_receive(ring, c);\n\telse\n\t\tsubmit_receive(ring, c);\n\n\treturn 0;\n}\n\n/*\n * Append new segment to our currently active msg_vec. This will be submitted\n * as a sendmsg (with all of it), or as separate sends, later. If we're using\n * send_ring, then we won't hit this path. Instead, outgoing buffers are\n * added directly to our outgoing send buffer ring.\n */\nstatic void send_append_vec(struct conn_dir *cd, void *data, int len)\n{\n\tstruct msg_vec *mvec = snd_msg_vec(cd);\n\n\tif (mvec->iov_len == mvec->vec_size) {\n\t\tmvec->vec_size <<= 1;\n\t\tmvec->iov = realloc(mvec->iov, mvec->vec_size * sizeof(struct iovec));\n\t}\n\n\tmvec->iov[mvec->iov_len].iov_base = data;\n\tmvec->iov[mvec->iov_len].iov_len = len;\n\tmvec->iov_len++;\n}\n\n/*\n * Queue a send based on the data received in this cqe, which came from\n * a completed receive operation.\n */\nstatic void send_append(struct conn *c, struct conn_dir *cd, void *data,\n\t\t\tint bid, int len)\n{\n\tvlog(\"%d: send %d (%p, bid %d)\\n\", c->tid, len, data, bid);\n\n\tassert(bid < nr_bufs);\n\n\t/* if using provided buffers for send, add it upfront */\n\tif (send_ring) {\n\t\tstruct conn_buf_ring *cbr = &c->out_br;\n\n\t\tio_uring_buf_ring_add(cbr->br, data, len, bid, br_mask, 0);\n\t\tio_uring_buf_ring_advance(cbr->br, 1);\n\t} else {\n\t\tsend_append_vec(cd, data, len);\n\t}\n}\n\n/*\n * For non recvmsg && multishot, a zero receive marks the end. For recvmsg\n * with multishot, we always get the header regardless. Hence a \"zero receive\"\n * is the size of the header.\n */\nstatic int recv_done_res(int res)\n{\n\tif (!res)\n\t\treturn 1;\n\tif (rcv_msg && recv_mshot && res == sizeof(struct io_uring_recvmsg_out))\n\t\treturn 1;\n\treturn 0;\n}\n\nstatic int recv_inc(struct conn *c, struct conn_dir *cd, int *bid,\n\t\t    struct io_uring_cqe *cqe)\n{\n\tstruct conn_buf_ring *cbr = &c->out_br;\n\tstruct conn_buf_ring *in_cbr = &c->in_br;\n\tvoid *data;\n\n\tif (!cqe->res)\n\t\treturn 0;\n\tif (cqe->flags & IORING_CQE_F_BUF_MORE)\n\t\treturn 0;\n\n\tdata = in_cbr->buf + *bid * buf_size;\n\tif (is_sink) {\n\t\tio_uring_buf_ring_add(in_cbr->br, data, buf_size, *bid, br_mask, 0);\n\t\tio_uring_buf_ring_advance(in_cbr->br, 1);\n\t} else if (send_ring) {\n\t\tio_uring_buf_ring_add(cbr->br, data, buf_size, *bid, br_mask, 0);\n\t\tio_uring_buf_ring_advance(cbr->br, 1);\n\t} else {\n\t\tsend_append(c, cd, data, *bid, buf_size);\n\t}\n\t*bid = (*bid + 1) & (nr_bufs - 1);\n\treturn 1;\n}\n\n/*\n * Any receive that isn't recvmsg with multishot can be handled the same way.\n * Iterate from '*bid' and 'in_bytes' in total, and append the data to the\n * outgoing queue.\n */\nstatic int recv_bids(struct conn *c, struct conn_dir *cd, int *bid, int in_bytes)\n{\n\tstruct conn_buf_ring *cbr = &c->out_br;\n\tstruct conn_buf_ring *in_cbr = &c->in_br;\n\tstruct io_uring_buf *buf;\n\tint nr_packets = 0;\n\n\twhile (in_bytes) {\n\t\tint this_bytes;\n\t\tvoid *data;\n\n\t\tbuf = &in_cbr->br->bufs[*bid];\n\t\tdata = (void *) (unsigned long) buf->addr;\n\t\tthis_bytes = buf->len;\n\t\tif (this_bytes > in_bytes)\n\t\t\tthis_bytes = in_bytes;\n\n\t\tin_bytes -= this_bytes;\n\n\t\tif (send_ring)\n\t\t\tio_uring_buf_ring_add(cbr->br, data, this_bytes, *bid,\n\t\t\t\t\t\tbr_mask, nr_packets);\n\t\telse\n\t\t\tsend_append(c, cd, data, *bid, this_bytes);\n\n\t\t*bid = (*bid + 1) & (nr_bufs - 1);\n\t\tnr_packets++;\n\t}\n\n\tif (send_ring)\n\t\tio_uring_buf_ring_advance(cbr->br, nr_packets);\n\n\treturn nr_packets;\n}\n\n/*\n * Special handling of recvmsg with multishot\n */\nstatic int recv_mshot_msg(struct conn *c, struct conn_dir *cd, int *bid,\n\t\t\t  int in_bytes)\n{\n\tstruct conn_buf_ring *cbr = &c->out_br;\n\tstruct conn_buf_ring *in_cbr = &c->in_br;\n\tstruct io_uring_buf *buf;\n\tint nr_packets = 0;\n\n\twhile (in_bytes) {\n\t\tstruct io_uring_recvmsg_out *pdu;\n\t\tint this_bytes;\n\t\tvoid *data;\n\n\t\tbuf = &in_cbr->br->bufs[*bid];\n\n\t\t/*\n\t\t * multishot recvmsg puts a header in front of the data - we\n\t\t * have to take that into account for the send setup, and\n\t\t * adjust the actual data read to not take this metadata into\n\t\t * account. For this use case, namelen and controllen will not\n\t\t * be set. If they were, they would need to be factored in too.\n\t\t */\n\t\tbuf->len -= sizeof(struct io_uring_recvmsg_out);\n\t\tin_bytes -= sizeof(struct io_uring_recvmsg_out);\n\n\t\tpdu = (void *) (unsigned long) buf->addr;\n\t\tvlog(\"pdu namelen %d, controllen %d, payload %d flags %x\\n\",\n\t\t\t\tpdu->namelen, pdu->controllen, pdu->payloadlen,\n\t\t\t\tpdu->flags);\n\t\tdata = (void *) (pdu + 1);\n\n\t\tthis_bytes = pdu->payloadlen;\n\t\tif (this_bytes > in_bytes)\n\t\t\tthis_bytes = in_bytes;\n\n\t\tin_bytes -= this_bytes;\n\n\t\tif (send_ring)\n\t\t\tio_uring_buf_ring_add(cbr->br, data, this_bytes, *bid,\n\t\t\t\t\t\tbr_mask, nr_packets);\n\t\telse\n\t\t\tsend_append(c, cd, data, *bid, this_bytes);\n\n\t\t*bid = (*bid + 1) & (nr_bufs - 1);\n\t\tnr_packets++;\n\t}\n\n\tif (send_ring)\n\t\tio_uring_buf_ring_advance(cbr->br, nr_packets);\n\n\treturn nr_packets;\n}\n\nstatic int __handle_recv(struct io_uring *ring, struct conn *c,\n\t\t\t struct conn_dir *cd, struct io_uring_cqe *cqe)\n{\n\tstruct conn_dir *ocd = &c->cd[!cd->index];\n\tint bid, nr_packets;\n\n\t/*\n\t * Not having a buffer attached should only happen if we get a zero\n\t * sized receive, because the other end closed the connection. It\n\t * cannot happen otherwise, as all our receives are using provided\n\t * buffers and hence it's not possible to return a CQE with a non-zero\n\t * result and not have a buffer attached.\n\t */\n\tif (!(cqe->flags & IORING_CQE_F_BUFFER)) {\n\t\tcd->pending_recv = 0;\n\n\t\tif (!recv_done_res(cqe->res)) {\n\t\t\tfprintf(stderr, \"no buffer assigned, res=%d\\n\", cqe->res);\n\t\t\treturn 1;\n\t\t}\nstart_close:\n\t\tprep_next_send(ring, c, ocd, other_dir_fd(c, cqe_to_fd(cqe)));\n\t\tclose_cd(c, cd);\n\t\treturn 0;\n\t}\n\n\tif (cqe->res && cqe->res < buf_size)\n\t\tcd->rcv_shrt++;\n\n\tbid = cqe->flags >> IORING_CQE_BUFFER_SHIFT;\n\n\t/*\n\t * BIDI will use the same buffer pool and do receive on both CDs,\n\t * so can't reliably check. TODO.\n\t */\n\tif (!bidi && cd->rcv_next_bid != -1 && bid != cd->rcv_next_bid) {\n\t\tfprintf(stderr, \"recv bid %d, wanted %d\\n\", bid, cd->rcv_next_bid);\n\t\tgoto start_close;\n\t}\n\n\tvlog(\"%d: recv: bid=%d, res=%d, cflags=%x\\n\", c->tid, bid, cqe->res, cqe->flags);\n\t/*\n\t * If we're a sink, we're done here. Just replenish the buffer back\n\t * to the pool. For proxy mode, we will send the data to the other\n\t * end and the buffer will be replenished once the send is done with\n\t * it.\n\t */\n\tif (buf_ring_inc)\n\t\tnr_packets = recv_inc(c, ocd, &bid, cqe);\n\telse if (is_sink)\n\t\tnr_packets = replenish_buffers(c, &bid, cqe->res);\n\telse if (rcv_msg && recv_mshot)\n\t\tnr_packets = recv_mshot_msg(c, ocd, &bid, cqe->res);\n\telse\n\t\tnr_packets = recv_bids(c, ocd, &bid, cqe->res);\n\n\tif (cd->rcv_bucket)\n\t\tcd->rcv_bucket[nr_packets]++;\n\n\tif (!is_sink) {\n\t\tocd->out_buffers += nr_packets;\n\t\tassert(ocd->out_buffers <= nr_bufs);\n\t}\n\n\tcd->rcv++;\n\tcd->rcv_next_bid = bid;\n\n\t/*\n\t * If IORING_CQE_F_MORE isn't set, then this is either a normal recv\n\t * that needs rearming, or it's a multishot that won't post any further\n\t * completions. Setup a new one for these cases.\n\t */\n\tif (!(cqe->flags & IORING_CQE_F_MORE)) {\n\t\tcd->pending_recv = 0;\n\t\tif (recv_done_res(cqe->res))\n\t\t\tgoto start_close;\n\t\tif (is_sink || !ocd->pending_send)\n\t\t\t__submit_receive(ring, c, cd, cqe_to_fd(cqe));\n\t}\n\n\t/*\n\t * Submit a send if we won't get anymore notifications from this\n\t * recv, or if we have nr_bufs / 2 queued up. If BIDI mode, send\n\t * every buffer. We assume this is interactive mode, and hence don't\n\t * delay anything.\n\t */\n\tif (((!ocd->pending_send && (bidi || (ocd->out_buffers >= nr_bufs / 2))) ||\n\t    !(cqe->flags & IORING_CQE_F_MORE)) && !is_sink)\n\t\tprep_next_send(ring, c, ocd, other_dir_fd(c, cqe_to_fd(cqe)));\n\n\tif (!recv_done_res(cqe->res))\n\t\tcd->in_bytes += cqe->res;\n\treturn 0;\n}\n\nstatic int handle_recv(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tstruct conn_dir *cd = cqe_to_conn_dir(c, cqe);\n\n\treturn __handle_recv(ring, c, cd, cqe);\n}\n\nstatic int recv_error(struct error_handler *err, struct io_uring *ring,\n\t\t      struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tstruct conn_dir *cd = cqe_to_conn_dir(c, cqe);\n\n\tcd->pending_recv = 0;\n\n\tif (cqe->res != -ENOBUFS)\n\t\treturn default_error(err, ring, cqe);\n\n\trecv_enobufs(ring, c, cd, other_dir_fd(c, cqe_to_fd(cqe)));\n\treturn 0;\n}\n\nstatic void submit_send(struct io_uring *ring, struct conn *c,\n\t\t\tstruct conn_dir *cd, int fd, void *data, int len,\n\t\t\tint bid, int flags)\n{\n\tstruct io_uring_sqe *sqe;\n\tint bgid = c->out_br.bgid;\n\n\tif (cd->pending_send)\n\t\treturn;\n\tcd->pending_send = 1;\n\n\tflags |= MSG_WAITALL | MSG_NOSIGNAL;\n\n\tsqe = get_sqe(ring);\n\tif (snd_msg) {\n\t\tstruct io_msg *imsg = &cd->io_snd_msg;\n\n\t\tif (snd_zc) {\n\t\t\tio_uring_prep_sendmsg_zc(sqe, fd, &imsg->msg, flags);\n\t\t\tcd->snd_notif++;\n\t\t} else {\n\t\t\tio_uring_prep_sendmsg(sqe, fd, &imsg->msg, flags);\n\t\t}\n\t} else if (send_ring) {\n\t\tio_uring_prep_send(sqe, fd, NULL, 0, flags);\n\t} else if (!snd_zc) {\n\t\tio_uring_prep_send(sqe, fd, data, len, flags);\n\t} else {\n\t\tio_uring_prep_send_zc(sqe, fd, data, len, flags, 0);\n\t\tsqe->ioprio |= IORING_RECVSEND_FIXED_BUF;\n\t\tsqe->buf_index = bid;\n\t\tcd->snd_notif++;\n\t}\n\tencode_userdata(sqe, c, __SEND, bid, fd);\n\tif (fixed_files)\n\t\tsqe->flags |= IOSQE_FIXED_FILE;\n\tif (send_ring) {\n\t\tsqe->flags |= IOSQE_BUFFER_SELECT;\n\t\tsqe->buf_group = bgid;\n\t}\n\tif (snd_bundle) {\n\t\tsqe->ioprio |= IORING_RECVSEND_BUNDLE;\n\t\tcd->snd_mshot++;\n\t} else if (send_ring)\n\t\tcd->snd_mshot++;\n}\n\n/*\n * Prepare the next send request, if we need to. If one is already pending,\n * or if we're a sink and we don't need to do sends, then there's nothing\n * to do.\n *\n * Return 1 if another send completion is expected, 0 if not.\n */\nstatic int prep_next_send(struct io_uring *ring, struct conn *c,\n\t\t\t   struct conn_dir *cd, int fd)\n{\n\tint bid;\n\n\tif (cd->pending_send || is_sink)\n\t\treturn 0;\n\tif (!cd->out_buffers)\n\t\treturn 0;\n\n\tbid = cd->snd_next_bid;\n\tif (bid == -1)\n\t\tbid = 0;\n\n\tif (send_ring) {\n\t\t/*\n\t\t * send_ring mode is easy, there's nothing to do but submit\n\t\t * our next send request. That will empty the entire outgoing\n\t\t * queue.\n\t\t */\n\t\tsubmit_send(ring, c, cd, fd, NULL, 0, bid, 0);\n\t\treturn 1;\n\t} else if (snd_msg) {\n\t\t/*\n\t\t * For sendmsg mode, submit our currently prepared iovec, if\n\t\t * we have one, and swap our iovecs so that any further\n\t\t * receives will start preparing that one.\n\t\t */\n\t\tstruct io_msg *imsg = &cd->io_snd_msg;\n\n\t\tif (!msg_vec(imsg)->iov_len)\n\t\t\treturn 0;\n\t\timsg->msg.msg_iov = msg_vec(imsg)->iov;\n\t\timsg->msg.msg_iovlen = msg_vec(imsg)->iov_len;\n\t\tmsg_vec(imsg)->iov_len = 0;\n\t\timsg->vec_index = !imsg->vec_index;\n\t\tsubmit_send(ring, c, cd, fd, NULL, 0, bid, 0);\n\t\treturn 1;\n\t} else {\n\t\t/*\n\t\t * send without send_ring - submit the next available vec,\n\t\t * if any. If this vec is the last one in the current series,\n\t\t * then swap to the next vec. We flag each send with MSG_MORE,\n\t\t * unless this is the last part of the current vec.\n\t\t */\n\t\tstruct io_msg *imsg = &cd->io_snd_msg;\n\t\tstruct msg_vec *mvec = msg_vec(imsg);\n\t\tint flags = !snd_zc ? MSG_MORE : 0;\n\t\tstruct iovec *iov;\n\n\t\tif (mvec->iov_len == mvec->cur_iov)\n\t\t\treturn 0;\n\t\timsg->msg.msg_iov = msg_vec(imsg)->iov;\n\t\tiov = &mvec->iov[mvec->cur_iov];\n\t\tmvec->cur_iov++;\n\t\tif (mvec->cur_iov == mvec->iov_len) {\n\t\t\tmvec->iov_len = 0;\n\t\t\tmvec->cur_iov = 0;\n\t\t\timsg->vec_index = !imsg->vec_index;\n\t\t\tflags = 0;\n\t\t}\n\t\tsubmit_send(ring, c, cd, fd, iov->iov_base, iov->iov_len, bid, flags);\n\t\treturn 1;\n\t}\n}\n\nstatic int handle_send_inc(struct conn *c, struct conn_dir *cd, int bid,\n\t\t\t   struct io_uring_cqe *cqe)\n{\n\tstruct conn_buf_ring *in_cbr = &c->in_br;\n\tint ret = 0;\n\tvoid *data;\n\n\tif (!cqe->res)\n\t\tgoto out;\n\tif (cqe->flags & IORING_CQE_F_BUF_MORE)\n\t\treturn 0;\n\n\tassert(cqe->res <= buf_size);\n\tcd->out_bytes += cqe->res;\n\n\tdata = in_cbr->buf + bid * buf_size;\n\tio_uring_buf_ring_add(in_cbr->br, data, buf_size, bid, br_mask, 0);\n\tio_uring_buf_ring_advance(in_cbr->br, 1);\n\tbid = (bid + 1) & (nr_bufs - 1);\n\tret = 1;\nout:\n\tif (pending_shutdown(c))\n\t\tclose_cd(c, cd);\n\n\treturn ret;\n}\n\n/*\n * Handling a send with an outgoing send ring. Get the buffers from the\n * receive side, and add them to the ingoing buffer ring again.\n */\nstatic int handle_send_ring(struct conn *c, struct conn_dir *cd, int bid,\n\t\t\t    int bytes)\n{\n\tstruct conn_buf_ring *in_cbr = &c->in_br;\n\tstruct conn_buf_ring *out_cbr = &c->out_br;\n\tint i = 0;\n\n\twhile (bytes) {\n\t\tstruct io_uring_buf *buf = &out_cbr->br->bufs[bid];\n\t\tint this_bytes;\n\t\tvoid *this_buf;\n\n\t\tthis_bytes = buf->len;\n\t\tif (this_bytes > bytes)\n\t\t\tthis_bytes = bytes;\n\n\t\tcd->out_bytes += this_bytes;\n\n\t\tvlog(\"%d: send: bid=%d, len=%d\\n\", c->tid, bid, this_bytes);\n\n\t\tthis_buf = in_cbr->buf + bid * buf_size;\n\t\tio_uring_buf_ring_add(in_cbr->br, this_buf, buf_size, bid, br_mask, i);\n\t\t/*\n\t\t * Find the provided buffer that the receive consumed, and\n\t\t * which we then used for the send, and add it back to the\n\t\t * pool so it can get picked by another receive. Once the send\n\t\t * is done, we're done with it.\n\t\t */\n\t\tbid = (bid + 1) & (nr_bufs - 1);\n\t\tbytes -= this_bytes;\n\t\ti++;\n\t}\n\tcd->snd_next_bid = bid;\n\tio_uring_buf_ring_advance(in_cbr->br, i);\n\n\tif (pending_shutdown(c))\n\t\tclose_cd(c, cd);\n\n\treturn i;\n}\n\n/*\n * sendmsg, or send without a ring. Just add buffers back to the ingoing\n * ring for receives.\n */\nstatic int handle_send_buf(struct conn *c, struct conn_dir *cd, int bid,\n\t\t\t   int bytes)\n{\n\tstruct conn_buf_ring *in_cbr = &c->in_br;\n\tint i = 0;\n\n\twhile (bytes) {\n\t\tstruct io_uring_buf *buf = &in_cbr->br->bufs[bid];\n\t\tint this_bytes;\n\n\t\tthis_bytes = bytes;\n\t\tif (this_bytes > buf->len)\n\t\t\tthis_bytes = buf->len;\n\n\t\tvlog(\"%d: send: bid=%d, len=%d\\n\", c->tid, bid, this_bytes);\n\n\t\tcd->out_bytes += this_bytes;\n\t\t/* each recvmsg mshot package has this overhead */\n\t\tif (rcv_msg && recv_mshot)\n\t\t\tcd->out_bytes += sizeof(struct io_uring_recvmsg_out);\n\t\treplenish_buffer(in_cbr, bid, i);\n\t\tbid = (bid + 1) & (nr_bufs - 1);\n\t\tbytes -= this_bytes;\n\t\ti++;\n\t}\n\tio_uring_buf_ring_advance(in_cbr->br, i);\n\tcd->snd_next_bid = bid;\n\treturn i;\n}\n\nstatic int __handle_send(struct io_uring *ring, struct conn *c,\n\t\t\t struct conn_dir *cd, struct io_uring_cqe *cqe)\n{\n\tstruct conn_dir *ocd;\n\tint bid, nr_packets;\n\n\tif (send_ring) {\n\t\tif (!(cqe->flags & IORING_CQE_F_BUFFER)) {\n\t\t\tfprintf(stderr, \"no buffer in send?! %d\\n\", cqe->res);\n\t\t\treturn 1;\n\t\t}\n\t\tbid = cqe->flags >> IORING_CQE_BUFFER_SHIFT;\n\t} else {\n\t\tbid = cqe_to_bid(cqe);\n\t}\n\n\t/*\n\t * CQE notifications only happen with send/sendmsg zerocopy. They\n\t * tell us that the data has been acked, and that hence the buffer\n\t * is now free to reuse. Waiting on an ACK for each packet will slow\n\t * us down tremendously, so do all of our sends and then wait for\n\t * the ACKs to come in. They tend to come in bundles anyway. Once\n\t * all acks are done (cd->snd_notif == 0), then fire off the next\n\t * receive.\n\t */\n\tif (cqe->flags & IORING_CQE_F_NOTIF) {\n\t\tcd->snd_notif--;\n\t} else {\n\t\tif (cqe->res && cqe->res < buf_size)\n\t\t\tcd->snd_shrt++;\n\n\t\t/*\n\t\t * BIDI will use the same buffer pool and do sends on both CDs,\n\t\t * so can't reliably check. TODO.\n\t\t */\n\t\tif (!bidi && send_ring && cd->snd_next_bid != -1 &&\n\t\t    bid != cd->snd_next_bid) {\n\t\t\tfprintf(stderr, \"send bid %d, wanted %d at %lu\\n\", bid,\n\t\t\t\t\tcd->snd_next_bid, cd->out_bytes);\n\t\t\tgoto out_close;\n\t\t}\n\n\t\tassert(bid <= nr_bufs);\n\n\t\tvlog(\"send: got %d, %lu\\n\", cqe->res, cd->out_bytes);\n\n\t\tif (buf_ring_inc)\n\t\t\tnr_packets = handle_send_inc(c, cd, bid, cqe);\n\t\telse if (send_ring)\n\t\t\tnr_packets = handle_send_ring(c, cd, bid, cqe->res);\n\t\telse\n\t\t\tnr_packets = handle_send_buf(c, cd, bid, cqe->res);\n\n\t\tif (cd->snd_bucket)\n\t\t\tcd->snd_bucket[nr_packets]++;\n\n\t\tcd->out_buffers -= nr_packets;\n\t\tassert(cd->out_buffers >= 0);\n\n\t\tcd->snd++;\n\t}\n\n\tif (!(cqe->flags & IORING_CQE_F_MORE)) {\n\t\tint do_recv_arm;\n\n\t\tcd->pending_send = 0;\n\n\t\t/*\n\t\t * send done - see if the current vec has data to submit, and\n\t\t * do so if it does. if it doesn't have data yet, nothing to\n\t\t * do.\n\t\t */\n\t\tdo_recv_arm = !prep_next_send(ring, c, cd, cqe_to_fd(cqe));\n\n\t\tocd = &c->cd[!cd->index];\n\t\tif (!cd->snd_notif && do_recv_arm && !ocd->pending_recv) {\n\t\t\tint fd = other_dir_fd(c, cqe_to_fd(cqe));\n\n\t\t\t__submit_receive(ring, c, ocd, fd);\n\t\t}\nout_close:\n\t\tif (pending_shutdown(c))\n\t\t\tclose_cd(c, cd);\n\t}\n\n\tvlog(\"%d: pending sends %d\\n\", c->tid, cd->pending_send);\n\treturn 0;\n}\n\nstatic int handle_send(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tstruct conn_dir *cd = cqe_to_conn_dir(c, cqe);\n\n\treturn __handle_send(ring, c, cd, cqe);\n}\n\nstatic int send_error(struct error_handler *err, struct io_uring *ring,\n\t\t      struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tstruct conn_dir *cd = cqe_to_conn_dir(c, cqe);\n\n\tcd->pending_send = 0;\n\n\t/* res can have high bit set */\n\tif (cqe->flags & IORING_CQE_F_NOTIF)\n\t\treturn handle_send(ring, cqe);\n\tif (cqe->res != -ENOBUFS)\n\t\treturn default_error(err, ring, cqe);\n\n\tcd->snd_enobufs++;\n\treturn 0;\n}\n\n/*\n * We don't expect to get here, as we marked it with skipping posting a\n * CQE if it was successful. If it does trigger, than means it fails and\n * that our close has not been done. Log the shutdown error and issue a new\n * separate close.\n */\nstatic int handle_shutdown(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tstruct io_uring_sqe *sqe;\n\tint fd = cqe_to_fd(cqe);\n\n\tfprintf(stderr, \"Got shutdown notification on fd %d\\n\", fd);\n\n\tif (!cqe->res)\n\t\tfprintf(stderr, \"Unexpected success shutdown CQE\\n\");\n\telse if (cqe->res < 0)\n\t\tfprintf(stderr, \"Shutdown got %s\\n\", strerror(-cqe->res));\n\n\tsqe = get_sqe(ring);\n\tif (fixed_files)\n\t\tio_uring_prep_close_direct(sqe, fd);\n\telse\n\t\tio_uring_prep_close(sqe, fd);\n\tencode_userdata(sqe, c, __CLOSE, 0, fd);\n\treturn 0;\n}\n\n/*\n * Final stage of a connection, the shutdown and close has finished. Mark\n * it as disconnected and let the main loop reap it.\n */\nstatic int handle_close(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tint fd = cqe_to_fd(cqe);\n\n\tprintf(\"Closed client: id=%d, in_fd=%d, out_fd=%d\\n\", c->tid, c->in_fd, c->out_fd);\n\tif (fd == c->in_fd)\n\t\tc->in_fd = -1;\n\telse if (fd == c->out_fd)\n\t\tc->out_fd = -1;\n\n\tif (c->in_fd == -1 && c->out_fd == -1) {\n\t\tc->flags |= CONN_F_DISCONNECTED;\n\n\t\tpthread_mutex_lock(&thread_lock);\n\t\t__show_stats(c);\n\t\topen_conns--;\n\t\tpthread_mutex_unlock(&thread_lock);\n\t\tfree_buffer_rings(ring, c);\n\t\tfree_msgs(&c->cd[0]);\n\t\tfree_msgs(&c->cd[1]);\n\t\tfree(c->cd[0].rcv_bucket);\n\t\tfree(c->cd[0].snd_bucket);\n\t}\n\n\treturn 0;\n}\n\nstatic int handle_cancel(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tint fd = cqe_to_fd(cqe);\n\n\tc->pending_cancels--;\n\n\tvlog(\"%d: got cancel fd %d, refs %d\\n\", c->tid, fd, c->pending_cancels);\n\n\tif (!c->pending_cancels) {\n\t\tqueue_shutdown_close(ring, c, c->in_fd);\n\t\tif (c->out_fd != -1)\n\t\t\tqueue_shutdown_close(ring, c, c->out_fd);\n\t\tio_uring_submit(ring);\n\t}\n\n\treturn 0;\n}\n\nstatic void open_socket(struct conn *c)\n{\n\tif (is_sink) {\n\t\tpthread_mutex_lock(&thread_lock);\n\t\topen_conns++;\n\t\tpthread_mutex_unlock(&thread_lock);\n\n\t\tsubmit_receive(&c->ring, c);\n\t} else {\n\t\tstruct io_uring_sqe *sqe;\n\t\tint domain;\n\n\t\tif (ipv6)\n\t\t\tdomain = AF_INET6;\n\t\telse\n\t\t\tdomain = AF_INET;\n\n\t\t/*\n\t\t * If fixed_files is set, proxy will use fixed files for any new\n\t\t * file descriptors it instantiates. Fixd files, or fixed\n\t\t * descriptors, are io_uring private file descriptors. They\n\t\t * cannot be accessed outside of io_uring. io_uring holds a\n\t\t * fixed reference to them, which means that we do not need to\n\t\t * grab per-request references to them. Particularly for\n\t\t * threaded applications, grabbing and dropping file references\n\t\t * for each operation can be costly as the file table is shared.\n\t\t * This generally shows up as fget/fput related overhead in any\n\t\t * workload profiles.\n\t\t *\n\t\t * Fixed descriptors are passed in via the 'fd' field just like\n\t\t * regular descriptors, and then marked as such by setting the\n\t\t * IOSQE_FIXED_FILE flag in the sqe->flags field. Some helpers\n\t\t * do that automatically, like the below, others will need it\n\t\t * set manually if they don't have a *direct*() helper.\n\t\t *\n\t\t * For operations that instantiate them, like the opening of a\n\t\t * direct socket, the application may either ask the kernel to\n\t\t * find a free one (as is done below), or the application may\n\t\t * manage the space itself and pass in an index for a currently\n\t\t * free slot in the table. If the kernel is asked to allocate a\n\t\t * free direct descriptor, note that io_uring does not abide by\n\t\t * the POSIX mandated \"lowest free must be returned\". It may\n\t\t * return any free descriptor of its choosing.\n\t\t */\n\t\tsqe = get_sqe(&c->ring);\n\t\tif (fixed_files)\n\t\t\tio_uring_prep_socket_direct_alloc(sqe, domain, SOCK_STREAM, 0, 0);\n\t\telse\n\t\t\tio_uring_prep_socket(sqe, domain, SOCK_STREAM, 0, 0);\n\t\tencode_userdata(sqe, c, __SOCK, 0, 0);\n\t}\n}\n\n/*\n * Start of connection, we got our in descriptor.\n */\nstatic int handle_fd_pass(struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\tint fd = cqe_to_fd(cqe);\n\n\tvlog(\"%d: got fd pass %d\\n\", c->tid, fd);\n\tc->in_fd = fd;\n\topen_socket(c);\n\treturn 0;\n}\n\nstatic int handle_stop(struct io_uring_cqe *cqe)\n{\n\tstruct conn *c = cqe_to_conn(cqe);\n\n\tprintf(\"Client %d: queueing shutdown\\n\", c->tid);\n\tqueue_cancel(&c->ring, c);\n\treturn 0;\n}\n\n/*\n * Called for each CQE that we receive. Decode the request type that it\n * came from, and call the appropriate handler.\n */\nstatic int handle_cqe(struct io_uring *ring, struct io_uring_cqe *cqe)\n{\n\tint ret;\n\n\t/*\n\t * Unlikely, but there's an error in this CQE. If an error handler\n\t * is defined, call it, and that will deal with it. If no error\n\t * handler is defined, the opcode handler either doesn't care or will\n\t * handle it on its own.\n\t */\n\tif (cqe->res < 0) {\n\t\tstruct error_handler *err = &error_handlers[cqe_to_op(cqe)];\n\n\t\tif (err->error_fn)\n\t\t\treturn err->error_fn(err, ring, cqe);\n\t}\n\n\tswitch (cqe_to_op(cqe)) {\n\tcase __ACCEPT:\n\t\tret = handle_accept(ring, cqe);\n\t\tbreak;\n\tcase __SOCK:\n\t\tret = handle_sock(ring, cqe);\n\t\tbreak;\n\tcase __CONNECT:\n\t\tret = handle_connect(ring, cqe);\n\t\tbreak;\n\tcase __RECV:\n\tcase __RECVMSG:\n\t\tret = handle_recv(ring, cqe);\n\t\tbreak;\n\tcase __SEND:\n\tcase __SENDMSG:\n\t\tret = handle_send(ring, cqe);\n\t\tbreak;\n\tcase __CANCEL:\n\t\tret = handle_cancel(ring, cqe);\n\t\tbreak;\n\tcase __SHUTDOWN:\n\t\tret = handle_shutdown(ring, cqe);\n\t\tbreak;\n\tcase __CLOSE:\n\t\tret = handle_close(ring, cqe);\n\t\tbreak;\n\tcase __FD_PASS:\n\t\tret = handle_fd_pass(cqe);\n\t\tbreak;\n\tcase __STOP:\n\t\tret = handle_stop(cqe);\n\t\tbreak;\n\tcase __NOP:\n\t\tret = 0;\n\t\tbreak;\n\tdefault:\n\t\tfprintf(stderr, \"bad user data %lx\\n\", (long) cqe->user_data);\n\t\treturn 1;\n\t}\n\n\treturn ret;\n}\n\nstatic void house_keeping(struct io_uring *ring)\n{\n\tstatic unsigned long last_bytes;\n\tunsigned long bytes, elapsed;\n\tstruct conn *c;\n\tint i, j;\n\n\tvlog(\"House keeping entered\\n\");\n\n\tbytes = 0;\n\tfor (i = 0; i < nr_conns; i++) {\n\t\tc = &conns[i];\n\n\t\tfor (j = 0; j < 2; j++) {\n\t\t\tstruct conn_dir *cd = &c->cd[j];\n\n\t\t\tbytes += cd->in_bytes + cd->out_bytes;\n\t\t}\n\t\tif (c->flags & CONN_F_DISCONNECTED) {\n\t\t\tvlog(\"%d: disconnected\\n\", i);\n\n\t\t\tif (!(c->flags & CONN_F_REAPED)) {\n\t\t\t\tvoid *ret;\n\n\t\t\t\tpthread_join(c->thread, &ret);\n\t\t\t\tc->flags |= CONN_F_REAPED;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (c->flags & CONN_F_DISCONNECTING)\n\t\t\tcontinue;\n\n\t\tif (should_shutdown(c)) {\n\t\t\t__close_conn(ring, c);\n\t\t\tc->flags |= CONN_F_DISCONNECTING;\n\t\t}\n\t}\n\n\telapsed = mtime_since_now(&last_housekeeping);\n\tif (bytes && elapsed >= 900) {\n\t\tunsigned long bw;\n\n\t\tbw = (8 * (bytes - last_bytes) / 1000UL) / elapsed;\n\t\tif (bw) {\n\t\t\tif (open_conns)\n\t\t\t\tprintf(\"Bandwidth (threads=%d): %'luMbit\\n\", open_conns, bw);\n\t\t\tgettimeofday(&last_housekeeping, NULL);\n\t\t\tlast_bytes = bytes;\n\t\t}\n\t}\n}\n\n/*\n * Event loop shared between the parent, and the connections. Could be\n * split in two, as they don't handle the same types of events. For the per\n * connection loop, 'c' is valid. For the main loop, it's NULL.\n */\nstatic int __event_loop(struct io_uring *ring, struct conn *c)\n{\n\tstruct __kernel_timespec active_ts, idle_ts;\n\tint flags;\n\n\tidle_ts.tv_sec = 0;\n\tidle_ts.tv_nsec = 100000000LL;\n\tactive_ts = idle_ts;\n\tif (wait_usec > 1000000) {\n\t\tactive_ts.tv_sec = wait_usec / 1000000;\n\t\twait_usec -= active_ts.tv_sec * 1000000;\n\t}\n\tactive_ts.tv_nsec = wait_usec * 1000;\n\n\tgettimeofday(&last_housekeeping, NULL);\n\n\tflags = 0;\n\twhile (1) {\n\t\tstruct __kernel_timespec *ts = &idle_ts;\n\t\tstruct io_uring_cqe *cqe;\n\t\tunsigned int head;\n\t\tint ret, i, to_wait;\n\n\t\t/*\n\t\t * If wait_batch is set higher than 1, then we'll wait on\n\t\t * that amount of CQEs to be posted each loop. If used with\n\t\t * DEFER_TASKRUN, this can provide a substantial reduction\n\t\t * in context switch rate as the task isn't woken until the\n\t\t * requested number of events can be returned.\n\t\t *\n\t\t * Can be used with -t to set a wait_usec timeout as well.\n\t\t * For example, if an application can deal with 250 usec\n\t\t * of wait latencies, it can set -w8 -t250 which will cause\n\t\t * io_uring to return when either 8 events have been received,\n\t\t * or if 250 usec of waiting has passed.\n\t\t *\n\t\t * If we don't have any open connections, wait on just 1\n\t\t * always.\n\t\t */\n\t\tto_wait = 1;\n\t\tif (open_conns && !flags) {\n\t\t\tts = &active_ts;\n\t\t\tto_wait = wait_batch;\n\t\t}\n\n\t\tvlog(\"Submit and wait for %d\\n\", to_wait);\n\t\tret = io_uring_submit_and_wait_timeout(ring, &cqe, to_wait, ts, NULL);\n\n\t\tif (*ring->cq.koverflow)\n\t\t\tprintf(\"overflow %u\\n\", *ring->cq.koverflow);\n\t\tif (*ring->sq.kflags &  IORING_SQ_CQ_OVERFLOW)\n\t\t\tprintf(\"saw overflow\\n\");\n\n\t\tvlog(\"Submit and wait: %d\\n\", ret);\n\n\t\ti = flags = 0;\n\t\tio_uring_for_each_cqe(ring, head, cqe) {\n\t\t\tif (handle_cqe(ring, cqe))\n\t\t\t\treturn 1;\n\t\t\tflags |= cqe_to_conn(cqe)->flags;\n\t\t\t++i;\n\t\t}\n\n\t\tvlog(\"Handled %d events\\n\", i);\n\n\t\t/*\n\t\t * Advance the CQ ring for seen events when we've processed\n\t\t * all of them in this loop. This can also be done with\n\t\t * io_uring_cqe_seen() in each handler above, which just marks\n\t\t * that single CQE as seen. However, it's more efficient to\n\t\t * mark a batch as seen when we're done with that batch.\n\t\t */\n\t\tif (i) {\n\t\t\tio_uring_cq_advance(ring, i);\n\t\t\tevents += i;\n\t\t}\n\n\t\tevent_loops++;\n\t\tif (c) {\n\t\t\tif (c->flags & CONN_F_DISCONNECTED)\n\t\t\t\tbreak;\n\t\t} else {\n\t\t\thouse_keeping(ring);\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n * Main event loop, Submit our multishot accept request, and then just loop\n * around handling incoming connections.\n */\nstatic int parent_loop(struct io_uring *ring, int fd)\n{\n\tstruct io_uring_sqe *sqe;\n\n\t/*\n\t * proxy provides a way to use either multishot receive or not, but\n\t * for accept, we always use multishot. A multishot accept request\n\t * needs only be armed once, and then it'll trigger a completion and\n\t * post a CQE whenever a new connection is accepted. No need to do\n\t * anything else, unless the multishot accept terminates. This happens\n\t * if it encounters an error. Applications should check for\n\t * IORING_CQE_F_MORE in cqe->flags - this tells you if more completions\n\t * are expected from this request or not. Non-multishot never have\n\t * this set, where multishot will always have this set unless an error\n\t * occurs.\n\t */\n\tsqe = get_sqe(ring);\n\tif (fixed_files)\n\t\tio_uring_prep_multishot_accept_direct(sqe, fd, NULL, NULL, 0);\n\telse\n\t\tio_uring_prep_multishot_accept(sqe, fd, NULL, NULL, 0);\n\t__encode_userdata(sqe, 0, __ACCEPT, 0, fd);\n\n\treturn __event_loop(ring, NULL);\n}\n\nstatic int init_ring(struct io_uring *ring, int nr_files)\n{\n\tstruct io_uring_params params;\n\tint ret;\n\n\t/*\n\t * By default, set us up with a big CQ ring. Not strictly needed\n\t * here, but it's very important to never overflow the CQ ring.\n\t * Events will not be dropped if this happens, but it does slow\n\t * the application down in dealing with overflown events.\n\t *\n\t * Set SINGLE_ISSUER, which tells the kernel that only one thread\n\t * is doing IO submissions. This enables certain optimizations in\n\t * the kernel.\n\t */\n\tmemset(&params, 0, sizeof(params));\n\tparams.flags |= IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_CLAMP;\n\tparams.flags |= IORING_SETUP_CQSIZE;\n\tparams.cq_entries = 1024;\n\n\t/*\n\t * If use_huge is set, setup the ring with IORING_SETUP_NO_MMAP. This\n\t * means that the application allocates the memory for the ring, and\n\t * the kernel maps it. The alternative is having the kernel allocate\n\t * the memory, and then liburing will mmap it. But we can't really\n\t * support huge pages that way. If this fails, then ensure that the\n\t * system has huge pages set aside upfront.\n\t */\n\tif (use_huge)\n\t\tparams.flags |= IORING_SETUP_NO_MMAP;\n\n\t/*\n\t * DEFER_TASKRUN decouples async event reaping and retrying from\n\t * regular system calls. If this isn't set, then io_uring uses\n\t * normal task_work for this. task_work is always being run on any\n\t * exit to userspace. Real applications do more than just call IO\n\t * related system calls, and hence we can be running this work way\n\t * too often. Using DEFER_TASKRUN defers any task_work running to\n\t * when the application enters the kernel anyway to wait on new\n\t * events. It's generally the preferred and recommended way to setup\n\t * a ring.\n\t */\n\tif (defer_tw) {\n\t\tparams.flags |= IORING_SETUP_DEFER_TASKRUN;\n\t\tsqpoll = 0;\n\t}\n\n\t/*\n\t * SQPOLL offloads any request submission and retry operations to a\n\t * dedicated thread. This enables an application to do IO without\n\t * ever having to enter the kernel itself. The SQPOLL thread will\n\t * stay busy as long as there's work to do, and go to sleep if\n\t * sq_thread_idle msecs have passed. If it's running, submitting new\n\t * IO just needs to make them visible to the SQPOLL thread, it needs\n\t * not enter the kernel. For submission, the application will only\n\t * enter the kernel if the SQPOLL has been idle long enough that it\n\t * has gone to sleep.\n\t *\n\t * Waiting on events still need to enter the kernel, if none are\n\t * available. The application may also use io_uring_peek_cqe() to\n\t * check for new events without entering the kernel, as completions\n\t * will be continually produced to the CQ ring by the SQPOLL thread\n\t * as they occur.\n\t */\n\tif (sqpoll) {\n\t\tparams.flags |= IORING_SETUP_SQPOLL;\n\t\tparams.sq_thread_idle = 1000;\n\t\tdefer_tw = 0;\n\t}\n\n\t/*\n\t * If neither DEFER_TASKRUN or SQPOLL is used, set COOP_TASKRUN. This\n\t * avoids heavy signal based notifications, which can force an\n\t * application to enter the kernel and process it as soon as they\n\t * occur.\n\t */\n\tif (!sqpoll && !defer_tw)\n\t\tparams.flags |= IORING_SETUP_COOP_TASKRUN;\n\n\t/*\n\t * The SQ ring size need not be larger than any batch of requests\n\t * that need to be prepared before submit. Normally in a loop we'd\n\t * only need a few, if any, particularly if multishot is used.\n\t */\n\tret = io_uring_queue_init_params(ring_size, ring, &params);\n\tif (ret) {\n\t\tfprintf(stderr, \"%s\\n\", strerror(-ret));\n\t\treturn 1;\n\t}\n\n\t/*\n\t * If send serialization is available and no option was given to use\n\t * it or not, default it to on. If it was turned on and the kernel\n\t * doesn't support it, turn it off.\n\t */\n\tif (params.features & IORING_FEAT_SEND_BUF_SELECT) {\n\t\tif (send_ring == -1)\n\t\t\tsend_ring = 1;\n\t} else {\n\t\tif (send_ring == 1) {\n\t\t\tfprintf(stderr, \"Kernel doesn't support ring provided \"\n\t\t\t\t\"buffers for sends, disabled\\n\");\n\t\t}\n\t\tsend_ring = 0;\n\t}\n\n\tif (!send_ring && snd_bundle) {\n\t\tfprintf(stderr, \"Can't use send bundle without send_ring\\n\");\n\t\tsnd_bundle = 0;\n\t}\n\n\tif (fixed_files) {\n\t\t/*\n\t\t * If fixed files are used, we need to allocate a fixed file\n\t\t * table upfront where new direct descriptors can be managed.\n\t\t */\n\t\tret = io_uring_register_files_sparse(ring, nr_files);\n\t\tif (ret) {\n\t\t\tfprintf(stderr, \"file register: %d\\n\", ret);\n\t\t\treturn 1;\n\t\t}\n\n\t\t/*\n\t\t * If fixed files are used, we also register the ring fd. See\n\t\t * comment near io_uring_prep_socket_direct_alloc() further\n\t\t * down. This avoids the fget/fput overhead associated with\n\t\t * the io_uring_enter(2) system call itself, which is used to\n\t\t * submit and wait on events.\n\t\t */\n\t\tret = io_uring_register_ring_fd(ring);\n\t\tif (ret != 1) {\n\t\t\tfprintf(stderr, \"ring register: %d\\n\", ret);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tif (napi) {\n\t\tstruct io_uring_napi n = {\n\t\t\t.prefer_busy_poll = napi > 1 ? 1 : 0,\n\t\t\t.busy_poll_to = napi_timeout,\n\t\t};\n\n\t\tret = io_uring_register_napi(ring, &n);\n\t\tif (ret) {\n\t\t\tfprintf(stderr, \"io_uring_register_napi: %d\\n\", ret);\n\t\t\tif (ret != -EINVAL)\n\t\t\t\treturn 1;\n\t\t\tfprintf(stderr, \"NAPI not available, turned off\\n\");\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nstatic void *thread_main(void *data)\n{\n\tstruct conn *c = data;\n\tint ret;\n\n\tc->flags |= CONN_F_STARTED;\n\n\t/* we need a max of 4 descriptors for each client */\n\tret = init_ring(&c->ring, 4);\n\tif (ret)\n\t\tgoto done;\n\n\tif (setup_buffer_rings(&c->ring, c))\n\t\tgoto done;\n\n\t/*\n\t * If we're using fixed files, then we need to wait for the parent\n\t * to install the c->in_fd into our direct descriptor table. When\n\t * that happens, we'll set things up. If we're not using fixed files,\n\t * we can set up the receive or connect now.\n\t */\n\tif (!fixed_files)\n\t\topen_socket(c);\n\n\t/* we're ready */\n\tpthread_barrier_wait(&c->startup_barrier);\n\n\t__event_loop(&c->ring, c);\ndone:\n\treturn NULL;\n}\n\nstatic void usage(const char *name)\n{\n\tprintf(\"%s:\\n\", name);\n\tprintf(\"\\t-m:\\t\\tUse multishot receive (%d)\\n\", recv_mshot);\n\tprintf(\"\\t-d:\\t\\tUse DEFER_TASKRUN (%d)\\n\", defer_tw);\n\tprintf(\"\\t-S:\\t\\tUse SQPOLL (%d)\\n\", sqpoll);\n\tprintf(\"\\t-f:\\t\\tUse only fixed files (%d)\\n\", fixed_files);\n\tprintf(\"\\t-a:\\t\\tUse huge pages for the ring (%d)\\n\", use_huge);\n\tprintf(\"\\t-t:\\t\\tTimeout for waiting on CQEs (usec) (%d)\\n\", wait_usec);\n\tprintf(\"\\t-w:\\t\\tNumber of CQEs to wait for each loop (%d)\\n\", wait_batch);\n\tprintf(\"\\t-B:\\t\\tUse bi-directional mode (%d)\\n\", bidi);\n\tprintf(\"\\t-s:\\t\\tAct only as a sink (%d)\\n\", is_sink);\n\tprintf(\"\\t-q:\\t\\tRing size to use (%d)\\n\", ring_size);\n\tprintf(\"\\t-H:\\t\\tHost to connect to (%s)\\n\", host);\n\tprintf(\"\\t-r:\\t\\tPort to receive on (%d)\\n\", receive_port);\n\tprintf(\"\\t-p:\\t\\tPort to connect to (%d)\\n\", send_port);\n\tprintf(\"\\t-6:\\t\\tUse IPv6 (%d)\\n\", ipv6);\n\tprintf(\"\\t-N:\\t\\tUse NAPI polling (%d)\\n\", napi);\n\tprintf(\"\\t-T:\\t\\tNAPI timeout (usec) (%d)\\n\", napi_timeout);\n\tprintf(\"\\t-b:\\t\\tSend/receive buf size (%d)\\n\", buf_size);\n\tprintf(\"\\t-n:\\t\\tNumber of provided buffers (pow2) (%d)\\n\", nr_bufs);\n\tprintf(\"\\t-u:\\t\\tUse provided buffers for send (%d)\\n\", send_ring);\n\tprintf(\"\\t-C:\\t\\tUse bundles for send (%d)\\n\", snd_bundle);\n\tprintf(\"\\t-z:\\t\\tUse zerocopy send (%d)\\n\", snd_zc);\n\tprintf(\"\\t-c:\\t\\tUse bundles for recv (%d)\\n\", snd_bundle);\n\tprintf(\"\\t-M:\\t\\tUse sendmsg (%d)\\n\", snd_msg);\n\tprintf(\"\\t-M:\\t\\tUse recvmsg (%d)\\n\", rcv_msg);\n\tprintf(\"\\t-x:\\t\\tShow extended stats (%d)\\n\", ext_stat);\n\tprintf(\"\\t-V:\\t\\tIncrease verbosity (%d)\\n\", verbose);\n}\n\n/*\n * Options parsing the ring / net setup\n */\nint main(int argc, char *argv[])\n{\n\tstruct io_uring ring;\n\tstruct sigaction sa = { };\n\tconst char *optstring;\n\tint opt, ret, fd;\n\n\tsetlocale(LC_NUMERIC, \"en_US\");\n\n\tpage_size = sysconf(_SC_PAGESIZE);\n\tif (page_size < 0) {\n\t\tperror(\"sysconf(_SC_PAGESIZE)\");\n\t\treturn 1;\n\t}\n\n\tpthread_mutex_init(&thread_lock, NULL);\n\n\toptstring = \"m:d:S:s:b:f:H:r:p:n:B:N:T:w:t:M:R:u:c:C:q:a:x:z:i:6Vh?\";\n\twhile ((opt = getopt(argc, argv, optstring)) != -1) {\n\t\tswitch (opt) {\n\t\tcase 'm':\n\t\t\trecv_mshot = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'S':\n\t\t\tsqpoll = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'd':\n\t\t\tdefer_tw = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'b':\n\t\t\tbuf_size = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'n':\n\t\t\tnr_bufs = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'u':\n\t\t\tsend_ring = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'c':\n\t\t\trcv_bundle = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'C':\n\t\t\tsnd_bundle = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'w':\n\t\t\twait_batch = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 't':\n\t\t\twait_usec = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 's':\n\t\t\tis_sink = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'f':\n\t\t\tfixed_files = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'H':\n\t\t\thost = strdup(optarg);\n\t\t\tbreak;\n\t\tcase 'r':\n\t\t\treceive_port = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'p':\n\t\t\tsend_port = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'B':\n\t\t\tbidi = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'N':\n\t\t\tnapi = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'T':\n\t\t\tnapi_timeout = atoi(optarg);\n\t\t\tbreak;\n\t\tcase '6':\n\t\t\tipv6 = true;\n\t\t\tbreak;\n\t\tcase 'M':\n\t\t\tsnd_msg = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'z':\n\t\t\tsnd_zc = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'R':\n\t\t\trcv_msg = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'q':\n\t\t\tring_size = atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'i':\n\t\t\tbuf_ring_inc = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'a':\n\t\t\tuse_huge = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'x':\n\t\t\text_stat = !!atoi(optarg);\n\t\t\tbreak;\n\t\tcase 'V':\n\t\t\tverbose++;\n\t\t\tbreak;\n\t\tcase 'h':\n\t\tdefault:\n\t\t\tusage(argv[0]);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tif (bidi && is_sink) {\n\t\tfprintf(stderr, \"Can't be both bidi proxy and sink\\n\");\n\t\treturn 1;\n\t}\n\tif (snd_msg && sqpoll) {\n\t\tfprintf(stderr, \"SQPOLL with msg variants disabled\\n\");\n\t\tsnd_msg = 0;\n\t}\n\tif (rcv_msg && rcv_bundle) {\n\t\tfprintf(stderr, \"Can't use bundles with recvmsg\\n\");\n\t\trcv_msg = 0;\n\t}\n\tif (snd_msg && snd_bundle) {\n\t\tfprintf(stderr, \"Can't use bundles with sendmsg\\n\");\n\t\tsnd_msg = 0;\n\t}\n\tif (snd_msg && send_ring) {\n\t\tfprintf(stderr, \"Can't use send ring sendmsg\\n\");\n\t\tsnd_msg = 0;\n\t}\n\tif (snd_zc && (send_ring || snd_bundle)) {\n\t\tfprintf(stderr, \"Can't use send zc with bundles or ring\\n\");\n\t\tsend_ring = snd_bundle = 0;\n\t}\n\t/*\n\t * For recvmsg w/multishot, we waste some data at the head of the\n\t * packet every time. Adjust the buffer size to account for that,\n\t * so we're still handing 'buf_size' actual payload of data.\n\t */\n\tif (rcv_msg && recv_mshot) {\n\t\tfprintf(stderr, \"Adjusted buf size for recvmsg w/multishot\\n\");\n\t\tbuf_size += sizeof(struct io_uring_recvmsg_out);\n\t}\n\n\tbr_mask = nr_bufs - 1;\n\n\tfd = setup_listening_socket(receive_port, ipv6);\n\tif (is_sink)\n\t\tsend_port = -1;\n\n\tif (fd == -1)\n\t\treturn 1;\n\n\tatexit(show_stats);\n\tsa.sa_handler = sig_int;\n\tsa.sa_flags = SA_RESTART;\n\tsigaction(SIGINT, &sa, NULL);\n\n\tret = init_ring(&ring, MAX_CONNS * 3);\n\tif (ret)\n\t\treturn ret;\n\n\tprintf(\"Backend: sqpoll=%d, defer_tw=%d, fixed_files=%d, \"\n\t\t\"is_sink=%d, buf_size=%d, nr_bufs=%d, host=%s, send_port=%d, \"\n\t\t\"receive_port=%d, napi=%d, napi_timeout=%d, huge_page=%d\\n\",\n\t\t\tsqpoll, defer_tw, fixed_files, is_sink,\n\t\t\tbuf_size, nr_bufs, host, send_port, receive_port,\n\t\t\tnapi, napi_timeout, use_huge);\n\tprintf(\" recv options: recvmsg=%d, recv_mshot=%d, recv_bundle=%d\\n\",\n\t\t\trcv_msg, recv_mshot, rcv_bundle);\n\tprintf(\" send options: sendmsg=%d, send_ring=%d, send_bundle=%d, \"\n\t\t\"send_zerocopy=%d\\n\", snd_msg, send_ring, snd_bundle,\n\t\t\tsnd_zc);\n\n\treturn parent_loop(&ring, fd);\n}\n"},
                          "roles": ["analysisTarget",
                                    "tracedFile"]}],
           "results": [{"ruleId": "-Wanalyzer-possible-null-dereference",
                        "taxa": [{"id": "690",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3195},
                                       "gcc/analyzer/saved_diagnostic/var": "_12",
                                       "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2296)",
                                       "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                       "gcc/analyzer/saved_diagnostic/idx": 19,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 2264},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_12",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2296)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 17,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"}},
                                                                                    {"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 1818},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_12",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2296)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 0,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"}},
                                                                                    {"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3680},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_12",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2296)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 32,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"},
                        "level": "warning",
                        "message": {"text": "dereference of possibly-NULL ‘sstat’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 515,
                                                                       "startColumn": 17,
                                                                       "endColumn": 40},
                                                            "contextRegion": {"startLine": 515,
                                                                              "snippet": {"text": "\t\tsstat[i].nr_packets = i;\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "show_buckets"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 550,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 550,
                                                                                                                           "snippet": {"text": "static void __show_stats(struct conn *c)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "entry to ‘__show_stats’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 572,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 572,
                                                                                                                           "snippet": {"text": "\tif (!qps)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘qps != 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 575,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 575,
                                                                                                                           "snippet": {"text": "\tif (msec)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 582,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 582,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 583,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 31},
                                                                                                         "contextRegion": {"startLine": 583,
                                                                                                                           "snippet": {"text": "\t\tcd = &c->cd[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 241,
                                                                                                                                 "dst_id": 242}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 600,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 600,
                                                                                                                           "snippet": {"text": "\t\tshow_buckets(cd);\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "calling ‘show_buckets’ from ‘__show_stats’"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 500,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 500,
                                                                                                                           "snippet": {"text": "static void show_buckets(struct conn_dir *cd)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "entry to ‘show_buckets’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 506,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 506,
                                                                                                                           "snippet": {"text": "\tif (!cd->rcv_bucket || !cd->snd_bucket)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 13},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 510,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 510,
                                                                                                                           "snippet": {"text": "\tsstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "this call could return NULL"}},
                                                                       "kinds": ["acquire",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 14},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3112}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 513,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 513,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 15},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3112}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 514,
                                                                                                                    "startColumn": 44,
                                                                                                                    "endColumn": 45},
                                                                                                         "contextRegion": {"startLine": 514,
                                                                                                                           "snippet": {"text": "\t\tsnd_total += cd->snd_bucket[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 16},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(17)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 515,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 40},
                                                                                                         "contextRegion": {"startLine": 515,
                                                                                                                           "snippet": {"text": "\t\tsstat[i].nr_packets = i;\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "‘sstat + (long unsigned int)i * 8’ could be NULL: unchecked value from [(14)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/13)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 17}]}]}]},
                       {"ruleId": "-Wanalyzer-possible-null-dereference",
                        "taxa": [{"id": "690",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3203},
                                       "gcc/analyzer/saved_diagnostic/var": "_17",
                                       "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                       "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                       "gcc/analyzer/saved_diagnostic/idx": 20,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 2272},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_17",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 18,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"}},
                                                                                    {"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 1826},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_17",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 1,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"}},
                                                                                    {"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3688},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_17",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "unchecked ({free})",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 33,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "possible_null_deref"},
                        "level": "warning",
                        "message": {"text": "dereference of possibly-NULL ‘rstat’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 518,
                                                                       "startColumn": 17,
                                                                       "endColumn": 40},
                                                            "contextRegion": {"startLine": 518,
                                                                              "snippet": {"text": "\t\trstat[i].nr_packets = i;\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "show_buckets"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 550,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 550,
                                                                                                                           "snippet": {"text": "static void __show_stats(struct conn *c)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "entry to ‘__show_stats’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 572,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 572,
                                                                                                                           "snippet": {"text": "\tif (!qps)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘qps != 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 575,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 575,
                                                                                                                           "snippet": {"text": "\tif (msec)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 582,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 582,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 583,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 31},
                                                                                                         "contextRegion": {"startLine": 583,
                                                                                                                           "snippet": {"text": "\t\tcd = &c->cd[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 241,
                                                                                                                                 "dst_id": 242}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 600,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 600,
                                                                                                                           "snippet": {"text": "\t\tshow_buckets(cd);\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "calling ‘show_buckets’ from ‘__show_stats’"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 500,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 500,
                                                                                                                           "snippet": {"text": "static void show_buckets(struct conn_dir *cd)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "entry to ‘show_buckets’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 506,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 506,
                                                                                                                           "snippet": {"text": "\tif (!cd->rcv_bucket || !cd->snd_bucket)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 13},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "this call could return NULL"}},
                                                                       "kinds": ["acquire",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 14},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3112}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 513,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 513,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 15},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3112}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 514,
                                                                                                                    "startColumn": 44,
                                                                                                                    "endColumn": 45},
                                                                                                         "contextRegion": {"startLine": 514,
                                                                                                                           "snippet": {"text": "\t\tsnd_total += cd->snd_bucket[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 16},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(17)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 518,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 40},
                                                                                                         "contextRegion": {"startLine": 518,
                                                                                                                           "snippet": {"text": "\t\trstat[i].nr_packets = i;\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "‘rstat + (long unsigned int)i * 8’ could be NULL: unchecked value from [(14)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/13)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 17}]}]}]},
                       {"ruleId": "-Wanalyzer-use-after-free",
                        "taxa": [{"id": "416",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3513},
                                       "gcc/analyzer/saved_diagnostic/var": "_25",
                                       "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                       "gcc/analyzer/saved_diagnostic/state": "freed",
                                       "gcc/analyzer/saved_diagnostic/idx": 29,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3509},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "_25",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "freed",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 26,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "use_after_free"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "use_after_free"},
                        "level": "warning",
                        "message": {"text": "use after ‘free’ of ‘rstat’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 534,
                                                                       "startColumn": 22,
                                                                       "endColumn": 36},
                                                            "contextRegion": {"startLine": 534,
                                                                              "snippet": {"text": "\t\tif (!rstat[i].count && !sstat[i].count)\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "show_buckets"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 550,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 550,
                                                                                                                           "snippet": {"text": "static void __show_stats(struct conn *c)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "entry to ‘__show_stats’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 572,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 572,
                                                                                                                           "snippet": {"text": "\tif (!qps)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘qps != 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 575,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 575,
                                                                                                                           "snippet": {"text": "\tif (msec)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 582,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 582,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 583,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 31},
                                                                                                         "contextRegion": {"startLine": 583,
                                                                                                                           "snippet": {"text": "\t\tcd = &c->cd[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 241,
                                                                                                                                 "dst_id": 242}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 600,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 600,
                                                                                                                           "snippet": {"text": "\t\tshow_buckets(cd);\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "calling ‘show_buckets’ from ‘__show_stats’"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 500,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 500,
                                                                                                                           "snippet": {"text": "static void show_buckets(struct conn_dir *cd)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "entry to ‘show_buckets’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 506,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 506,
                                                                                                                           "snippet": {"text": "\tif (!cd->rcv_bucket || !cd->snd_bucket)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 13},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "allocated here"}},
                                                                       "kinds": ["acquire",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 14},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3112}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 513,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 513,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 15},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3112}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 514,
                                                                                                                    "startColumn": 44,
                                                                                                                    "endColumn": 45},
                                                                                                         "contextRegion": {"startLine": 514,
                                                                                                                           "snippet": {"text": "\t\tsnd_total += cd->snd_bucket[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 16},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(17)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 518,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 40},
                                                                                                         "contextRegion": {"startLine": 518,
                                                                                                                           "snippet": {"text": "\t\trstat[i].nr_packets = i;\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "assuming ‘rstat’ is non-NULL"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 17},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(18)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3134}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 513,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 513,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 18},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(19)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3111,
                                                                                                                                 "dst_id": 3134}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 522,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 37},
                                                                                                         "contextRegion": {"startLine": 522,
                                                                                                                           "snippet": {"text": "\tif (!snd_total && !rcv_total) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 19},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(20)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3135,
                                                                                                                                 "dst_id": 3136}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 522,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 522,
                                                                                                                           "snippet": {"text": "\tif (!snd_total && !rcv_total) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 20},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(21)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3135,
                                                                                                                                 "dst_id": 3136}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 523,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 523,
                                                                                                                           "snippet": {"text": "\t\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 21},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(22)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 524,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 524,
                                                                                                                           "snippet": {"text": "\t\tfree(rstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "freed here"}},
                                                                       "kinds": ["release",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 22},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(23)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3141,
                                                                                                                                 "dst_id": 3145}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 526,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 526,
                                                                                                                           "snippet": {"text": "\tif (snd_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘snd_total == 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 23},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(24)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3141,
                                                                                                                                 "dst_id": 3145}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 528,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 528,
                                                                                                                           "snippet": {"text": "\tif (rcv_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 24},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(25)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3147,
                                                                                                                                 "dst_id": 3152}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 528,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 528,
                                                                                                                           "snippet": {"text": "\tif (rcv_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘rcv_total == 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 25},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(26)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3147,
                                                                                                                                 "dst_id": 3152}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 531,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 46},
                                                                                                         "contextRegion": {"startLine": 531,
                                                                                                                           "snippet": {"text": "\tprintf(\"\\t Packets per recv/send:\\n\");\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 26},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(27)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3158,
                                                                                                                                 "dst_id": 3159}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 532,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 532,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 27},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(28)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3158,
                                                                                                                                 "dst_id": 3159}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 534,
                                                                                                                    "startColumn": 27,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 534,
                                                                                                                           "snippet": {"text": "\t\tif (!rstat[i].count && !sstat[i].count)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 28},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(29)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 534,
                                                                                                                    "startColumn": 22,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 534,
                                                                                                                           "snippet": {"text": "\t\tif (!rstat[i].count && !sstat[i].count)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "use after ‘free’ of ‘rstat + (long unsigned int)i * 8’; freed at [(22)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/21)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 29}]}]}]},
                       {"ruleId": "-Wanalyzer-double-free",
                        "taxa": [{"id": "415",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3506},
                                       "gcc/analyzer/saved_diagnostic/var": "sstat_58",
                                       "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2296)",
                                       "gcc/analyzer/saved_diagnostic/state": "freed",
                                       "gcc/analyzer/saved_diagnostic/idx": 30,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 2064},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "sstat_58",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2296)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "freed",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 15,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "double_free"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "double_free"},
                        "level": "warning",
                        "message": {"text": "double-‘free’ of ‘sstat’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 546,
                                                                       "startColumn": 9,
                                                                       "endColumn": 20},
                                                            "contextRegion": {"startLine": 546,
                                                                              "snippet": {"text": "\tfree(sstat);\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "show_buckets"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 550,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 550,
                                                                                                                           "snippet": {"text": "static void __show_stats(struct conn *c)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "entry to ‘__show_stats’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 572,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 572,
                                                                                                                           "snippet": {"text": "\tif (!qps)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘qps != 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 575,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 575,
                                                                                                                           "snippet": {"text": "\tif (msec)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 582,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 582,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 583,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 31},
                                                                                                         "contextRegion": {"startLine": 583,
                                                                                                                           "snippet": {"text": "\t\tcd = &c->cd[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 241,
                                                                                                                                 "dst_id": 242}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 600,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 600,
                                                                                                                           "snippet": {"text": "\t\tshow_buckets(cd);\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "calling ‘show_buckets’ from ‘__show_stats’"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 500,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 500,
                                                                                                                           "snippet": {"text": "static void show_buckets(struct conn_dir *cd)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "entry to ‘show_buckets’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 506,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 506,
                                                                                                                           "snippet": {"text": "\tif (!cd->rcv_bucket || !cd->snd_bucket)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 13},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 510,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 510,
                                                                                                                           "snippet": {"text": "\tsstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "allocated here"}},
                                                                       "kinds": ["acquire",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 14},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3135,
                                                                                                                                 "dst_id": 3136}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 522,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 522,
                                                                                                                           "snippet": {"text": "\tif (!snd_total && !rcv_total) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 15},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3135,
                                                                                                                                 "dst_id": 3136}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 523,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 523,
                                                                                                                           "snippet": {"text": "\t\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 16},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(17)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 523,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 523,
                                                                                                                           "snippet": {"text": "\t\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "first ‘free’ here"}},
                                                                       "kinds": ["release",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 17},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(18)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3141,
                                                                                                                                 "dst_id": 3145}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 526,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 526,
                                                                                                                           "snippet": {"text": "\tif (snd_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘snd_total == 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 18},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(19)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3141,
                                                                                                                                 "dst_id": 3145}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 528,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 528,
                                                                                                                           "snippet": {"text": "\tif (rcv_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 19},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(20)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3147,
                                                                                                                                 "dst_id": 3152}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 528,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 528,
                                                                                                                           "snippet": {"text": "\tif (rcv_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘rcv_total == 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 20},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(21)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3147,
                                                                                                                                 "dst_id": 3152}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 531,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 46},
                                                                                                         "contextRegion": {"startLine": 531,
                                                                                                                           "snippet": {"text": "\tprintf(\"\\t Packets per recv/send:\\n\");\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 21},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(22)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3158,
                                                                                                                                 "dst_id": 3200}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 532,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 532,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 22},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(23)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3158,
                                                                                                                                 "dst_id": 3200}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 546,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 20},
                                                                                                         "contextRegion": {"startLine": 546,
                                                                                                                           "snippet": {"text": "\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 23},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(24)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 546,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 20},
                                                                                                         "contextRegion": {"startLine": 546,
                                                                                                                           "snippet": {"text": "\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "second ‘free’ here; first ‘free’ was at [(17)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/16)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 24}]}]}]},
                       {"ruleId": "-Wanalyzer-double-free",
                        "taxa": [{"id": "415",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 3650},
                                       "gcc/analyzer/saved_diagnostic/var": "rstat_56",
                                       "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                       "gcc/analyzer/saved_diagnostic/state": "freed",
                                       "gcc/analyzer/saved_diagnostic/idx": 31,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "malloc",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 2235},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "rstat_56",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "&HEAP_ALLOCATED_REGION(2281)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "freed",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 16,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "double_free"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "double_free"},
                        "level": "warning",
                        "message": {"text": "double-‘free’ of ‘rstat’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 547,
                                                                       "startColumn": 9,
                                                                       "endColumn": 20},
                                                            "contextRegion": {"startLine": 547,
                                                                              "snippet": {"text": "\tfree(rstat);\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "show_buckets"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 550,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 550,
                                                                                                                           "snippet": {"text": "static void __show_stats(struct conn *c)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "entry to ‘__show_stats’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 569,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 569,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 181,
                                                                                                                                 "dst_id": 182}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 570,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 36},
                                                                                                         "contextRegion": {"startLine": 570,
                                                                                                                           "snippet": {"text": "\t\tqps += c->cd[i].rcv + c->cd[i].snd;\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 572,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 572,
                                                                                                                           "snippet": {"text": "\tif (!qps)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘qps != 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 190,
                                                                                                                                 "dst_id": 192}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 575,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 575,
                                                                                                                           "snippet": {"text": "\tif (msec)\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 582,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 26},
                                                                                                         "contextRegion": {"startLine": 582,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i < 2; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘i != 2’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 206,
                                                                                                                                 "dst_id": 207}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 583,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 31},
                                                                                                         "contextRegion": {"startLine": 583,
                                                                                                                           "snippet": {"text": "\t\tcd = &c->cd[i];\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "call",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 241,
                                                                                                                                 "dst_id": 242}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 600,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 600,
                                                                                                                           "snippet": {"text": "\t\tshow_buckets(cd);\n"}}},
                                                                                    "logicalLocations": [{"index": 1,
                                                                                                          "fullyQualifiedName": "__show_stats.part.0"}],
                                                                                    "message": {"text": "calling ‘show_buckets’ from ‘__show_stats’"}},
                                                                       "kinds": ["call",
                                                                                 "function"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "function_entry"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 500,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 25},
                                                                                                         "contextRegion": {"startLine": 500,
                                                                                                                           "snippet": {"text": "static void show_buckets(struct conn_dir *cd)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "entry to ‘show_buckets’"}},
                                                                       "kinds": ["enter",
                                                                                 "function"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 506,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 506,
                                                                                                                           "snippet": {"text": "\tif (!cd->rcv_bucket || !cd->snd_bucket)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_consolidated_cfg_edges"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 24,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 13},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(14)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 509,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 64},
                                                                                                         "contextRegion": {"startLine": 509,
                                                                                                                           "snippet": {"text": "\trstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "allocated here"}},
                                                                       "kinds": ["acquire",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 14},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(15)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3135,
                                                                                                                                 "dst_id": 3136}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 522,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 522,
                                                                                                                           "snippet": {"text": "\tif (!snd_total && !rcv_total) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 15},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(16)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3135,
                                                                                                                                 "dst_id": 3136}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 523,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 523,
                                                                                                                           "snippet": {"text": "\t\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 16},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(17)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 524,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 524,
                                                                                                                           "snippet": {"text": "\t\tfree(rstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "first ‘free’ here"}},
                                                                       "kinds": ["release",
                                                                                 "memory"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 17},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(18)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3147,
                                                                                                                                 "dst_id": 3152}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 528,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 528,
                                                                                                                           "snippet": {"text": "\tif (rcv_total)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘rcv_total == 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 18},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(19)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3147,
                                                                                                                                 "dst_id": 3152}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 531,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 46},
                                                                                                         "contextRegion": {"startLine": 531,
                                                                                                                           "snippet": {"text": "\tprintf(\"\\t Packets per recv/send:\\n\");\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 19},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(20)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3158,
                                                                                                                                 "dst_id": 3200}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 532,
                                                                                                                    "startColumn": 21,
                                                                                                                    "endColumn": 33},
                                                                                                         "contextRegion": {"startLine": 532,
                                                                                                                           "snippet": {"text": "\tfor (i = 0; i <= nr_bufs; i++) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 20},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(21)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 3158,
                                                                                                                                 "dst_id": 3200}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 546,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 20},
                                                                                                         "contextRegion": {"startLine": 546,
                                                                                                                           "snippet": {"text": "\tfree(sstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 21},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(22)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "proxy.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 547,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 20},
                                                                                                         "contextRegion": {"startLine": 547,
                                                                                                                           "snippet": {"text": "\tfree(rstat);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "show_buckets"}],
                                                                                    "message": {"text": "second ‘free’ here; first ‘free’ was at [(17)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/16)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 2,
                                                                       "executionOrder": 22}]}]}]}],
           "logicalLocations": [{"name": "show_buckets",
                                 "fullyQualifiedName": "show_buckets",
                                 "decoratedName": "show_buckets",
                                 "kind": "function",
                                 "index": 0},
                                {"name": "__show_stats.part.0",
                                 "fullyQualifiedName": "__show_stats.part.0",
                                 "decoratedName": "__show_stats.part.0",
                                 "kind": "function",
                                 "index": 1}]}]}
