fuzz_init:
   25|  6.85k|void fuzz_init(const uint8_t *data, size_t size) {
   26|  6.85k|    global_fuzz_data = (uint8_t *)data;
   27|  6.85k|    global_size = size;
   28|       |    
   29|  6.85k|    callback1 = NULL;
   30|  6.85k|    callback2 = NULL;
   31|  6.85k|    callback3 = NULL;
   32|       |    callback4 = NULL;
   33|  6.85k|}
create_callback_file:
   36|  5.27k|void create_callback_file(const char *filename) {
   37|  5.27k|  fprintf(stderr, "create_callback_file: Creating file %s\n", filename);
   38|  5.27k|  FILE *fp = fopen(filename, "wb");
   39|  5.27k|  if (!fp) {
  ------------------
  |  Branch (39:7): [True: 511, False: 4.76k]
  ------------------
   40|    511|    return;
   41|    511|  }
   42|  4.76k|  fwrite(global_fuzz_data, global_size, 1, fp);
   43|  4.76k|  fclose(fp);
   44|       |
   45|  4.76k|  if (callback1 == NULL) {
  ------------------
  |  Branch (45:7): [True: 2.08k, False: 2.67k]
  ------------------
   46|  2.08k|    callback1 = strdup(filename);
   47|  2.67k|  } else if (callback2 == NULL) {
  ------------------
  |  Branch (47:14): [True: 1.24k, False: 1.42k]
  ------------------
   48|  1.24k|    callback2 = strdup(filename);
   49|  1.42k|  } else if (callback3 == NULL) {
  ------------------
  |  Branch (49:14): [True: 792, False: 632]
  ------------------
   50|    792|    callback3 = strdup(filename);
   51|    792|  } else if (callback4 == NULL) {
  ------------------
  |  Branch (51:14): [True: 226, False: 406]
  ------------------
   52|    226|    callback4 = strdup(filename);
   53|    406|  } else {
   54|       |    fprintf(stderr, "create_callback_file: Too many callbacks created, ignoring %s\n", filename);
   55|    406|  }
   56|  4.76k|}
fuzz_cleanup:
   62|  6.85k|void fuzz_cleanup() {
   63|  6.85k|  if (callback1) {
  ------------------
  |  Branch (63:7): [True: 2.08k, False: 4.76k]
  ------------------
   64|  2.08k| unlink(callback1);    
   65|  2.08k|    free(callback1);
   66|       |   
   67|  2.08k|    callback1 = NULL;
   68|  2.08k|  }
   69|  6.85k|  if (callback2) {
  ------------------
  |  Branch (69:7): [True: 1.24k, False: 5.60k]
  ------------------
   70|  1.24k| unlink(callback2);    
   71|  1.24k|    free(callback2);
   72|  1.24k|    callback2 = NULL;
   73|  1.24k|  }
   74|  6.85k|  if (callback3) {
  ------------------
  |  Branch (74:7): [True: 792, False: 6.06k]
  ------------------
   75|    792| unlink(callback3);      
   76|    792|    free(callback3);
   77|    792|    callback3 = NULL;
   78|    792|  }
   79|  6.85k|  if (callback4) {
  ------------------
  |  Branch (79:7): [True: 226, False: 6.62k]
  ------------------
   80|    226|     unlink(callback4);
   81|    226|    free(callback4);
   82|       |    callback4 = NULL;
   83|    226|  }
   84|  6.85k|}

LLVMFuzzerInitialize:
   22|      2|int LLVMFuzzerInitialize(int *argc, char ***argv) {
   23|      2|  setenv("HOME", "/tmp", 1);
   24|      2|  system("mkdir -p $HOME/.local/share/vulkan/implicit_layer.d");
   25|      2|  system("mkdir -p $HOME/.local/share/vulkan/loader_settings.d");
   26|      2|  system("mkdir -p $HOME/.local/share/vulkan/icd.d");
   27|      2|  return 0;
   28|      2|}
create_config_file:
   33|  20.5k|int create_config_file(const char* config_path, const char* config_filename, const uint8_t* data, size_t size) {
   34|  20.5k|  char filename[512];
   35|  20.5k|  char path[256];
   36|       |  // char command[256];
   37|       |
   38|  20.5k|  sprintf(path, "%s/%s", getenv("HOME"), config_path);
   39|       |  //sprintf(command, "mkdir -p %s", path);
   40|       |
   41|       |  //system(command);
   42|       |
   43|  20.5k|  sprintf(filename, "%s/%s", path, config_filename);
   44|       |
   45|  20.5k|  FILE *fp = fopen(filename, "wb");
   46|  20.5k|  if (!fp) {
  ------------------
  |  Branch (46:7): [True: 0, False: 20.5k]
  ------------------
   47|      0|    return 1;
   48|      0|  }
   49|  20.5k|  fwrite(data, size, 1, fp);
   50|  20.5k|  fclose(fp);
   51|       |
   52|  20.5k|  return 0;
   53|  20.5k|}
remove_config_file:
   58|  20.5k|void remove_config_file(const char* config_path, const char* config_filename) {
   59|  20.5k|  char filename[512];
   60|  20.5k|  sprintf(filename, "%s/%s/%s", getenv("HOME"), config_path, config_filename);
   61|  20.5k|  unlink(filename);
   62|  20.5k|}
LLVMFuzzerTestOneInput:
   67|  6.88k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   68|  6.88k|  if (size < 3*sizeof(size_t)) {
  ------------------
  |  Branch (68:7): [True: 8, False: 6.87k]
  ------------------
   69|      8|    return 0;
   70|      8|  }
   71|       |
   72|       |  // Split the loaders into two different parts so the files
   73|       |  // are independently seeded with fuzz data.
   74|  6.87k|  size_t first_size = (*(size_t*)data) % 40000;
   75|  6.87k|  size_t second_size = (*(size_t*)(data + sizeof(size_t))) % 40000;
   76|  6.87k|  size_t third_size = (*(size_t*)(data + 2*sizeof(size_t))) % 40000;
   77|       |
   78|  6.87k|  data += 3*sizeof(size_t); // Move past the first two integers
   79|  6.87k|  size -= 3*sizeof(size_t); // Adjust size to account for the first two integers
   80|  6.87k|  size_t total_size_needed = first_size + second_size + third_size;
   81|  6.87k|  if (size <= total_size_needed) {
  ------------------
  |  Branch (81:7): [True: 18, False: 6.85k]
  ------------------
   82|     18|    return 0;
   83|     18|  }
   84|  6.85k|  int result = create_config_file(".local/share/vulkan/implicit_layer.d", "complex_layer.json", data, first_size);
   85|  6.85k|  if (result) {
  ------------------
  |  Branch (85:7): [True: 0, False: 6.85k]
  ------------------
   86|      0|    return 0;
   87|      0|  }
   88|       |
   89|  6.85k|  data += first_size;
   90|  6.85k|  size -= first_size;
   91|  6.85k|  result = create_config_file(".local/share/vulkan/loader_settings.d", "vk_loader_settings.json", data, second_size);
   92|  6.85k|  if (result) {
  ------------------
  |  Branch (92:7): [True: 0, False: 6.85k]
  ------------------
   93|      0|    return 0;
   94|      0|  }
   95|       |
   96|  6.85k|  data += second_size;
   97|  6.85k|  size -= second_size;
   98|  6.85k|  result = create_config_file(".local/share/vulkan/loader_settings.d", "icd_test.json", data, third_size);
   99|  6.85k|  if (result) {
  ------------------
  |  Branch (99:7): [True: 0, False: 6.85k]
  ------------------
  100|      0|    return 0;
  101|      0|  }
  102|  6.85k|  data += third_size;
  103|  6.85k|  size -= third_size;
  104|       |
  105|  6.85k|  fuzz_init(data, size);
  106|       |
  107|  6.85k|  setenv("VK_LOADER_LAYERS_ENABLE", "all", 1);
  108|       |
  109|       |
  110|  6.85k|  VkInstance inst = {0};
  111|  6.85k|  char *instance_layers[] = {
  112|  6.85k|    "VK_LAYER_KHRONOS_validation",
  113|  6.85k|    "VK_LAYER_test_layer_1",
  114|  6.85k|    "VK_LAYER_test_layer_2"
  115|  6.85k|  };
  116|  6.85k|  const VkApplicationInfo app = {
  117|  6.85k|      .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
  118|  6.85k|      .pNext = NULL,
  119|  6.85k|      .pApplicationName = "TEST_APP",
  120|  6.85k|      .applicationVersion = 0,
  121|  6.85k|      .pEngineName = "TEST_ENGINE",
  122|  6.85k|      .engineVersion = 0,
  123|  6.85k|      .apiVersion = VK_API_VERSION_1_0,
  ------------------
  |  |   92|  6.85k|#define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0
  |  |  ------------------
  |  |  |  |   63|  6.85k|    ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
  |  |  ------------------
  ------------------
  124|  6.85k|  };
  125|  6.85k|  VkInstanceCreateInfo inst_info = {
  126|  6.85k|      .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
  127|  6.85k|      .pNext = NULL,
  128|  6.85k|      .pApplicationInfo = &app,
  129|  6.85k|      .enabledLayerCount = 1,
  130|  6.85k|      .ppEnabledLayerNames = (const char *const *)instance_layers,
  131|  6.85k|      .enabledExtensionCount = 0,
  132|  6.85k|      .ppEnabledExtensionNames = NULL,
  133|  6.85k|  };
  134|  6.85k|  VkResult err = vkCreateInstance(&inst_info, NULL, &inst);
  135|  6.85k|  if (err != VK_SUCCESS) {
  ------------------
  |  Branch (135:7): [True: 6.85k, False: 0]
  ------------------
  136|  6.85k|    goto out;
  137|  6.85k|  }
  138|      0|  else {
  139|       |
  140|      0|  }
  141|       |
  142|      0|  vkDestroyInstance(inst, NULL);
  143|       |
  144|  6.85k|out:
  145|       |  // Clean up config files
  146|  6.85k|  remove_config_file(".local/share/vulkan/implicit_layer.d", "complex_layer.json");
  147|  6.85k|  remove_config_file(".local/share/vulkan/loader_settings.d", "vk_loader_settings.json");
  148|  6.85k|  remove_config_file(".local/share/vulkan/icd.d", "icd_test.json");
  149|       |
  150|       |
  151|  6.85k|  fuzz_cleanup();
  152|       |
  153|  6.85k|  return 0;
  154|      0|}

loader_alloc:
   34|      5|void *loader_alloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) {
   35|      5|    void *pMemory = NULL;
   36|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   37|       |    {
   38|       |#else
   39|      5|    if (pAllocator && pAllocator->pfnAllocation) {
  ------------------
  |  Branch (39:9): [True: 5, False: 0]
  |  Branch (39:23): [True: 0, False: 5]
  ------------------
   40|       |        // These are internal structures, so it's best to align everything to
   41|       |        // the largest unit size which is the size of a uint64_t.
   42|      0|        pMemory = pAllocator->pfnAllocation(pAllocator->pUserData, size, sizeof(uint64_t), allocation_scope);
   43|      5|    } else {
   44|      5|#endif
   45|      5|        pMemory = malloc(size);
   46|      5|    }
   47|       |
   48|      5|    return pMemory;
   49|      5|}
loader_calloc:
   51|  9.52M|void *loader_calloc(const VkAllocationCallbacks *pAllocator, size_t size, VkSystemAllocationScope allocation_scope) {
   52|  9.52M|    void *pMemory = NULL;
   53|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   54|       |    {
   55|       |#else
   56|  9.52M|    if (pAllocator && pAllocator->pfnAllocation) {
  ------------------
  |  Branch (56:9): [True: 9.51M, False: 6.85k]
  |  Branch (56:23): [True: 0, False: 9.51M]
  ------------------
   57|       |        // These are internal structures, so it's best to align everything to
   58|       |        // the largest unit size which is the size of a uint64_t.
   59|      0|        pMemory = pAllocator->pfnAllocation(pAllocator->pUserData, size, sizeof(uint64_t), allocation_scope);
   60|      0|        if (pMemory) {
  ------------------
  |  Branch (60:13): [True: 0, False: 0]
  ------------------
   61|      0|            memset(pMemory, 0, size);
   62|      0|        }
   63|  9.52M|    } else {
   64|  9.52M|#endif
   65|  9.52M|        pMemory = calloc(1, size);
   66|  9.52M|    }
   67|       |
   68|  9.52M|    return pMemory;
   69|  9.52M|}
loader_free:
   71|  13.8M|void loader_free(const VkAllocationCallbacks *pAllocator, void *pMemory) {
   72|  13.8M|    if (pMemory != NULL) {
  ------------------
  |  Branch (72:9): [True: 9.52M, False: 4.31M]
  ------------------
   73|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   74|       |        {
   75|       |#else
   76|  9.52M|        if (pAllocator && pAllocator->pfnFree) {
  ------------------
  |  Branch (76:13): [True: 9.52M, False: 0]
  |  Branch (76:27): [True: 0, False: 9.52M]
  ------------------
   77|      0|            pAllocator->pfnFree(pAllocator->pUserData, pMemory);
   78|  9.52M|        } else {
   79|  9.52M|#endif
   80|  9.52M|            free(pMemory);
   81|  9.52M|        }
   82|  9.52M|    }
   83|  13.8M|}
loader_realloc:
   86|   266k|                     VkSystemAllocationScope allocation_scope) {
   87|   266k|    void *pNewMem = NULL;
   88|   266k|    if (pMemory == NULL || orig_size == 0) {
  ------------------
  |  Branch (88:9): [True: 0, False: 266k]
  |  Branch (88:28): [True: 0, False: 266k]
  ------------------
   89|      0|        pNewMem = loader_alloc(pAllocator, size, allocation_scope);
   90|   266k|    } else if (size == 0) {
  ------------------
  |  Branch (90:16): [True: 0, False: 266k]
  ------------------
   91|      0|        loader_free(pAllocator, pMemory);
   92|       |#if (DEBUG_DISABLE_APP_ALLOCATORS == 1)
   93|       |#else
   94|   266k|    } else if (pAllocator && pAllocator->pfnReallocation) {
  ------------------
  |  Branch (94:16): [True: 266k, False: 0]
  |  Branch (94:30): [True: 0, False: 266k]
  ------------------
   95|       |        // These are internal structures, so it's best to align everything to
   96|       |        // the largest unit size which is the size of a uint64_t.
   97|      0|        pNewMem = pAllocator->pfnReallocation(pAllocator->pUserData, pMemory, size, sizeof(uint64_t), allocation_scope);
   98|      0|#endif
   99|   266k|    } else {
  100|   266k|        pNewMem = realloc(pMemory, size);
  101|       |        // Clear out the newly allocated memory. On failure realloc returns NULL and leaves the original block valid, so
  102|       |        // only write through pNewMem once we know it points at the resized allocation.
  103|   266k|        if (NULL != pNewMem && size > orig_size) {
  ------------------
  |  Branch (103:13): [True: 266k, False: 0]
  |  Branch (103:32): [True: 4.05k, False: 262k]
  ------------------
  104|  4.05k|            memset((uint8_t *)pNewMem + orig_size, 0, size - orig_size);
  105|  4.05k|        }
  106|   266k|    }
  107|   266k|    return pNewMem;
  108|   266k|}
loader_instance_heap_alloc:
  110|      5|void *loader_instance_heap_alloc(const struct loader_instance *inst, size_t size, VkSystemAllocationScope allocation_scope) {
  111|      5|    return loader_alloc(inst ? &inst->alloc_callbacks : NULL, size, allocation_scope);
  ------------------
  |  Branch (111:25): [True: 5, False: 0]
  ------------------
  112|      5|}
loader_instance_heap_calloc:
  114|   617k|void *loader_instance_heap_calloc(const struct loader_instance *inst, size_t size, VkSystemAllocationScope allocation_scope) {
  115|   617k|    return loader_calloc(inst ? &inst->alloc_callbacks : NULL, size, allocation_scope);
  ------------------
  |  Branch (115:26): [True: 617k, False: 0]
  ------------------
  116|   617k|}
loader_instance_heap_free:
  118|  5.20M|void loader_instance_heap_free(const struct loader_instance *inst, void *pMemory) {
  119|  5.20M|    loader_free(inst ? &inst->alloc_callbacks : NULL, pMemory);
  ------------------
  |  Branch (119:17): [True: 5.20M, False: 2]
  ------------------
  120|  5.20M|}
loader_instance_heap_realloc:
  122|  1.36k|                                   VkSystemAllocationScope allocation_scope) {
  123|  1.36k|    return loader_realloc(inst ? &inst->alloc_callbacks : NULL, pMemory, orig_size, size, allocation_scope);
  ------------------
  |  Branch (123:27): [True: 1.36k, False: 0]
  ------------------
  124|  1.36k|}

loader_cJSON_GetStringValue:
   98|   756k|CJSON_PUBLIC(char *) loader_cJSON_GetStringValue(const cJSON *const item) {
   99|   756k|    if (!loader_cJSON_IsString(item)) {
  ------------------
  |  Branch (99:9): [True: 182k, False: 574k]
  ------------------
  100|   182k|        return NULL;
  101|   182k|    }
  102|       |
  103|   574k|    return item->valuestring;
  104|   756k|}
loader_cJSON_Delete:
  151|   690k|TEST_FUNCTION_EXPORT CJSON_PUBLIC(void) loader_cJSON_Delete(cJSON *item) {
  152|   690k|    cJSON *next = NULL;
  153|  4.36M|    while (item != NULL) {
  ------------------
  |  Branch (153:12): [True: 3.67M, False: 690k]
  ------------------
  154|  3.67M|        next = item->next;
  155|  3.67M|        if (!(item->type & cJSON_IsReference) && (item->child != NULL)) {
  ------------------
  |  |  106|  3.67M|#define cJSON_IsReference 256
  ------------------
  |  Branch (155:13): [True: 3.67M, False: 0]
  |  Branch (155:50): [True: 560k, False: 3.11M]
  ------------------
  156|   560k|            loader_cJSON_Delete(item->child);
  157|   560k|        }
  158|  3.67M|        if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) {
  ------------------
  |  |  106|  3.67M|#define cJSON_IsReference 256
  ------------------
  |  Branch (158:13): [True: 3.67M, False: 0]
  |  Branch (158:50): [True: 2.51M, False: 1.16M]
  ------------------
  159|  2.51M|            loader_free(item->pAllocator, item->valuestring);
  160|  2.51M|            item->valuestring = NULL;
  161|  2.51M|        }
  162|  3.67M|        if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) {
  ------------------
  |  |  107|  3.67M|#define cJSON_StringIsConst 512
  ------------------
  |  Branch (162:13): [True: 3.67M, False: 0]
  |  Branch (162:52): [True: 2.44M, False: 1.23M]
  ------------------
  163|  2.44M|            loader_free(item->pAllocator, item->string);
  164|       |            item->string = NULL;
  165|  2.44M|        }
  166|  3.67M|        loader_free(item->pAllocator, item);
  167|  3.67M|        item = next;
  168|  3.67M|    }
  169|   690k|}
loader_cJSON_ParseWithLengthOpts:
  824|  23.5k|                                 const char **return_parse_end, cJSON_bool require_null_terminated, bool *out_of_memory) {
  825|  23.5k|    parse_buffer buffer = {0, 0, 0, 0, 0};
  826|  23.5k|    cJSON *item = NULL;
  827|       |
  828|       |    /* reset error position */
  829|       |    // global_error.json = NULL;
  830|       |    // global_error.position = 0;
  831|       |
  832|  23.5k|    if (value == NULL || 0 == buffer_length) {
  ------------------
  |  Branch (832:9): [True: 0, False: 23.5k]
  |  Branch (832:26): [True: 0, False: 23.5k]
  ------------------
  833|      0|        goto fail;
  834|      0|    }
  835|       |
  836|  23.5k|    buffer.content = (const unsigned char *)value;
  837|  23.5k|    buffer.length = buffer_length;
  838|  23.5k|    buffer.offset = 0;
  839|  23.5k|    buffer.pAllocator = pAllocator;
  840|       |
  841|  23.5k|    item = cJSON_New_Item(pAllocator);
  842|  23.5k|    if (item == NULL) /* memory fail */
  ------------------
  |  Branch (842:9): [True: 0, False: 23.5k]
  ------------------
  843|      0|    {
  844|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  845|      0|        goto fail;
  846|      0|    }
  847|       |
  848|  23.5k|    if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer)), out_of_memory)) {
  ------------------
  |  Branch (848:9): [True: 9.04k, False: 14.5k]
  ------------------
  849|       |        /* parse failure. ep is set. */
  850|  9.04k|        goto fail;
  851|  9.04k|    }
  852|       |
  853|       |    /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
  854|  14.5k|    if (require_null_terminated) {
  ------------------
  |  Branch (854:9): [True: 0, False: 14.5k]
  ------------------
  855|      0|        buffer_skip_whitespace(&buffer);
  856|      0|        if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0') {
  ------------------
  |  |  195|      0|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (856:13): [True: 0, False: 0]
  |  Branch (856:49): [True: 0, False: 0]
  ------------------
  857|      0|            goto fail;
  858|      0|        }
  859|      0|    }
  860|  14.5k|    if (return_parse_end) {
  ------------------
  |  Branch (860:9): [True: 0, False: 14.5k]
  ------------------
  861|      0|        *return_parse_end = (const char *)buffer_at_offset(&buffer);
  ------------------
  |  |  195|      0|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  862|      0|    }
  863|       |
  864|  14.5k|    return item;
  865|       |
  866|  9.04k|fail:
  867|  9.04k|    if (item != NULL) {
  ------------------
  |  Branch (867:9): [True: 9.04k, False: 0]
  ------------------
  868|  9.04k|        loader_cJSON_Delete(item);
  869|  9.04k|    }
  870|       |
  871|  9.04k|    if (value != NULL) {
  ------------------
  |  Branch (871:9): [True: 9.04k, False: 0]
  ------------------
  872|  9.04k|        error local_error;
  873|  9.04k|        local_error.json = (const unsigned char *)value;
  874|  9.04k|        local_error.position = 0;
  875|       |
  876|  9.04k|        if (buffer.offset < buffer.length) {
  ------------------
  |  Branch (876:13): [True: 8.47k, False: 570]
  ------------------
  877|  8.47k|            local_error.position = buffer.offset;
  878|  8.47k|        } else if (buffer.length > 0) {
  ------------------
  |  Branch (878:20): [True: 570, False: 0]
  ------------------
  879|    570|            local_error.position = buffer.length - 1;
  880|    570|        }
  881|       |
  882|  9.04k|        if (return_parse_end != NULL) {
  ------------------
  |  Branch (882:13): [True: 0, False: 9.04k]
  ------------------
  883|      0|            *return_parse_end = (const char *)local_error.json + local_error.position;
  884|      0|        }
  885|       |
  886|       |        // global_error = local_error;
  887|  9.04k|    }
  888|       |
  889|       |    return NULL;
  890|  14.5k|}
loader_cJSON_ParseWithLength:
  899|  23.5k|                             bool *out_of_memory) {
  900|  23.5k|    return loader_cJSON_ParseWithLengthOpts(pAllocator, value, buffer_length, 0, 0, out_of_memory);
  901|  23.5k|}
loader_cJSON_Print:
  953|   262k|TEST_FUNCTION_EXPORT CJSON_PUBLIC(char *) loader_cJSON_Print(const cJSON *item, bool *out_of_memory) {
  954|   262k|    return (char *)print(item, true, out_of_memory);
  ------------------
  |  |   67|   262k|#define true ((cJSON_bool)1)
  ------------------
  955|   262k|}
loader_cJSON_PrintPreallocated:
  990|   414k|    loader_cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format) {
  991|   414k|    printbuffer p = {0, 0, 0, 0, 0, 0, 0};
  992|       |
  993|   414k|    if ((length < 0) || (buffer == NULL)) {
  ------------------
  |  Branch (993:9): [True: 0, False: 414k]
  |  Branch (993:25): [True: 0, False: 414k]
  ------------------
  994|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  995|      0|    }
  996|       |
  997|   414k|    p.buffer = (unsigned char *)buffer;
  998|   414k|    p.length = (size_t)length;
  999|   414k|    p.offset = 0;
 1000|   414k|    p.noalloc = true;
  ------------------
  |  |   67|   414k|#define true ((cJSON_bool)1)
  ------------------
 1001|   414k|    p.format = format;
 1002|   414k|    p.pAllocator = item->pAllocator;
 1003|   414k|    bool out_of_memory = false;
  ------------------
  |  |   72|   414k|#define false ((cJSON_bool)0)
  ------------------
 1004|   414k|    return print_value(item, &p, &out_of_memory);
 1005|   414k|}
loader_cJSON_GetArraySize:
 1457|  72.0k|CJSON_PUBLIC(int) loader_cJSON_GetArraySize(const cJSON *array) {
 1458|  72.0k|    cJSON *child = NULL;
 1459|  72.0k|    size_t size = 0;
 1460|       |
 1461|  72.0k|    if (array == NULL) {
  ------------------
  |  Branch (1461:9): [True: 0, False: 72.0k]
  ------------------
 1462|      0|        return 0;
 1463|      0|    }
 1464|       |
 1465|  72.0k|    child = array->child;
 1466|       |
 1467|   226k|    while (child != NULL) {
  ------------------
  |  Branch (1467:12): [True: 154k, False: 72.0k]
  ------------------
 1468|   154k|        size++;
 1469|   154k|        child = child->next;
 1470|   154k|    }
 1471|       |
 1472|       |    /* FIXME: Can overflow here. Cannot be fixed without breaking the API */
 1473|       |
 1474|  72.0k|    return (int)size;
 1475|  72.0k|}
loader_cJSON_GetObjectItem:
 1527|  2.46M|CJSON_PUBLIC(cJSON *) loader_cJSON_GetObjectItem(const cJSON *const object, const char *const string) {
 1528|  2.46M|    return get_object_item(object, string, false);
  ------------------
  |  |   72|  2.46M|#define false ((cJSON_bool)0)
  ------------------
 1529|  2.46M|}
loader_cJSON_IsString:
 1670|   756k|CJSON_PUBLIC(cJSON_bool) loader_cJSON_IsString(const cJSON *const item) {
 1671|   756k|    if (item == NULL) {
  ------------------
  |  Branch (1671:9): [True: 181k, False: 574k]
  ------------------
 1672|   181k|        return false;
  ------------------
  |  |   72|   181k|#define false ((cJSON_bool)0)
  ------------------
 1673|   181k|    }
 1674|       |
 1675|   574k|    return (item->type & 0xFF) == cJSON_String;
  ------------------
  |  |  101|   574k|#define cJSON_String (1 << 4)
  ------------------
 1676|   756k|}
cJSON.c:cJSON_New_Item:
  142|  3.67M|static cJSON *cJSON_New_Item(const VkAllocationCallbacks *pAllocator) {
  143|  3.67M|    cJSON *node = (cJSON *)loader_calloc(pAllocator, sizeof(cJSON), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  144|  3.67M|    if (NULL != node) {
  ------------------
  |  Branch (144:9): [True: 3.67M, False: 0]
  ------------------
  145|  3.67M|        node->pAllocator = pAllocator;
  146|  3.67M|    }
  147|  3.67M|    return node;
  148|  3.67M|}
cJSON.c:buffer_skip_whitespace:
  772|  12.8M|static parse_buffer *buffer_skip_whitespace(parse_buffer *const buffer) {
  773|  12.8M|    if ((buffer == NULL) || (buffer->content == NULL)) {
  ------------------
  |  Branch (773:9): [True: 0, False: 12.8M]
  |  Branch (773:29): [True: 0, False: 12.8M]
  ------------------
  774|      0|        return NULL;
  775|      0|    }
  776|       |
  777|  12.8M|    if (cannot_access_at_index(buffer, 0)) {
  ------------------
  |  |  193|  12.8M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  12.8M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 12.8M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 12.8M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|      0|        return buffer;
  779|      0|    }
  780|       |
  781|  33.0M|    while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) {
  ------------------
  |  |  192|  66.1M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 33.0M, False: 0]
  |  |  |  Branch (192:65): [True: 33.0M, False: 4.79k]
  |  |  ------------------
  ------------------
                  while (can_access_at_index(buffer, 0) && (buffer_at_offset(buffer)[0] <= 32)) {
  ------------------
  |  |  195|  33.0M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (781:46): [True: 20.2M, False: 12.8M]
  ------------------
  782|  20.2M|        buffer->offset++;
  783|  20.2M|    }
  784|       |
  785|  12.8M|    if (buffer->offset == buffer->length) {
  ------------------
  |  Branch (785:9): [True: 4.79k, False: 12.8M]
  ------------------
  786|  4.79k|        buffer->offset--;
  787|  4.79k|    }
  788|       |
  789|  12.8M|    return buffer;
  790|  12.8M|}
cJSON.c:skip_utf8_bom:
  793|  23.5k|static parse_buffer *skip_utf8_bom(parse_buffer *const buffer) {
  794|  23.5k|    if ((buffer == NULL) || (buffer->content == NULL) || (buffer->offset != 0)) {
  ------------------
  |  Branch (794:9): [True: 0, False: 23.5k]
  |  Branch (794:29): [True: 0, False: 23.5k]
  |  Branch (794:58): [True: 0, False: 23.5k]
  ------------------
  795|      0|        return NULL;
  796|      0|    }
  797|       |
  798|  23.5k|    if (can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) {
  ------------------
  |  |  192|  47.1k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 23.5k, False: 0]
  |  |  |  Branch (192:65): [True: 16.1k, False: 7.41k]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(buffer, 4) && (strncmp((const char *)buffer_at_offset(buffer), "\xEF\xBB\xBF", 3) == 0)) {
  ------------------
  |  |  195|  16.1k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (798:43): [True: 117, False: 16.0k]
  ------------------
  799|    117|        buffer->offset += 3;
  800|    117|    }
  801|       |
  802|  23.5k|    return buffer;
  803|  23.5k|}
cJSON.c:print:
  905|   262k|static unsigned char *print(const cJSON *const item, cJSON_bool format, bool *out_of_memory) {
  906|   262k|    static const size_t default_buffer_size = 256;
  907|   262k|    printbuffer buffer[1];
  908|   262k|    unsigned char *printed = NULL;
  909|       |
  910|   262k|    memset(buffer, 0, sizeof(buffer));
  911|       |
  912|       |    /* create buffer */
  913|   262k|    buffer->buffer = (unsigned char *)loader_calloc(item->pAllocator, default_buffer_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  914|   262k|    buffer->length = default_buffer_size;
  915|   262k|    buffer->format = format;
  916|   262k|    buffer->pAllocator = item->pAllocator;
  917|   262k|    if (buffer->buffer == NULL) {
  ------------------
  |  Branch (917:9): [True: 0, False: 262k]
  ------------------
  918|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  919|      0|        goto fail;
  920|      0|    }
  921|       |
  922|       |    /* print the value */
  923|   262k|    if (!print_value(item, buffer, out_of_memory)) {
  ------------------
  |  Branch (923:9): [True: 0, False: 262k]
  ------------------
  924|      0|        goto fail;
  925|      0|    }
  926|   262k|    update_offset(buffer);
  927|       |
  928|   262k|    printed = (unsigned char *)loader_realloc(item->pAllocator, buffer->buffer, buffer->length, buffer->offset + 1,
  929|   262k|                                              VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  930|   262k|    if (printed == NULL) {
  ------------------
  |  Branch (930:9): [True: 0, False: 262k]
  ------------------
  931|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  932|      0|        goto fail;
  933|      0|    }
  934|   262k|    buffer->buffer = NULL;
  935|       |
  936|   262k|    return printed;
  937|       |
  938|      0|fail:
  939|      0|    if (buffer->buffer != NULL) {
  ------------------
  |  Branch (939:9): [True: 0, False: 0]
  ------------------
  940|      0|        loader_free(item->pAllocator, buffer->buffer);
  941|      0|        buffer->buffer = NULL;
  942|      0|    }
  943|       |
  944|      0|    if (printed != NULL) {
  ------------------
  |  Branch (944:9): [True: 0, False: 0]
  ------------------
  945|      0|        loader_free(item->pAllocator, printed);
  946|      0|        printed = NULL;
  947|      0|    }
  948|       |
  949|       |    return NULL;
  950|   262k|}
cJSON.c:update_offset:
  331|   262k|static void update_offset(printbuffer *const buffer) {
  332|   262k|    const unsigned char *buffer_pointer = NULL;
  333|   262k|    if ((buffer == NULL) || (buffer->buffer == NULL)) {
  ------------------
  |  Branch (333:9): [True: 0, False: 262k]
  |  Branch (333:29): [True: 0, False: 262k]
  ------------------
  334|      0|        return;
  335|      0|    }
  336|   262k|    buffer_pointer = buffer->buffer + buffer->offset;
  337|       |
  338|   262k|    buffer->offset += strlen((const char *)buffer_pointer);
  339|   262k|}
cJSON.c:parse_value:
 1008|  3.67M|static cJSON_bool parse_value(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1009|  3.67M|    if ((input_buffer == NULL) || (input_buffer->content == NULL)) {
  ------------------
  |  Branch (1009:9): [True: 0, False: 3.67M]
  |  Branch (1009:35): [True: 0, False: 3.67M]
  ------------------
 1010|      0|        return false; /* no input */
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1011|      0|    }
 1012|       |
 1013|       |    /* parse the different types of values */
 1014|       |    /* null */
 1015|  3.67M|    if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) {
  ------------------
  |  |  190|  7.35M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 3.67M, False: 0]
  |  |  |  Branch (190:53): [True: 3.66M, False: 7.77k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "null", 4) == 0)) {
  ------------------
  |  |  195|  3.66M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1015:38): [True: 120, False: 3.66M]
  ------------------
 1016|    120|        item->type = cJSON_NULL;
  ------------------
  |  |   99|    120|#define cJSON_NULL (1 << 2)
  ------------------
 1017|    120|        input_buffer->offset += 4;
 1018|    120|        return true;
  ------------------
  |  |   67|    120|#define true ((cJSON_bool)1)
  ------------------
 1019|    120|    }
 1020|       |    /* false */
 1021|  3.67M|    if (can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) {
  ------------------
  |  |  190|  7.35M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 3.67M, False: 0]
  |  |  |  Branch (190:53): [True: 3.66M, False: 8.08k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 5) && (strncmp((const char *)buffer_at_offset(input_buffer), "false", 5) == 0)) {
  ------------------
  |  |  195|  3.66M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1021:38): [True: 706, False: 3.66M]
  ------------------
 1022|    706|        item->type = cJSON_False;
  ------------------
  |  |   97|    706|#define cJSON_False (1 << 0)
  ------------------
 1023|    706|        input_buffer->offset += 5;
 1024|    706|        return true;
  ------------------
  |  |   67|    706|#define true ((cJSON_bool)1)
  ------------------
 1025|    706|    }
 1026|       |    /* true */
 1027|  3.67M|    if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) {
  ------------------
  |  |  190|  7.35M|#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (190:33): [True: 3.67M, False: 0]
  |  |  |  Branch (190:53): [True: 3.66M, False: 7.77k]
  |  |  ------------------
  ------------------
                  if (can_read(input_buffer, 4) && (strncmp((const char *)buffer_at_offset(input_buffer), "true", 4) == 0)) {
  ------------------
  |  |  195|  3.66M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1027:38): [True: 22.6k, False: 3.64M]
  ------------------
 1028|  22.6k|        item->type = cJSON_True;
  ------------------
  |  |   98|  22.6k|#define cJSON_True (1 << 1)
  ------------------
 1029|  22.6k|        item->valueint = 1;
 1030|  22.6k|        input_buffer->offset += 4;
 1031|  22.6k|        return true;
  ------------------
  |  |   67|  22.6k|#define true ((cJSON_bool)1)
  ------------------
 1032|  22.6k|    }
 1033|       |    /* string */
 1034|  3.65M|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) {
  ------------------
  |  |  192|  7.30M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 3.65M, False: 0]
  |  |  |  Branch (192:65): [True: 3.65M, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '\"')) {
  ------------------
  |  |  195|  3.65M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1034:49): [True: 2.51M, False: 1.13M]
  ------------------
 1035|  2.51M|        return parse_string(item, input_buffer, out_of_memory);
 1036|  2.51M|    }
 1037|       |    /* number */
 1038|  1.13M|    if (can_access_at_index(input_buffer, 0) &&
  ------------------
  |  |  192|  2.27M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 1.13M, False: 0]
  |  |  |  Branch (192:65): [True: 1.13M, False: 0]
  |  |  ------------------
  ------------------
 1039|  1.13M|        ((buffer_at_offset(input_buffer)[0] == '-') ||
  ------------------
  |  |  195|  1.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1039:10): [True: 2.60k, False: 1.13M]
  ------------------
 1040|  1.13M|         ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
  ------------------
  |  |  195|  1.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
                       ((buffer_at_offset(input_buffer)[0] >= '0') && (buffer_at_offset(input_buffer)[0] <= '9')))) {
  ------------------
  |  |  195|  1.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1040:11): [True: 1.13M, False: 3.46k]
  |  Branch (1040:57): [True: 418k, False: 715k]
  ------------------
 1041|   420k|        return parse_number(item, input_buffer);
 1042|   420k|    }
 1043|       |    /* array */
 1044|   719k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) {
  ------------------
  |  |  192|  1.43M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 719k, False: 0]
  |  |  |  Branch (192:65): [True: 719k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '[')) {
  ------------------
  |  |  195|   719k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1044:49): [True: 253k, False: 465k]
  ------------------
 1045|   253k|        return parse_array(item, input_buffer, out_of_memory);
 1046|   253k|    }
 1047|       |    /* object */
 1048|   465k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) {
  ------------------
  |  |  192|   931k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 465k, False: 0]
  |  |  |  Branch (192:65): [True: 465k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '{')) {
  ------------------
  |  |  195|   465k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1048:49): [True: 458k, False: 6.83k]
  ------------------
 1049|   458k|        return parse_object(item, input_buffer, out_of_memory);
 1050|   458k|    }
 1051|       |
 1052|  6.83k|    return false;
  ------------------
  |  |   72|  6.83k|#define false ((cJSON_bool)0)
  ------------------
 1053|   465k|}
cJSON.c:parse_string:
  533|  4.95M|static cJSON_bool parse_string(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
  534|  4.95M|    const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1;
  ------------------
  |  |  195|  4.95M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  535|  4.95M|    const unsigned char *input_end = buffer_at_offset(input_buffer) + 1;
  ------------------
  |  |  195|  4.95M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  536|  4.95M|    unsigned char *output_pointer = NULL;
  537|  4.95M|    unsigned char *output = NULL;
  538|       |
  539|       |    /* not a string */
  540|  4.95M|    if (buffer_at_offset(input_buffer)[0] != '\"') {
  ------------------
  |  |  195|  4.95M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (540:9): [True: 661, False: 4.95M]
  ------------------
  541|    661|        goto fail;
  542|    661|    }
  543|       |
  544|  4.95M|    {
  545|       |        /* calculate approximate size of the output (overestimate) */
  546|  4.95M|        size_t allocation_length = 0;
  547|  4.95M|        size_t skipped_bytes = 0;
  548|   123M|        while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"')) {
  ------------------
  |  Branch (548:16): [True: 123M, False: 206]
  |  Branch (548:88): [True: 118M, False: 4.95M]
  ------------------
  549|       |            /* is escape sequence */
  550|   118M|            if (input_end[0] == '\\') {
  ------------------
  |  Branch (550:17): [True: 212k, False: 118M]
  ------------------
  551|   212k|                if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length) {
  ------------------
  |  Branch (551:21): [True: 0, False: 212k]
  ------------------
  552|       |                    /* prevent buffer overflow when last input character is a backslash */
  553|      0|                    goto fail;
  554|      0|                }
  555|   212k|                skipped_bytes++;
  556|   212k|                input_end++;
  557|   212k|            }
  558|   118M|            input_end++;
  559|   118M|        }
  560|  4.95M|        if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"')) {
  ------------------
  |  Branch (560:13): [True: 206, False: 4.95M]
  |  Branch (560:86): [True: 0, False: 4.95M]
  ------------------
  561|    206|            goto fail; /* string ended unexpectedly */
  562|    206|        }
  563|       |
  564|       |        /* This is at most how much we need for the output */
  565|  4.95M|        allocation_length = (size_t)(input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
  ------------------
  |  |  195|  4.95M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  566|  4.95M|        output = (unsigned char *)loader_calloc(input_buffer->pAllocator, allocation_length + sizeof(""),
  567|  4.95M|                                                VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  568|  4.95M|        if (output == NULL) {
  ------------------
  |  Branch (568:13): [True: 0, False: 4.95M]
  ------------------
  569|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  570|      0|            goto fail; /* allocation failure */
  571|      0|        }
  572|  4.95M|    }
  573|       |
  574|  4.95M|    output_pointer = output;
  575|       |    /* loop through the string literal */
  576|  94.4M|    while (input_pointer < input_end) {
  ------------------
  |  Branch (576:12): [True: 89.4M, False: 4.95M]
  ------------------
  577|  89.4M|        if (*input_pointer != '\\') {
  ------------------
  |  Branch (577:13): [True: 89.3M, False: 154k]
  ------------------
  578|  89.3M|            *output_pointer++ = *input_pointer++;
  579|  89.3M|        }
  580|       |        /* escape sequence */
  581|   154k|        else {
  582|   154k|            unsigned char sequence_length = 2;
  583|   154k|            if ((input_end - input_pointer) < 1) {
  ------------------
  |  Branch (583:17): [True: 0, False: 154k]
  ------------------
  584|      0|                goto fail;
  585|      0|            }
  586|       |
  587|   154k|            switch (input_pointer[1]) {
  588|  3.50k|                case 'b':
  ------------------
  |  Branch (588:17): [True: 3.50k, False: 151k]
  ------------------
  589|  3.50k|                    *output_pointer++ = '\b';
  590|  3.50k|                    break;
  591|  1.64k|                case 'f':
  ------------------
  |  Branch (591:17): [True: 1.64k, False: 153k]
  ------------------
  592|  1.64k|                    *output_pointer++ = '\f';
  593|  1.64k|                    break;
  594|  2.88k|                case 'n':
  ------------------
  |  Branch (594:17): [True: 2.88k, False: 151k]
  ------------------
  595|  2.88k|                    *output_pointer++ = '\n';
  596|  2.88k|                    break;
  597|    686|                case 'r':
  ------------------
  |  Branch (597:17): [True: 686, False: 154k]
  ------------------
  598|    686|                    *output_pointer++ = '\r';
  599|    686|                    break;
  600|  1.33k|                case 't':
  ------------------
  |  Branch (600:17): [True: 1.33k, False: 153k]
  ------------------
  601|  1.33k|                    *output_pointer++ = '\t';
  602|  1.33k|                    break;
  603|    718|                case '\"':
  ------------------
  |  Branch (603:17): [True: 718, False: 154k]
  ------------------
  604|  8.04k|                case '\\':
  ------------------
  |  Branch (604:17): [True: 7.33k, False: 147k]
  ------------------
  605|  12.0k|                case '/':
  ------------------
  |  Branch (605:17): [True: 3.98k, False: 150k]
  ------------------
  606|  12.0k|                    *output_pointer++ = input_pointer[1];
  607|  12.0k|                    break;
  608|       |
  609|       |                /* UTF-16 literal */
  610|   132k|                case 'u':
  ------------------
  |  Branch (610:17): [True: 132k, False: 22.2k]
  ------------------
  611|   132k|                    sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
  612|   132k|                    if (sequence_length == 0) {
  ------------------
  |  Branch (612:25): [True: 535, False: 132k]
  ------------------
  613|       |                        /* failed to convert UTF16-literal to UTF-8 */
  614|    535|                        goto fail;
  615|    535|                    }
  616|   132k|                    break;
  617|       |
  618|   132k|                default:
  ------------------
  |  Branch (618:17): [True: 126, False: 154k]
  ------------------
  619|    126|                    goto fail;
  620|   154k|            }
  621|   154k|            input_pointer += sequence_length;
  622|   154k|        }
  623|  89.4M|    }
  624|       |
  625|       |    /* zero terminate the output */
  626|  4.95M|    *output_pointer = '\0';
  627|       |
  628|  4.95M|    item->type = cJSON_String;
  ------------------
  |  |  101|  4.95M|#define cJSON_String (1 << 4)
  ------------------
  629|  4.95M|    item->valuestring = (char *)output;
  630|       |
  631|  4.95M|    input_buffer->offset = (size_t)(input_end - input_buffer->content);
  632|  4.95M|    input_buffer->offset++;
  633|       |
  634|  4.95M|    return true;
  ------------------
  |  |   67|  4.95M|#define true ((cJSON_bool)1)
  ------------------
  635|       |
  636|  1.52k|fail:
  637|  1.52k|    if (output != NULL) {
  ------------------
  |  Branch (637:9): [True: 661, False: 867]
  ------------------
  638|    661|        loader_free(input_buffer->pAllocator, output);
  639|    661|        output = NULL;
  640|    661|    }
  641|       |
  642|  1.52k|    if (input_pointer != NULL) {
  ------------------
  |  Branch (642:9): [True: 1.52k, False: 0]
  ------------------
  643|  1.52k|        input_buffer->offset = (size_t)(input_pointer - input_buffer->content);
  644|  1.52k|    }
  645|       |
  646|  1.52k|    return false;
  ------------------
  |  |   72|  1.52k|#define false ((cJSON_bool)0)
  ------------------
  647|  4.95M|}
cJSON.c:utf16_literal_to_utf8:
  435|   132k|                                           unsigned char **output_pointer) {
  436|   132k|    long unsigned int codepoint = 0;
  437|   132k|    unsigned int first_code = 0;
  438|   132k|    const unsigned char *first_sequence = input_pointer;
  439|   132k|    unsigned char utf8_length = 0;
  440|   132k|    unsigned char utf8_position = 0;
  441|   132k|    unsigned char sequence_length = 0;
  442|   132k|    unsigned char first_byte_mark = 0;
  443|       |
  444|   132k|    if ((input_end - first_sequence) < 6) {
  ------------------
  |  Branch (444:9): [True: 72, False: 132k]
  ------------------
  445|       |        /* input ends unexpectedly */
  446|     72|        goto fail;
  447|     72|    }
  448|       |
  449|       |    /* get the first utf16 sequence */
  450|   132k|    first_code = parse_hex4(first_sequence + 2);
  451|       |
  452|       |    /* check that the code is valid */
  453|   132k|    if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) {
  ------------------
  |  Branch (453:10): [True: 38.2k, False: 94.2k]
  |  Branch (453:36): [True: 88, False: 38.1k]
  ------------------
  454|     88|        goto fail;
  455|     88|    }
  456|       |
  457|       |    /* UTF16 surrogate pair */
  458|   132k|    if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) {
  ------------------
  |  Branch (458:9): [True: 40.5k, False: 91.8k]
  |  Branch (458:35): [True: 2.40k, False: 38.1k]
  ------------------
  459|  2.40k|        const unsigned char *second_sequence = first_sequence + 6;
  460|  2.40k|        unsigned int second_code = 0;
  461|  2.40k|        sequence_length = 12; /* \uXXXX\uXXXX */
  462|       |
  463|  2.40k|        if ((input_end - second_sequence) < 6) {
  ------------------
  |  Branch (463:13): [True: 96, False: 2.31k]
  ------------------
  464|       |            /* input ends unexpectedly */
  465|     96|            goto fail;
  466|     96|        }
  467|       |
  468|  2.31k|        if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) {
  ------------------
  |  Branch (468:13): [True: 16, False: 2.29k]
  |  Branch (468:45): [True: 74, False: 2.22k]
  ------------------
  469|       |            /* missing second half of the surrogate pair */
  470|     90|            goto fail;
  471|     90|        }
  472|       |
  473|       |        /* get the second utf16 sequence */
  474|  2.22k|        second_code = parse_hex4(second_sequence + 2);
  475|       |        /* check that the code is valid */
  476|  2.22k|        if ((second_code < 0xDC00) || (second_code > 0xDFFF)) {
  ------------------
  |  Branch (476:13): [True: 101, False: 2.12k]
  |  Branch (476:39): [True: 88, False: 2.03k]
  ------------------
  477|       |            /* invalid second half of the surrogate pair */
  478|    189|            goto fail;
  479|    189|        }
  480|       |
  481|       |        /* calculate the unicode codepoint from the surrogate pair */
  482|  2.03k|        codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF));
  483|   130k|    } else {
  484|   130k|        sequence_length = 6; /* \uXXXX */
  485|   130k|        codepoint = first_code;
  486|   130k|    }
  487|       |
  488|       |    /* encode as UTF-8
  489|       |     * takes at maximum 4 bytes to encode:
  490|       |     * 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
  491|   132k|    if (codepoint < 0x80) {
  ------------------
  |  Branch (491:9): [True: 70.1k, False: 61.9k]
  ------------------
  492|       |        /* normal ascii, encoding 0xxxxxxx */
  493|  70.1k|        utf8_length = 1;
  494|  70.1k|    } else if (codepoint < 0x800) {
  ------------------
  |  Branch (494:16): [True: 4.67k, False: 57.3k]
  ------------------
  495|       |        /* two bytes, encoding 110xxxxx 10xxxxxx */
  496|  4.67k|        utf8_length = 2;
  497|  4.67k|        first_byte_mark = 0xC0; /* 11000000 */
  498|  57.3k|    } else if (codepoint < 0x10000) {
  ------------------
  |  Branch (498:16): [True: 55.2k, False: 2.03k]
  ------------------
  499|       |        /* three bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx */
  500|  55.2k|        utf8_length = 3;
  501|  55.2k|        first_byte_mark = 0xE0; /* 11100000 */
  502|  55.2k|    } else if (codepoint <= 0x10FFFF) {
  ------------------
  |  Branch (502:16): [True: 2.03k, False: 0]
  ------------------
  503|       |        /* four bytes, encoding 1110xxxx 10xxxxxx 10xxxxxx 10xxxxxx */
  504|  2.03k|        utf8_length = 4;
  505|  2.03k|        first_byte_mark = 0xF0; /* 11110000 */
  506|  2.03k|    } else {
  507|       |        /* invalid unicode codepoint */
  508|      0|        goto fail;
  509|      0|    }
  510|       |
  511|       |    /* encode as utf8 */
  512|   253k|    for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) {
  ------------------
  |  Branch (512:60): [True: 121k, False: 132k]
  ------------------
  513|       |        /* 10xxxxxx */
  514|   121k|        (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF);
  515|   121k|        codepoint >>= 6;
  516|   121k|    }
  517|       |    /* encode first byte */
  518|   132k|    if (utf8_length > 1) {
  ------------------
  |  Branch (518:9): [True: 61.9k, False: 70.1k]
  ------------------
  519|  61.9k|        (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF);
  520|  70.1k|    } else {
  521|  70.1k|        (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F);
  522|  70.1k|    }
  523|       |
  524|   132k|    *output_pointer += utf8_length;
  525|       |
  526|   132k|    return sequence_length;
  527|       |
  528|    535|fail:
  529|    535|    return 0;
  530|   132k|}
cJSON.c:parse_hex4:
  406|   134k|static unsigned parse_hex4(const unsigned char *const input) {
  407|   134k|    unsigned int h = 0;
  408|   134k|    size_t i = 0;
  409|       |
  410|   510k|    for (i = 0; i < 4; i++) {
  ------------------
  |  Branch (410:17): [True: 443k, False: 67.0k]
  ------------------
  411|       |        /* parse digit */
  412|   443k|        if ((input[i] >= '0') && (input[i] <= '9')) {
  ------------------
  |  Branch (412:13): [True: 426k, False: 16.8k]
  |  Branch (412:34): [True: 224k, False: 202k]
  ------------------
  413|   224k|            h += (unsigned int)input[i] - '0';
  414|   224k|        } else if ((input[i] >= 'A') && (input[i] <= 'F')) {
  ------------------
  |  Branch (414:20): [True: 192k, False: 26.5k]
  |  Branch (414:41): [True: 47.1k, False: 145k]
  ------------------
  415|  47.1k|            h += (unsigned int)10 + input[i] - 'A';
  416|   171k|        } else if ((input[i] >= 'a') && (input[i] <= 'f')) {
  ------------------
  |  Branch (416:20): [True: 124k, False: 47.1k]
  |  Branch (416:41): [True: 104k, False: 20.5k]
  ------------------
  417|   104k|            h += (unsigned int)10 + input[i] - 'a';
  418|   104k|        } else /* invalid */
  419|  67.7k|        {
  420|  67.7k|            return 0;
  421|  67.7k|        }
  422|       |
  423|   375k|        if (i < 3) {
  ------------------
  |  Branch (423:13): [True: 308k, False: 67.0k]
  ------------------
  424|       |            /* shift left to make place for the next nibble */
  425|   308k|            h = h << 4;
  426|   308k|        }
  427|   375k|    }
  428|       |
  429|  67.0k|    return h;
  430|   134k|}
cJSON.c:parse_number:
  198|   420k|static cJSON_bool parse_number(cJSON *const item, parse_buffer *const input_buffer) {
  199|   420k|    double number = 0;
  200|   420k|    unsigned char *after_end = NULL;
  201|   420k|    unsigned char number_c_string[64];
  202|   420k|    unsigned char decimal_point = get_decimal_point();
  203|   420k|    size_t i = 0;
  204|       |
  205|   420k|    if ((input_buffer == NULL) || (input_buffer->content == NULL)) {
  ------------------
  |  Branch (205:9): [True: 0, False: 420k]
  |  Branch (205:35): [True: 0, False: 420k]
  ------------------
  206|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  207|      0|    }
  208|       |
  209|       |    /* copy the number into a temporary buffer and replace '.' with the decimal point
  210|       |     * of the current locale (for strtod)
  211|       |     * This also takes care of '\0' not necessarily being available for marking the end of the input */
  212|  1.58M|    for (i = 0; (i < (sizeof(number_c_string) - 1)) && can_access_at_index(input_buffer, i); i++) {
  ------------------
  |  |  192|  1.58M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 1.58M, False: 0]
  |  |  |  Branch (192:65): [True: 1.58M, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (212:17): [True: 1.58M, False: 232]
  ------------------
  213|  1.58M|        switch (buffer_at_offset(input_buffer)[i]) {
  ------------------
  |  |  195|  1.58M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  214|  63.8k|            case '0':
  ------------------
  |  Branch (214:13): [True: 63.8k, False: 1.52M]
  ------------------
  215|   314k|            case '1':
  ------------------
  |  Branch (215:13): [True: 250k, False: 1.33M]
  ------------------
  216|   370k|            case '2':
  ------------------
  |  Branch (216:13): [True: 55.8k, False: 1.52M]
  ------------------
  217|   466k|            case '3':
  ------------------
  |  Branch (217:13): [True: 95.8k, False: 1.48M]
  ------------------
  218|   492k|            case '4':
  ------------------
  |  Branch (218:13): [True: 25.6k, False: 1.56M]
  ------------------
  219|   605k|            case '5':
  ------------------
  |  Branch (219:13): [True: 113k, False: 1.47M]
  ------------------
  220|   635k|            case '6':
  ------------------
  |  Branch (220:13): [True: 30.0k, False: 1.55M]
  ------------------
  221|   861k|            case '7':
  ------------------
  |  Branch (221:13): [True: 226k, False: 1.35M]
  ------------------
  222|  1.02M|            case '8':
  ------------------
  |  Branch (222:13): [True: 166k, False: 1.41M]
  ------------------
  223|  1.10M|            case '9':
  ------------------
  |  Branch (223:13): [True: 77.6k, False: 1.50M]
  ------------------
  224|  1.10M|            case '+':
  ------------------
  |  Branch (224:13): [True: 746, False: 1.58M]
  ------------------
  225|  1.10M|            case '-':
  ------------------
  |  Branch (225:13): [True: 3.26k, False: 1.58M]
  ------------------
  226|  1.13M|            case 'e':
  ------------------
  |  Branch (226:13): [True: 27.9k, False: 1.55M]
  ------------------
  227|  1.13M|            case 'E':
  ------------------
  |  Branch (227:13): [True: 1.50k, False: 1.58M]
  ------------------
  228|  1.13M|                number_c_string[i] = buffer_at_offset(input_buffer)[i];
  ------------------
  |  |  195|  1.13M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  229|  1.13M|                break;
  230|       |
  231|  25.9k|            case '.':
  ------------------
  |  Branch (231:13): [True: 25.9k, False: 1.55M]
  ------------------
  232|  25.9k|                number_c_string[i] = decimal_point;
  233|  25.9k|                break;
  234|       |
  235|   420k|            default:
  ------------------
  |  Branch (235:13): [True: 420k, False: 1.16M]
  ------------------
  236|   420k|                goto loop_end;
  237|  1.58M|        }
  238|  1.58M|    }
  239|   420k|loop_end:
  240|   420k|    number_c_string[i] = '\0';
  241|       |
  242|   420k|    number = strtod((const char *)number_c_string, (char **)&after_end);
  243|   420k|    if (number_c_string == after_end) {
  ------------------
  |  Branch (243:9): [True: 72, False: 420k]
  ------------------
  244|     72|        return false; /* parse_error */
  ------------------
  |  |   72|     72|#define false ((cJSON_bool)0)
  ------------------
  245|     72|    }
  246|       |
  247|   420k|    item->valuedouble = number;
  248|       |
  249|       |    /* use saturation in case of overflow */
  250|   420k|    if (number >= INT_MAX) {
  ------------------
  |  Branch (250:9): [True: 34.3k, False: 386k]
  ------------------
  251|  34.3k|        item->valueint = INT_MAX;
  252|   386k|    } else if (number <= (double)INT_MIN) {
  ------------------
  |  Branch (252:16): [True: 920, False: 385k]
  ------------------
  253|    920|        item->valueint = INT_MIN;
  254|   385k|    } else {
  255|   385k|        item->valueint = (int)number;
  256|   385k|    }
  257|       |
  258|   420k|    item->type = cJSON_Number;
  ------------------
  |  |  100|   420k|#define cJSON_Number (1 << 3)
  ------------------
  259|       |
  260|   420k|    input_buffer->offset += (size_t)(after_end - number_c_string);
  261|   420k|    return true;
  ------------------
  |  |   67|   420k|#define true ((cJSON_bool)1)
  ------------------
  262|   420k|}
cJSON.c:get_decimal_point:
  172|   420k|static unsigned char get_decimal_point(void) {
  173|       |#ifdef ENABLE_LOCALES
  174|       |    struct lconv *lconv = localeconv();
  175|       |    return (unsigned char)lconv->decimal_point[0];
  176|       |#else
  177|   420k|    return '.';
  178|   420k|#endif
  179|   420k|}
cJSON.c:parse_array:
 1121|   253k|static cJSON_bool parse_array(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1122|   253k|    cJSON *head = NULL; /* head of the linked list */
 1123|   253k|    cJSON *current_item = NULL;
 1124|       |
 1125|   253k|    if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
  ------------------
  |  |  138|   253k|#define CJSON_NESTING_LIMIT 1000
  ------------------
  |  Branch (1125:9): [True: 33, False: 253k]
  ------------------
 1126|     33|        return false; /* to deeply nested */
  ------------------
  |  |   72|     33|#define false ((cJSON_bool)0)
  ------------------
 1127|     33|    }
 1128|   253k|    input_buffer->depth++;
 1129|       |
 1130|   253k|    if (buffer_at_offset(input_buffer)[0] != '[') {
  ------------------
  |  |  195|   253k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1130:9): [True: 0, False: 253k]
  ------------------
 1131|       |        /* not an array */
 1132|      0|        goto fail;
 1133|      0|    }
 1134|       |
 1135|   253k|    input_buffer->offset++;
 1136|   253k|    buffer_skip_whitespace(input_buffer);
 1137|   253k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) {
  ------------------
  |  |  192|   507k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 253k, False: 0]
  |  |  |  Branch (192:65): [True: 253k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ']')) {
  ------------------
  |  |  195|   253k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1137:49): [True: 29.5k, False: 223k]
  ------------------
 1138|       |        /* empty array */
 1139|  29.5k|        goto success;
 1140|  29.5k|    }
 1141|       |
 1142|       |    /* check if we skipped to the end of the buffer */
 1143|   223k|    if (cannot_access_at_index(input_buffer, 0)) {
  ------------------
  |  |  193|   223k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   223k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 223k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 223k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|      0|        input_buffer->offset--;
 1145|      0|        goto fail;
 1146|      0|    }
 1147|       |
 1148|       |    /* step back to character in front of the first element */
 1149|   223k|    input_buffer->offset--;
 1150|       |    /* loop through the comma separated array elements */
 1151|  1.21M|    do {
 1152|       |        /* allocate next item */
 1153|  1.21M|        cJSON *new_item = cJSON_New_Item(input_buffer->pAllocator);
 1154|  1.21M|        if (new_item == NULL) {
  ------------------
  |  Branch (1154:13): [True: 0, False: 1.21M]
  ------------------
 1155|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1156|      0|            goto fail; /* allocation failure */
 1157|      0|        }
 1158|       |
 1159|       |        /* attach next item to list */
 1160|  1.21M|        if (head == NULL) {
  ------------------
  |  Branch (1160:13): [True: 223k, False: 987k]
  ------------------
 1161|       |            /* start the linked list */
 1162|   223k|            current_item = head = new_item;
 1163|   987k|        } else {
 1164|       |            /* add to the end and advance */
 1165|   987k|            current_item->next = new_item;
 1166|   987k|            new_item->prev = current_item;
 1167|   987k|            current_item = new_item;
 1168|   987k|        }
 1169|       |
 1170|       |        /* parse next value */
 1171|  1.21M|        input_buffer->offset++;
 1172|  1.21M|        buffer_skip_whitespace(input_buffer);
 1173|  1.21M|        if (!parse_value(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1173:13): [True: 102k, False: 1.10M]
  ------------------
 1174|   102k|            goto fail; /* failed to parse value */
 1175|   102k|        }
 1176|  1.10M|        buffer_skip_whitespace(input_buffer);
 1177|  1.10M|    } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  192|  2.21M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 1.10M, False: 0]
  |  |  |  Branch (192:65): [True: 1.10M, False: 0]
  |  |  ------------------
  ------------------
                  } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  195|  1.10M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1177:54): [True: 987k, False: 121k]
  ------------------
 1178|       |
 1179|   121k|    if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') {
  ------------------
  |  |  193|   243k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   121k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 121k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 121k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || buffer_at_offset(input_buffer)[0] != ']') {
  ------------------
  |  |  195|   121k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1179:52): [True: 329, False: 121k]
  ------------------
 1180|    329|        goto fail; /* expected end of array */
 1181|    329|    }
 1182|       |
 1183|   150k|success:
 1184|   150k|    input_buffer->depth--;
 1185|       |
 1186|   150k|    if (head != NULL) {
  ------------------
  |  Branch (1186:9): [True: 121k, False: 29.5k]
  ------------------
 1187|   121k|        head->prev = current_item;
 1188|   121k|    }
 1189|       |
 1190|   150k|    item->type = cJSON_Array;
  ------------------
  |  |  102|   150k|#define cJSON_Array (1 << 5)
  ------------------
 1191|   150k|    item->child = head;
 1192|       |
 1193|   150k|    input_buffer->offset++;
 1194|       |
 1195|   150k|    return true;
  ------------------
  |  |   67|   150k|#define true ((cJSON_bool)1)
  ------------------
 1196|       |
 1197|   102k|fail:
 1198|   102k|    if (head != NULL) {
  ------------------
  |  Branch (1198:9): [True: 102k, False: 0]
  ------------------
 1199|   102k|        loader_cJSON_Delete(head);
 1200|   102k|    }
 1201|       |
 1202|   102k|    return false;
  ------------------
  |  |   72|   102k|#define false ((cJSON_bool)0)
  ------------------
 1203|   121k|}
cJSON.c:parse_object:
 1259|   458k|static cJSON_bool parse_object(cJSON *const item, parse_buffer *const input_buffer, bool *out_of_memory) {
 1260|   458k|    cJSON *head = NULL; /* linked list head */
 1261|   458k|    cJSON *current_item = NULL;
 1262|       |
 1263|   458k|    if (input_buffer->depth >= CJSON_NESTING_LIMIT) {
  ------------------
  |  |  138|   458k|#define CJSON_NESTING_LIMIT 1000
  ------------------
  |  Branch (1263:9): [True: 34, False: 458k]
  ------------------
 1264|     34|        return false; /* to deeply nested */
  ------------------
  |  |   72|     34|#define false ((cJSON_bool)0)
  ------------------
 1265|     34|    }
 1266|   458k|    input_buffer->depth++;
 1267|       |
 1268|   458k|    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) {
  ------------------
  |  |  193|   917k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   458k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 458k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 458k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{')) {
  ------------------
  |  |  195|   458k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1268:52): [True: 0, False: 458k]
  ------------------
 1269|      0|        goto fail; /* not an object */
 1270|      0|    }
 1271|       |
 1272|   458k|    input_buffer->offset++;
 1273|   458k|    buffer_skip_whitespace(input_buffer);
 1274|   458k|    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) {
  ------------------
  |  |  192|   917k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 458k, False: 0]
  |  |  |  Branch (192:65): [True: 458k, False: 0]
  |  |  ------------------
  ------------------
                  if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}')) {
  ------------------
  |  |  195|   458k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1274:49): [True: 16.0k, False: 442k]
  ------------------
 1275|  16.0k|        goto success; /* empty object */
 1276|  16.0k|    }
 1277|       |
 1278|       |    /* check if we skipped to the end of the buffer */
 1279|   442k|    if (cannot_access_at_index(input_buffer, 0)) {
  ------------------
  |  |  193|   442k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   442k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 442k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 442k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1280|      0|        input_buffer->offset--;
 1281|      0|        goto fail;
 1282|      0|    }
 1283|       |
 1284|       |    /* step back to character in front of the first element */
 1285|   442k|    input_buffer->offset--;
 1286|       |    /* loop through the comma separated array elements */
 1287|  2.44M|    do {
 1288|       |        /* allocate next item */
 1289|  2.44M|        cJSON *new_item = cJSON_New_Item(input_buffer->pAllocator);
 1290|  2.44M|        if (new_item == NULL) {
  ------------------
  |  Branch (1290:13): [True: 0, False: 2.44M]
  ------------------
 1291|      0|            *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1292|      0|            goto fail; /* allocation failure */
 1293|      0|        }
 1294|       |
 1295|       |        /* attach next item to list */
 1296|  2.44M|        if (head == NULL) {
  ------------------
  |  Branch (1296:13): [True: 442k, False: 2.00M]
  ------------------
 1297|       |            /* start the linked list */
 1298|   442k|            current_item = head = new_item;
 1299|  2.00M|        } else {
 1300|       |            /* add to the end and advance */
 1301|  2.00M|            current_item->next = new_item;
 1302|  2.00M|            new_item->prev = current_item;
 1303|  2.00M|            current_item = new_item;
 1304|  2.00M|        }
 1305|       |
 1306|  2.44M|        if (cannot_access_at_index(input_buffer, 1)) {
  ------------------
  |  |  193|  2.44M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  2.44M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 2.44M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 2.44M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1307|      0|            goto fail; /* nothing comes after the comma */
 1308|      0|        }
 1309|       |
 1310|       |        /* parse the name of the child */
 1311|  2.44M|        input_buffer->offset++;
 1312|  2.44M|        buffer_skip_whitespace(input_buffer);
 1313|  2.44M|        if (!parse_string(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1313:13): [True: 894, False: 2.44M]
  ------------------
 1314|    894|            goto fail; /* failed to parse name */
 1315|    894|        }
 1316|  2.44M|        buffer_skip_whitespace(input_buffer);
 1317|       |
 1318|       |        /* swap valuestring and string, because we parsed the name */
 1319|  2.44M|        current_item->string = current_item->valuestring;
 1320|  2.44M|        current_item->valuestring = NULL;
 1321|       |
 1322|  2.44M|        if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) {
  ------------------
  |  |  193|  4.88M|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|  2.44M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 2.44M, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 2.44M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':')) {
  ------------------
  |  |  195|  2.44M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1322:56): [True: 139, False: 2.44M]
  ------------------
 1323|    139|            goto fail; /* invalid object */
 1324|    139|        }
 1325|       |
 1326|       |        /* parse the value */
 1327|  2.44M|        input_buffer->offset++;
 1328|  2.44M|        buffer_skip_whitespace(input_buffer);
 1329|  2.44M|        if (!parse_value(current_item, input_buffer, out_of_memory)) {
  ------------------
  |  Branch (1329:13): [True: 2.05k, False: 2.44M]
  ------------------
 1330|  2.05k|            goto fail; /* failed to parse value */
 1331|  2.05k|        }
 1332|  2.44M|        buffer_skip_whitespace(input_buffer);
 1333|  2.44M|    } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  192|  4.88M|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  ------------------
  |  |  |  Branch (192:45): [True: 2.44M, False: 0]
  |  |  |  Branch (192:65): [True: 2.44M, False: 0]
  |  |  ------------------
  ------------------
                  } while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));
  ------------------
  |  |  195|  2.44M|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1333:54): [True: 2.00M, False: 439k]
  ------------------
 1334|       |
 1335|   439k|    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) {
  ------------------
  |  |  193|   879k|#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
  |  |  ------------------
  |  |  |  |  192|   439k|#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (192:45): [True: 439k, False: 0]
  |  |  |  |  |  Branch (192:65): [True: 439k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}')) {
  ------------------
  |  |  195|   439k|#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
  ------------------
  |  Branch (1335:52): [True: 71, False: 439k]
  ------------------
 1336|     71|        goto fail; /* expected end of object */
 1337|     71|    }
 1338|       |
 1339|   455k|success:
 1340|   455k|    input_buffer->depth--;
 1341|       |
 1342|   455k|    if (head != NULL) {
  ------------------
  |  Branch (1342:9): [True: 439k, False: 16.0k]
  ------------------
 1343|   439k|        head->prev = current_item;
 1344|   439k|    }
 1345|       |
 1346|   455k|    item->type = cJSON_Object;
  ------------------
  |  |  103|   455k|#define cJSON_Object (1 << 6)
  ------------------
 1347|   455k|    item->child = head;
 1348|       |
 1349|   455k|    input_buffer->offset++;
 1350|   455k|    return true;
  ------------------
  |  |   67|   455k|#define true ((cJSON_bool)1)
  ------------------
 1351|       |
 1352|  3.16k|fail:
 1353|  3.16k|    if (head != NULL) {
  ------------------
  |  Branch (1353:9): [True: 3.16k, False: 0]
  ------------------
 1354|  3.16k|        loader_cJSON_Delete(head);
 1355|  3.16k|    }
 1356|       |
 1357|  3.16k|    return false;
  ------------------
  |  |   72|  3.16k|#define false ((cJSON_bool)0)
  ------------------
 1358|   439k|}
cJSON.c:print_value:
 1056|   677k|static cJSON_bool print_value(const cJSON *const item, printbuffer *const output_buffer, bool *out_of_memory) {
 1057|   677k|    unsigned char *output = NULL;
 1058|       |
 1059|   677k|    if ((item == NULL) || (output_buffer == NULL)) {
  ------------------
  |  Branch (1059:9): [True: 0, False: 677k]
  |  Branch (1059:27): [True: 0, False: 677k]
  ------------------
 1060|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1061|      0|    }
 1062|       |
 1063|   677k|    switch ((item->type) & 0xFF) {
 1064|      0|        case cJSON_NULL:
  ------------------
  |  |   99|      0|#define cJSON_NULL (1 << 2)
  ------------------
  |  Branch (1064:9): [True: 0, False: 677k]
  ------------------
 1065|      0|            output = ensure(output_buffer, 5, out_of_memory);
 1066|      0|            if (output == NULL) {
  ------------------
  |  Branch (1066:17): [True: 0, False: 0]
  ------------------
 1067|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1068|      0|            }
 1069|      0|            strcpy((char *)output, "null");
 1070|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1071|       |
 1072|      0|        case cJSON_False:
  ------------------
  |  |   97|      0|#define cJSON_False (1 << 0)
  ------------------
  |  Branch (1072:9): [True: 0, False: 677k]
  ------------------
 1073|      0|            output = ensure(output_buffer, 6, out_of_memory);
 1074|      0|            if (output == NULL) {
  ------------------
  |  Branch (1074:17): [True: 0, False: 0]
  ------------------
 1075|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1076|      0|            }
 1077|      0|            strcpy((char *)output, "false");
 1078|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1079|       |
 1080|      0|        case cJSON_True:
  ------------------
  |  |   98|      0|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (1080:9): [True: 0, False: 677k]
  ------------------
 1081|      0|            output = ensure(output_buffer, 5, out_of_memory);
 1082|      0|            if (output == NULL) {
  ------------------
  |  Branch (1082:17): [True: 0, False: 0]
  ------------------
 1083|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1084|      0|            }
 1085|      0|            strcpy((char *)output, "true");
 1086|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1087|       |
 1088|      0|        case cJSON_Number:
  ------------------
  |  |  100|      0|#define cJSON_Number (1 << 3)
  ------------------
  |  Branch (1088:9): [True: 0, False: 677k]
  ------------------
 1089|      0|            return print_number(item, output_buffer, out_of_memory);
 1090|       |
 1091|      0|        case cJSON_Raw: {
  ------------------
  |  |  104|      0|#define cJSON_Raw (1 << 7) /* raw json */
  ------------------
  |  Branch (1091:9): [True: 0, False: 677k]
  ------------------
 1092|      0|            size_t raw_length = 0;
 1093|      0|            if (item->valuestring == NULL) {
  ------------------
  |  Branch (1093:17): [True: 0, False: 0]
  ------------------
 1094|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1095|      0|            }
 1096|       |
 1097|      0|            raw_length = strlen(item->valuestring) + sizeof("");
 1098|      0|            output = ensure(output_buffer, raw_length, out_of_memory);
 1099|      0|            if (output == NULL) {
  ------------------
  |  Branch (1099:17): [True: 0, False: 0]
  ------------------
 1100|      0|                return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1101|      0|            }
 1102|      0|            memcpy(output, item->valuestring, raw_length);
 1103|      0|            return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
 1104|      0|        }
 1105|       |
 1106|   677k|        case cJSON_String:
  ------------------
  |  |  101|   677k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (1106:9): [True: 677k, False: 0]
  ------------------
 1107|   677k|            return print_string(item, output_buffer, out_of_memory);
 1108|       |
 1109|      0|        case cJSON_Array:
  ------------------
  |  |  102|      0|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (1109:9): [True: 0, False: 677k]
  ------------------
 1110|      0|            return print_array(item, output_buffer, out_of_memory);
 1111|       |
 1112|      0|        case cJSON_Object:
  ------------------
  |  |  103|      0|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (1112:9): [True: 0, False: 677k]
  ------------------
 1113|      0|            return print_object(item, output_buffer, out_of_memory);
 1114|       |
 1115|      0|        default:
  ------------------
  |  Branch (1115:9): [True: 0, False: 677k]
  ------------------
 1116|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
 1117|   677k|    }
 1118|   677k|}
cJSON.c:ensure:
  275|   677k|static unsigned char *ensure(printbuffer *const p, size_t needed, bool *out_of_memory) {
  276|   677k|    unsigned char *newbuffer = NULL;
  277|   677k|    size_t newsize = 0;
  278|       |
  279|   677k|    if ((p == NULL) || (p->buffer == NULL)) {
  ------------------
  |  Branch (279:9): [True: 0, False: 677k]
  |  Branch (279:24): [True: 0, False: 677k]
  ------------------
  280|      0|        return NULL;
  281|      0|    }
  282|       |
  283|   677k|    if ((p->length > 0) && (p->offset >= p->length)) {
  ------------------
  |  Branch (283:9): [True: 677k, False: 0]
  |  Branch (283:28): [True: 0, False: 677k]
  ------------------
  284|       |        /* make sure that offset is valid */
  285|      0|        return NULL;
  286|      0|    }
  287|       |
  288|   677k|    if (needed > INT_MAX) {
  ------------------
  |  Branch (288:9): [True: 0, False: 677k]
  ------------------
  289|       |        /* sizes bigger than INT_MAX are currently not supported */
  290|      0|        return NULL;
  291|      0|    }
  292|       |
  293|   677k|    needed += p->offset + 1;
  294|   677k|    if (needed <= p->length) {
  ------------------
  |  Branch (294:9): [True: 673k, False: 3.24k]
  ------------------
  295|   673k|        return p->buffer + p->offset;
  296|   673k|    }
  297|       |
  298|  3.24k|    if (p->noalloc) {
  ------------------
  |  Branch (298:9): [True: 555, False: 2.69k]
  ------------------
  299|    555|        return NULL;
  300|    555|    }
  301|       |
  302|       |    /* calculate new buffer size */
  303|  2.69k|    if (needed > (INT_MAX / 2)) {
  ------------------
  |  Branch (303:9): [True: 0, False: 2.69k]
  ------------------
  304|       |        /* overflow of int, use INT_MAX if possible */
  305|      0|        if (needed <= INT_MAX) {
  ------------------
  |  Branch (305:13): [True: 0, False: 0]
  ------------------
  306|      0|            newsize = INT_MAX;
  307|      0|        } else {
  308|      0|            return NULL;
  309|      0|        }
  310|  2.69k|    } else {
  311|  2.69k|        newsize = needed * 2;
  312|  2.69k|    }
  313|       |
  314|  2.69k|    newbuffer = (unsigned char *)loader_realloc(p->pAllocator, p->buffer, p->length, newsize, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  315|  2.69k|    if (newbuffer == NULL) {
  ------------------
  |  Branch (315:9): [True: 0, False: 2.69k]
  ------------------
  316|      0|        *out_of_memory = true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  317|      0|        loader_free(p->pAllocator, p->buffer);
  318|      0|        p->length = 0;
  319|      0|        p->buffer = NULL;
  320|       |
  321|      0|        return NULL;
  322|      0|    }
  323|       |
  324|  2.69k|    p->length = newsize;
  325|  2.69k|    p->buffer = newbuffer;
  326|       |
  327|  2.69k|    return newbuffer + p->offset;
  328|  2.69k|}
cJSON.c:print_string:
  759|   677k|static cJSON_bool print_string(const cJSON *const item, printbuffer *const p, bool *out_of_memory) {
  760|   677k|    return print_string_ptr((unsigned char *)item->valuestring, p, out_of_memory);
  761|   677k|}
cJSON.c:print_string_ptr:
  650|   677k|static cJSON_bool print_string_ptr(const unsigned char *const input, printbuffer *const output_buffer, bool *out_of_memory) {
  651|   677k|    const unsigned char *input_pointer = NULL;
  652|   677k|    unsigned char *output = NULL;
  653|   677k|    unsigned char *output_pointer = NULL;
  654|   677k|    size_t output_length = 0;
  655|       |    /* numbers of additional characters needed for escaping */
  656|   677k|    size_t escape_characters = 0;
  657|       |
  658|   677k|    if (output_buffer == NULL) {
  ------------------
  |  Branch (658:9): [True: 0, False: 677k]
  ------------------
  659|      0|        return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  660|      0|    }
  661|       |
  662|       |    /* empty string */
  663|   677k|    if (input == NULL) {
  ------------------
  |  Branch (663:9): [True: 0, False: 677k]
  ------------------
  664|      0|        output = ensure(output_buffer, sizeof(""), out_of_memory);
  665|      0|        if (output == NULL) {
  ------------------
  |  Branch (665:13): [True: 0, False: 0]
  ------------------
  666|      0|            return false;
  ------------------
  |  |   72|      0|#define false ((cJSON_bool)0)
  ------------------
  667|      0|        }
  668|       |
  669|      0|        return true;
  ------------------
  |  |   67|      0|#define true ((cJSON_bool)1)
  ------------------
  670|      0|    }
  671|       |
  672|       |    /* set "flag" to 1 if something needs to be escaped */
  673|  20.5M|    for (input_pointer = input; *input_pointer; input_pointer++) {
  ------------------
  |  Branch (673:33): [True: 19.8M, False: 677k]
  ------------------
  674|  19.8M|        switch (*input_pointer) {
  675|    278|            case '\"':
  ------------------
  |  Branch (675:13): [True: 278, False: 19.8M]
  ------------------
  676|  2.50k|            case '\\':
  ------------------
  |  Branch (676:13): [True: 2.22k, False: 19.8M]
  ------------------
  677|  23.1k|            case '\b':
  ------------------
  |  Branch (677:13): [True: 20.6k, False: 19.8M]
  ------------------
  678|  27.3k|            case '\f':
  ------------------
  |  Branch (678:13): [True: 4.16k, False: 19.8M]
  ------------------
  679|  35.6k|            case '\n':
  ------------------
  |  Branch (679:13): [True: 8.37k, False: 19.8M]
  ------------------
  680|  41.4k|            case '\r':
  ------------------
  |  Branch (680:13): [True: 5.75k, False: 19.8M]
  ------------------
  681|  51.7k|            case '\t':
  ------------------
  |  Branch (681:13): [True: 10.3k, False: 19.8M]
  ------------------
  682|       |                /* one character escape sequence */
  683|  51.7k|                escape_characters++;
  684|  51.7k|                break;
  685|  19.7M|            default:
  ------------------
  |  Branch (685:13): [True: 19.7M, False: 51.7k]
  ------------------
  686|  19.7M|                if (*input_pointer < 32) {
  ------------------
  |  Branch (686:21): [True: 15.0M, False: 4.71M]
  ------------------
  687|       |                    /* UTF-16 escape sequence uXXXX */
  688|  15.0M|                    escape_characters += 5;
  689|  15.0M|                }
  690|  19.7M|                break;
  691|  19.8M|        }
  692|  19.8M|    }
  693|   677k|    output_length = (size_t)(input_pointer - input) + escape_characters;
  694|       |
  695|   677k|    output = ensure(output_buffer, output_length + sizeof(""), out_of_memory);
  696|   677k|    if (output == NULL) {
  ------------------
  |  Branch (696:9): [True: 555, False: 676k]
  ------------------
  697|    555|        return false;
  ------------------
  |  |   72|    555|#define false ((cJSON_bool)0)
  ------------------
  698|    555|    }
  699|       |
  700|       |    /* no characters have to be escaped */
  701|   676k|    if (escape_characters == 0) {
  ------------------
  |  Branch (701:9): [True: 598k, False: 78.5k]
  ------------------
  702|   598k|        memcpy(output, input, output_length);
  703|   598k|        output[output_length] = '\0';
  704|       |
  705|   598k|        return true;
  ------------------
  |  |   67|   598k|#define true ((cJSON_bool)1)
  ------------------
  706|   598k|    }
  707|       |
  708|  78.5k|    output_pointer = output;
  709|       |    /* copy the string */
  710|  16.4M|    for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++) {
  ------------------
  |  Branch (710:33): [True: 16.4M, False: 78.5k]
  ------------------
  711|  16.4M|        if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\')) {
  ------------------
  |  Branch (711:13): [True: 1.73M, False: 14.6M]
  |  Branch (711:38): [True: 1.72M, False: 270]
  |  Branch (711:66): [True: 1.72M, False: 2.22k]
  ------------------
  712|       |            /* normal character, copy */
  713|  1.72M|            *output_pointer = *input_pointer;
  714|  14.6M|        } else {
  715|       |            // Loader specific modification - don't add a backslash because that will 'double up' any existing back slashes.
  716|       |            // This change was added right after vulkan's public release, so while it may not be a problem, there are plenty
  717|       |            // of API calls made which might not work if the paths have "\\"" in them
  718|       |            /* character needs to be escaped */
  719|       |            //*output_pointer++ = '\\';
  720|  14.6M|            switch (*input_pointer) {
  721|  2.22k|                case '\\':
  ------------------
  |  Branch (721:17): [True: 2.22k, False: 14.6M]
  ------------------
  722|  2.22k|                    *output_pointer = '\\';
  723|  2.22k|                    break;
  724|    270|                case '\"':
  ------------------
  |  Branch (724:17): [True: 270, False: 14.6M]
  ------------------
  725|    270|                    *output_pointer = '\"';
  726|    270|                    break;
  727|  20.6k|                case '\b':
  ------------------
  |  Branch (727:17): [True: 20.6k, False: 14.6M]
  ------------------
  728|  20.6k|                    *output_pointer = '\b';
  729|  20.6k|                    break;
  730|  3.84k|                case '\f':
  ------------------
  |  Branch (730:17): [True: 3.84k, False: 14.6M]
  ------------------
  731|  3.84k|                    *output_pointer = '\f';
  732|  3.84k|                    break;
  733|  8.36k|                case '\n':
  ------------------
  |  Branch (733:17): [True: 8.36k, False: 14.6M]
  ------------------
  734|  8.36k|                    *output_pointer = '\n';
  735|  8.36k|                    break;
  736|  5.74k|                case '\r':
  ------------------
  |  Branch (736:17): [True: 5.74k, False: 14.6M]
  ------------------
  737|  5.74k|                    *output_pointer = '\r';
  738|  5.74k|                    break;
  739|  10.1k|                case '\t':
  ------------------
  |  Branch (739:17): [True: 10.1k, False: 14.6M]
  ------------------
  740|  10.1k|                    *output_pointer = '\t';
  741|  10.1k|                    break;
  742|  14.6M|                default:
  ------------------
  |  Branch (742:17): [True: 14.6M, False: 51.2k]
  ------------------
  743|       |                    /* escape and print as unicode codepoint */
  744|  14.6M|                    snprintf((char *)output_pointer, output_length - (size_t)(output_pointer - output), "u%04x", *input_pointer);
  745|  14.6M|                    output_pointer += 4;
  746|  14.6M|                    break;
  747|  14.6M|            }
  748|  14.6M|        }
  749|  16.4M|    }
  750|       |    // The loader-specific escaping above emits one byte where the standard form emits two, so the written
  751|       |    // length is shorter than output_length. Terminate at the actual end, otherwise the bytes between it and
  752|       |    // output_length (uninitialized when the caller buffer is not zeroed) get read back as part of the string.
  753|  78.5k|    *output_pointer = '\0';
  754|       |
  755|  78.5k|    return true;
  ------------------
  |  |   67|  78.5k|#define true ((cJSON_bool)1)
  ------------------
  756|  78.5k|}
cJSON.c:get_object_item:
 1501|  2.46M|static cJSON *get_object_item(const cJSON *const object, const char *const name, const cJSON_bool case_sensitive) {
 1502|  2.46M|    cJSON *current_element = NULL;
 1503|       |
 1504|  2.46M|    if ((object == NULL) || (name == NULL)) {
  ------------------
  |  Branch (1504:9): [True: 0, False: 2.46M]
  |  Branch (1504:29): [True: 0, False: 2.46M]
  ------------------
 1505|      0|        return NULL;
 1506|      0|    }
 1507|       |
 1508|  2.46M|    current_element = object->child;
 1509|  2.46M|    if (case_sensitive) {
  ------------------
  |  Branch (1509:9): [True: 0, False: 2.46M]
  ------------------
 1510|      0|        while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0)) {
  ------------------
  |  Branch (1510:16): [True: 0, False: 0]
  |  Branch (1510:45): [True: 0, False: 0]
  |  Branch (1510:82): [True: 0, False: 0]
  ------------------
 1511|      0|            current_element = current_element->next;
 1512|      0|        }
 1513|  2.46M|    } else {
 1514|  16.2M|        while ((current_element != NULL) &&
  ------------------
  |  Branch (1514:16): [True: 14.9M, False: 1.21M]
  ------------------
 1515|  14.9M|               (case_insensitive_strcmp((const unsigned char *)name, (const unsigned char *)(current_element->string)) != 0)) {
  ------------------
  |  Branch (1515:16): [True: 13.7M, False: 1.24M]
  ------------------
 1516|  13.7M|            current_element = current_element->next;
 1517|  13.7M|        }
 1518|  2.46M|    }
 1519|       |
 1520|  2.46M|    if ((current_element == NULL) || (current_element->string == NULL)) {
  ------------------
  |  Branch (1520:9): [True: 1.21M, False: 1.24M]
  |  Branch (1520:38): [True: 0, False: 1.24M]
  ------------------
 1521|  1.21M|        return NULL;
 1522|  1.21M|    }
 1523|       |
 1524|  1.24M|    return current_element;
 1525|  2.46M|}
cJSON.c:case_insensitive_strcmp:
  120|  14.9M|static int case_insensitive_strcmp(const unsigned char *string1, const unsigned char *string2) {
  121|  14.9M|    if ((string1 == NULL) || (string2 == NULL)) {
  ------------------
  |  Branch (121:9): [True: 0, False: 14.9M]
  |  Branch (121:30): [True: 222, False: 14.9M]
  ------------------
  122|    222|        return 1;
  123|    222|    }
  124|       |
  125|  14.9M|    if (string1 == string2) {
  ------------------
  |  Branch (125:9): [True: 0, False: 14.9M]
  ------------------
  126|      0|        return 0;
  127|      0|    }
  128|       |
  129|  30.3M|    for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++) {
  ------------------
  |  Branch (129:12): [True: 0, False: 0]
  |  Branch (129:12): [True: 0, False: 0]
  |  Branch (129:12): [Folded, False: 30.3M]
  |  Branch (129:12): [True: 16.6M, False: 13.7M]
  |  Branch (129:33): [True: 0, False: 0]
  |  Branch (129:33): [True: 0, False: 0]
  |  Branch (129:33): [Folded, False: 30.3M]
  ------------------
  130|  16.6M|        if (*string1 == '\0') {
  ------------------
  |  Branch (130:13): [True: 1.24M, False: 15.3M]
  ------------------
  131|  1.24M|            return 0;
  132|  1.24M|        }
  133|  16.6M|    }
  134|       |
  135|  13.7M|    return tolower(*string1) - tolower(*string2);
  ------------------
  |  Branch (135:12): [True: 0, False: 0]
  |  Branch (135:12): [True: 0, False: 0]
  |  Branch (135:12): [Folded, False: 13.7M]
  |  Branch (135:32): [True: 0, False: 0]
  |  Branch (135:32): [True: 0, False: 0]
  |  Branch (135:32): [Folded, False: 13.7M]
  ------------------
  136|  14.9M|}

util_SubmitDebugUtilsMessageEXT:
   78|   859k|                                         const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) {
   79|   859k|    VkBool32 bail = false;
   80|       |
   81|   859k|    if (NULL != pCallbackData) {
  ------------------
  |  Branch (81:9): [True: 859k, False: 0]
  ------------------
   82|   859k|        VkLayerDbgFunctionNode *pTrav = inst->current_dbg_function_head;
   83|   859k|        VkDebugReportObjectTypeEXT object_type = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
   84|   859k|        VkDebugReportFlagsEXT object_flags = 0;
   85|   859k|        uint64_t object_handle = 0;
   86|       |
   87|   859k|        debug_utils_AnnotFlagsToReportFlags(messageSeverity, messageTypes, &object_flags);
   88|   859k|        if (0 < pCallbackData->objectCount) {
  ------------------
  |  Branch (88:13): [True: 859k, False: 0]
  ------------------
   89|   859k|            debug_utils_AnnotObjectToDebugReportObject(pCallbackData->pObjects, &object_type, &object_handle);
   90|   859k|        }
   91|   859k|        while (pTrav) {
  ------------------
  |  Branch (91:16): [True: 0, False: 859k]
  ------------------
   92|      0|            if (pTrav->is_messenger && (pTrav->messenger.messageSeverity & messageSeverity) &&
  ------------------
  |  Branch (92:17): [True: 0, False: 0]
  |  Branch (92:40): [True: 0, False: 0]
  ------------------
   93|      0|                (pTrav->messenger.messageType & messageTypes)) {
  ------------------
  |  Branch (93:17): [True: 0, False: 0]
  ------------------
   94|      0|                if (pTrav->messenger.pfnUserCallback(messageSeverity, messageTypes, pCallbackData, pTrav->pUserData)) {
  ------------------
  |  Branch (94:21): [True: 0, False: 0]
  ------------------
   95|      0|                    bail = true;
   96|      0|                }
   97|      0|            }
   98|      0|            if (!pTrav->is_messenger && pTrav->report.msgFlags & object_flags) {
  ------------------
  |  Branch (98:17): [True: 0, False: 0]
  |  Branch (98:41): [True: 0, False: 0]
  ------------------
   99|      0|                if (pTrav->report.pfnMsgCallback(object_flags, object_type, object_handle, 0, pCallbackData->messageIdNumber,
  ------------------
  |  Branch (99:21): [True: 0, False: 0]
  ------------------
  100|      0|                                                 pCallbackData->pMessageIdName, pCallbackData->pMessage, pTrav->pUserData)) {
  101|      0|                    bail = true;
  102|      0|                }
  103|      0|            }
  104|      0|            pTrav = pTrav->pNext;
  105|      0|        }
  106|   859k|    }
  107|       |
  108|   859k|    return bail;
  109|   859k|}
util_CreateDebugUtilsMessengers:
  130|  6.85k|                                         const VkAllocationCallbacks *pAllocator) {
  131|  6.85k|    const void *pNext = pChain;
  132|  6.85k|    while (pNext) {
  ------------------
  |  Branch (132:12): [True: 0, False: 6.85k]
  ------------------
  133|      0|        VkBaseInStructure in_structure = {0};
  134|      0|        memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
  135|      0|        if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) {
  ------------------
  |  Branch (135:13): [True: 0, False: 0]
  ------------------
  136|       |            // Assign a unique handle to each messenger (just use the address of the VkDebugUtilsMessengerCreateInfoEXT)
  137|       |            // This is only being used this way due to it being for an 'anonymous' callback during instance creation
  138|       |            // NOLINTNEXTLINE(performance-no-int-to-ptr) - non-dispatchable handle; round-trip via uintptr_t is required
  139|      0|            VkDebugUtilsMessengerEXT messenger_handle = (VkDebugUtilsMessengerEXT)(uintptr_t)pNext;
  140|      0|            VkResult ret = util_CreateDebugUtilsMessenger(inst, (const VkDebugUtilsMessengerCreateInfoEXT *)pNext, pAllocator,
  141|      0|                                                          messenger_handle);
  142|      0|            if (ret != VK_SUCCESS) {
  ------------------
  |  Branch (142:17): [True: 0, False: 0]
  ------------------
  143|      0|                return ret;
  144|      0|            }
  145|      0|        }
  146|      0|        pNext = in_structure.pNext;
  147|      0|    }
  148|  6.85k|    return VK_SUCCESS;
  149|  6.85k|}
util_CreateDebugReportCallbacks:
  416|  6.85k|                                         const VkAllocationCallbacks *pAllocator) {
  417|  6.85k|    const void *pNext = pChain;
  418|  6.85k|    while (pNext) {
  ------------------
  |  Branch (418:12): [True: 0, False: 6.85k]
  ------------------
  419|      0|        VkBaseInStructure in_structure = {0};
  420|      0|        memcpy(&in_structure, pNext, sizeof(VkBaseInStructure));
  421|      0|        if (in_structure.sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) {
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|       |            // Assign a unique handle to each callback (just use the address of the VkDebugReportCallbackCreateInfoEXT):
  423|       |            // This is only being used this way due to it being for an 'anonymous' callback during instance creation
  424|       |            // NOLINTNEXTLINE(performance-no-int-to-ptr) - non-dispatchable handle; round-trip via uintptr_t is required
  425|      0|            VkDebugReportCallbackEXT report_handle = (VkDebugReportCallbackEXT)(uintptr_t)pNext;
  426|      0|            VkResult ret =
  427|      0|                util_CreateDebugReportCallback(inst, (const VkDebugReportCallbackCreateInfoEXT *)pNext, pAllocator, report_handle);
  428|      0|            if (ret != VK_SUCCESS) {
  ------------------
  |  Branch (428:17): [True: 0, False: 0]
  ------------------
  429|      0|                return ret;
  430|      0|            }
  431|      0|        }
  432|      0|        pNext = in_structure.pNext;
  433|      0|    }
  434|  6.85k|    return VK_SUCCESS;
  435|  6.85k|}
destroy_debug_callbacks_chain:
  618|  6.85k|void destroy_debug_callbacks_chain(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator) {
  619|  6.85k|    VkLayerDbgFunctionNode *pTrav = inst->current_dbg_function_head;
  620|  6.85k|    VkLayerDbgFunctionNode *pNext = NULL;
  621|  6.85k|    while (pTrav) {
  ------------------
  |  Branch (621:12): [True: 0, False: 6.85k]
  ------------------
  622|      0|        pNext = pTrav->pNext;
  623|      0|        loader_free_with_instance_fallback(pAllocator, inst, pTrav);
  624|      0|        pTrav = pNext;
  625|      0|    }
  626|       |    inst->current_dbg_function_head = NULL;
  627|  6.85k|}
debug_utils_AnnotFlagsToReportFlags:
  703|   859k|                                         VkDebugUtilsMessageTypeFlagsEXT da_type, VkDebugReportFlagsEXT *dr_flags) {
  704|   859k|    if (NULL == dr_flags) {
  ------------------
  |  Branch (704:9): [True: 0, False: 859k]
  ------------------
  705|      0|        return false;
  706|      0|    }
  707|       |
  708|   859k|    *dr_flags = 0;
  709|       |
  710|   859k|    if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) != 0) {
  ------------------
  |  Branch (710:9): [True: 16.8k, False: 842k]
  ------------------
  711|  16.8k|        *dr_flags |= VK_DEBUG_REPORT_ERROR_BIT_EXT;
  712|   842k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) != 0) {
  ------------------
  |  Branch (712:16): [True: 449k, False: 392k]
  ------------------
  713|   449k|        if ((da_type & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) != 0) {
  ------------------
  |  Branch (713:13): [True: 0, False: 449k]
  ------------------
  714|      0|            *dr_flags |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
  715|   449k|        } else {
  716|   449k|            *dr_flags |= VK_DEBUG_REPORT_WARNING_BIT_EXT;
  717|   449k|        }
  718|   449k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) != 0) {
  ------------------
  |  Branch (718:16): [True: 248k, False: 144k]
  ------------------
  719|   248k|        *dr_flags |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
  720|   248k|    } else if ((da_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) != 0) {
  ------------------
  |  Branch (720:16): [True: 144k, False: 0]
  ------------------
  721|   144k|        *dr_flags |= VK_DEBUG_REPORT_DEBUG_BIT_EXT;
  722|   144k|    }
  723|       |
  724|       |    return true;
  725|   859k|}
debug_utils_AnnotObjectToDebugReportObject:
  742|   859k|                                                VkDebugReportObjectTypeEXT *dr_object_type, uint64_t *dr_object_handle) {
  743|   859k|    if (NULL == da_object_name_info || NULL == dr_object_type || NULL == dr_object_handle) {
  ------------------
  |  Branch (743:9): [True: 0, False: 859k]
  |  Branch (743:40): [True: 0, False: 859k]
  |  Branch (743:66): [True: 0, False: 859k]
  ------------------
  744|      0|        return false;
  745|      0|    }
  746|   859k|    *dr_object_type = convertCoreObjectToDebugReportObject(da_object_name_info->objectType);
  747|   859k|    *dr_object_handle = da_object_name_info->objectHandle;
  748|       |    return true;
  749|   859k|}

debug_utils.c:convertCoreObjectToDebugReportObject:
  391|   859k|static inline VkDebugReportObjectTypeEXT convertCoreObjectToDebugReportObject(VkObjectType core_report_obj){
  392|   859k|    if (core_report_obj == VK_OBJECT_TYPE_UNKNOWN) {
  ------------------
  |  Branch (392:9): [True: 0, False: 859k]
  ------------------
  393|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  394|   859k|    } else if (core_report_obj == VK_OBJECT_TYPE_UNKNOWN) {
  ------------------
  |  Branch (394:16): [True: 0, False: 859k]
  ------------------
  395|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  396|   859k|    } else if (core_report_obj == VK_OBJECT_TYPE_INSTANCE) {
  ------------------
  |  Branch (396:16): [True: 859k, False: 0]
  ------------------
  397|   859k|        return VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT;
  398|   859k|    } else if (core_report_obj == VK_OBJECT_TYPE_PHYSICAL_DEVICE) {
  ------------------
  |  Branch (398:16): [True: 0, False: 0]
  ------------------
  399|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT;
  400|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DEVICE) {
  ------------------
  |  Branch (400:16): [True: 0, False: 0]
  ------------------
  401|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT;
  402|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_QUEUE) {
  ------------------
  |  Branch (402:16): [True: 0, False: 0]
  ------------------
  403|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT;
  404|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SEMAPHORE) {
  ------------------
  |  Branch (404:16): [True: 0, False: 0]
  ------------------
  405|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT;
  406|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_COMMAND_BUFFER) {
  ------------------
  |  Branch (406:16): [True: 0, False: 0]
  ------------------
  407|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT;
  408|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_FENCE) {
  ------------------
  |  Branch (408:16): [True: 0, False: 0]
  ------------------
  409|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT;
  410|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DEVICE_MEMORY) {
  ------------------
  |  Branch (410:16): [True: 0, False: 0]
  ------------------
  411|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT;
  412|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_BUFFER) {
  ------------------
  |  Branch (412:16): [True: 0, False: 0]
  ------------------
  413|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT;
  414|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_IMAGE) {
  ------------------
  |  Branch (414:16): [True: 0, False: 0]
  ------------------
  415|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT;
  416|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_EVENT) {
  ------------------
  |  Branch (416:16): [True: 0, False: 0]
  ------------------
  417|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT;
  418|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_QUERY_POOL) {
  ------------------
  |  Branch (418:16): [True: 0, False: 0]
  ------------------
  419|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT;
  420|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_BUFFER_VIEW) {
  ------------------
  |  Branch (420:16): [True: 0, False: 0]
  ------------------
  421|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT;
  422|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_IMAGE_VIEW) {
  ------------------
  |  Branch (422:16): [True: 0, False: 0]
  ------------------
  423|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT;
  424|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SHADER_MODULE) {
  ------------------
  |  Branch (424:16): [True: 0, False: 0]
  ------------------
  425|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT;
  426|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_PIPELINE_CACHE) {
  ------------------
  |  Branch (426:16): [True: 0, False: 0]
  ------------------
  427|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT;
  428|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_PIPELINE_LAYOUT) {
  ------------------
  |  Branch (428:16): [True: 0, False: 0]
  ------------------
  429|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT;
  430|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_RENDER_PASS) {
  ------------------
  |  Branch (430:16): [True: 0, False: 0]
  ------------------
  431|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT;
  432|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_PIPELINE) {
  ------------------
  |  Branch (432:16): [True: 0, False: 0]
  ------------------
  433|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT;
  434|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) {
  ------------------
  |  Branch (434:16): [True: 0, False: 0]
  ------------------
  435|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT;
  436|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SAMPLER) {
  ------------------
  |  Branch (436:16): [True: 0, False: 0]
  ------------------
  437|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT;
  438|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_POOL) {
  ------------------
  |  Branch (438:16): [True: 0, False: 0]
  ------------------
  439|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT;
  440|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_SET) {
  ------------------
  |  Branch (440:16): [True: 0, False: 0]
  ------------------
  441|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT;
  442|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_FRAMEBUFFER) {
  ------------------
  |  Branch (442:16): [True: 0, False: 0]
  ------------------
  443|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT;
  444|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_COMMAND_POOL) {
  ------------------
  |  Branch (444:16): [True: 0, False: 0]
  ------------------
  445|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT;
  446|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE) {
  ------------------
  |  Branch (446:16): [True: 0, False: 0]
  ------------------
  447|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT;
  448|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION) {
  ------------------
  |  Branch (448:16): [True: 0, False: 0]
  ------------------
  449|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT;
  450|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SURFACE_KHR) {
  ------------------
  |  Branch (450:16): [True: 0, False: 0]
  ------------------
  451|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT;
  452|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_SWAPCHAIN_KHR) {
  ------------------
  |  Branch (452:16): [True: 0, False: 0]
  ------------------
  453|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT;
  454|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DISPLAY_KHR) {
  ------------------
  |  Branch (454:16): [True: 0, False: 0]
  ------------------
  455|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT;
  456|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DISPLAY_MODE_KHR) {
  ------------------
  |  Branch (456:16): [True: 0, False: 0]
  ------------------
  457|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT;
  458|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT) {
  ------------------
  |  Branch (458:16): [True: 0, False: 0]
  ------------------
  459|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT;
  460|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CU_MODULE_NVX) {
  ------------------
  |  Branch (460:16): [True: 0, False: 0]
  ------------------
  461|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CU_MODULE_NVX_EXT;
  462|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CU_FUNCTION_NVX) {
  ------------------
  |  Branch (462:16): [True: 0, False: 0]
  ------------------
  463|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CU_FUNCTION_NVX_EXT;
  464|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR) {
  ------------------
  |  Branch (464:16): [True: 0, False: 0]
  ------------------
  465|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR_EXT;
  466|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_VALIDATION_CACHE_EXT) {
  ------------------
  |  Branch (466:16): [True: 0, False: 0]
  ------------------
  467|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT;
  468|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV) {
  ------------------
  |  Branch (468:16): [True: 0, False: 0]
  ------------------
  469|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT;
  470|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CUDA_MODULE_NV) {
  ------------------
  |  Branch (470:16): [True: 0, False: 0]
  ------------------
  471|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_MODULE_NV_EXT;
  472|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_CUDA_FUNCTION_NV) {
  ------------------
  |  Branch (472:16): [True: 0, False: 0]
  ------------------
  473|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_FUNCTION_NV_EXT;
  474|      0|    } else if (core_report_obj == VK_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA) {
  ------------------
  |  Branch (474:16): [True: 0, False: 0]
  ------------------
  475|      0|        return VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA_EXT;
  476|      0|    }
  477|      0|    return VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT;
  478|   859k|}

loader_make_version:
  113|  34.1k|loader_api_version loader_make_version(uint32_t version) {
  114|  34.1k|    loader_api_version out_version;
  115|  34.1k|    out_version.major = VK_API_VERSION_MAJOR(version);
  116|       |    out_version.minor = VK_API_VERSION_MINOR(version);
  117|  34.1k|    out_version.patch = 0;
  118|  34.1k|    return out_version;
  119|  34.1k|}
loader_make_full_version:
  122|  8.88k|loader_api_version loader_make_full_version(uint32_t version) {
  123|  8.88k|    loader_api_version out_version;
  124|  8.88k|    out_version.major = VK_API_VERSION_MAJOR(version);
  125|  8.88k|    out_version.minor = VK_API_VERSION_MINOR(version);
  126|       |    out_version.patch = VK_API_VERSION_PATCH(version);
  127|  8.88k|    return out_version;
  128|  8.88k|}
loader_combine_version:
  131|  90.7k|loader_api_version loader_combine_version(uint32_t major, uint32_t minor, uint32_t patch) {
  132|  90.7k|    loader_api_version out_version;
  133|  90.7k|    out_version.major = (uint16_t)major;
  134|  90.7k|    out_version.minor = (uint16_t)minor;
  135|  90.7k|    out_version.patch = (uint16_t)patch;
  136|  90.7k|    return out_version;
  137|  90.7k|}
loader_check_version_meets_required:
  140|  96.4k|bool loader_check_version_meets_required(loader_api_version required, loader_api_version version) {
  141|       |    // major version is satisfied
  142|  96.4k|    return (version.major > required.major) ||
  ------------------
  |  Branch (142:12): [True: 65.5k, False: 30.8k]
  ------------------
  143|       |           // major version is equal, minor version is patch version is greater to minimum minor
  144|  30.8k|           (version.major == required.major && version.minor > required.minor) ||
  ------------------
  |  Branch (144:13): [True: 11.9k, False: 18.9k]
  |  Branch (144:48): [True: 2.43k, False: 9.49k]
  ------------------
  145|       |           // major and minor version are equal, patch version is greater or equal to minimum patch
  146|  28.4k|           (version.major == required.major && version.minor == required.minor && version.patch >= required.patch);
  ------------------
  |  Branch (146:13): [True: 9.49k, False: 18.9k]
  |  Branch (146:48): [True: 6.67k, False: 2.82k]
  |  Branch (146:83): [True: 6.08k, False: 585]
  ------------------
  147|  96.4k|}
loader_opendir:
  172|  72.3k|DIR *loader_opendir(const struct loader_instance *instance, const char *name) {
  173|       |#if defined(_WIN32)
  174|       |    return opendir(instance ? &instance->alloc_callbacks : NULL, name);
  175|       |#elif COMMON_UNIX_PLATFORMS
  176|       |    (void)instance;
  177|  72.3k|    return opendir(name);
  178|       |#else
  179|       |#warning dirent.h - opendir not available on this platform
  180|       |#endif  // _WIN32
  181|  72.3k|}
loader_closedir:
  182|  5.50k|int loader_closedir(const struct loader_instance *instance, DIR *dir) {
  183|       |#if defined(_WIN32)
  184|       |    return closedir(instance ? &instance->alloc_callbacks : NULL, dir);
  185|       |#elif COMMON_UNIX_PLATFORMS
  186|       |    (void)instance;
  187|  5.50k|    return closedir(dir);
  188|       |#else
  189|       |#warning dirent.h - closedir not available on this platform
  190|       |#endif  // _WIN32
  191|  5.50k|}
is_json:
  193|   202k|bool is_json(const char *path, size_t len) {
  194|   202k|    if (len < 5) {
  ------------------
  |  Branch (194:9): [True: 24.3k, False: 177k]
  ------------------
  195|  24.3k|        return false;
  196|  24.3k|    }
  197|   177k|    return !strncmp(path + len - 5, ".json", 5);
  198|   202k|}
loader_free_layer_properties:
  248|   328k|void loader_free_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *layer_properties) {
  249|   328k|    loader_instance_heap_free(inst, layer_properties->manifest_file_name);
  250|   328k|    loader_instance_heap_free(inst, layer_properties->lib_name);
  251|   328k|    loader_instance_heap_free(inst, layer_properties->functions.str_gipa);
  252|   328k|    loader_instance_heap_free(inst, layer_properties->functions.str_gdpa);
  253|   328k|    loader_instance_heap_free(inst, layer_properties->functions.str_negotiate_interface);
  254|   328k|    loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_properties->instance_extension_list);
  255|   328k|    if (layer_properties->device_extension_list.capacity > 0 && NULL != layer_properties->device_extension_list.list) {
  ------------------
  |  Branch (255:9): [True: 2.77k, False: 325k]
  |  Branch (255:65): [True: 2.77k, False: 0]
  ------------------
  256|  16.5k|        for (uint32_t i = 0; i < layer_properties->device_extension_list.count; i++) {
  ------------------
  |  Branch (256:30): [True: 13.7k, False: 2.77k]
  ------------------
  257|  13.7k|            free_string_list(inst, &layer_properties->device_extension_list.list[i].entrypoints);
  258|  13.7k|        }
  259|  2.77k|    }
  260|   328k|    loader_destroy_generic_list(inst, (struct loader_generic_list *)&layer_properties->device_extension_list);
  261|   328k|    loader_instance_heap_free(inst, layer_properties->disable_env_var.name);
  262|   328k|    loader_instance_heap_free(inst, layer_properties->disable_env_var.value);
  263|   328k|    loader_instance_heap_free(inst, layer_properties->enable_env_var.name);
  264|   328k|    loader_instance_heap_free(inst, layer_properties->enable_env_var.value);
  265|   328k|    free_string_list(inst, &layer_properties->component_layer_names);
  266|   328k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_extension_properties);
  267|   328k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_layer_properties);
  268|   328k|    loader_instance_heap_free(inst, layer_properties->pre_instance_functions.enumerate_instance_version);
  269|   328k|    free_string_list(inst, &layer_properties->override_paths);
  270|   328k|    free_string_list(inst, &layer_properties->blacklist_layer_names);
  271|   328k|    free_string_list(inst, &layer_properties->app_key_paths);
  272|       |
  273|       |    // Make sure to clear out the removed layer, in case new layers are added in the previous location
  274|   328k|    memset(layer_properties, 0, sizeof(struct loader_layer_properties));
  275|   328k|}
is_string_in_string_list:
  288|  86.0k|bool is_string_in_string_list(struct loader_string_list *string_list, const char *str) {
  289|       |    // Remove duplicate paths, or it would result in duplicate extensions, duplicate devices, etc.
  290|   629k|    for (size_t i = 0; i < string_list->count; i++) {
  ------------------
  |  Branch (290:24): [True: 553k, False: 76.1k]
  ------------------
  291|   553k|        if (strcmp(string_list->list[i], str) == 0) {
  ------------------
  |  Branch (291:13): [True: 9.86k, False: 543k]
  ------------------
  292|  9.86k|            return true;
  293|  9.86k|        }
  294|   553k|    }
  295|  76.1k|    return false;
  296|  86.0k|}
loader_copy_to_new_str:
  298|   324k|VkResult loader_copy_to_new_str(const struct loader_instance *inst, const char *source_str, char **dest_str) {
  299|   324k|    assert(source_str && dest_str);
  300|   324k|    size_t str_len = strlen(source_str) + 1;
  301|   324k|    *dest_str = loader_instance_heap_calloc(inst, str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  302|   324k|    if (NULL == *dest_str) return VK_ERROR_OUT_OF_HOST_MEMORY;
  ------------------
  |  Branch (302:9): [True: 0, False: 324k]
  ------------------
  303|   324k|    loader_strncpy(*dest_str, str_len, source_str, str_len);
  304|   324k|    (*dest_str)[str_len - 1] = 0;
  305|   324k|    return VK_SUCCESS;
  306|   324k|}
create_string_list:
  308|  53.8k|VkResult create_string_list(const struct loader_instance *inst, uint32_t allocated_count, struct loader_string_list *string_list) {
  309|  53.8k|    assert(string_list);
  310|  53.8k|    string_list->list =
  311|  53.8k|        (char **)loader_instance_heap_calloc(inst, sizeof(char *) * allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  312|  53.8k|    if (NULL == string_list->list) {
  ------------------
  |  Branch (312:9): [True: 0, False: 53.8k]
  ------------------
  313|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  314|      0|    }
  315|  53.8k|    string_list->allocated_count = allocated_count;
  316|  53.8k|    string_list->count = 0;
  317|  53.8k|    return VK_SUCCESS;
  318|  53.8k|}
increase_str_capacity_by_at_least_one:
  320|   206k|VkResult increase_str_capacity_by_at_least_one(const struct loader_instance *inst, struct loader_string_list *string_list) {
  321|   206k|    assert(string_list);
  322|   206k|    if (string_list->allocated_count == 0) {
  ------------------
  |  Branch (322:9): [True: 14.8k, False: 192k]
  ------------------
  323|  14.8k|        string_list->allocated_count = 32;
  324|  14.8k|        string_list->list = (char **)loader_instance_heap_calloc(inst, sizeof(char *) * string_list->allocated_count,
  325|  14.8k|                                                                 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  326|  14.8k|        if (NULL == string_list->list) {
  ------------------
  |  Branch (326:13): [True: 0, False: 14.8k]
  ------------------
  327|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  328|      0|        }
  329|   192k|    } else if (string_list->count + 1 > string_list->allocated_count) {
  ------------------
  |  Branch (329:16): [True: 103, False: 191k]
  ------------------
  330|    103|        uint32_t new_allocated_count = string_list->allocated_count * 2;
  331|    103|        void *new_ptr = loader_instance_heap_realloc(inst, (void *)string_list->list, sizeof(char *) * string_list->allocated_count,
  332|    103|                                                     sizeof(char *) * new_allocated_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  333|    103|        if (NULL == new_ptr) {
  ------------------
  |  Branch (333:13): [True: 0, False: 103]
  ------------------
  334|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  335|      0|        }
  336|    103|        string_list->list = (char **)new_ptr;
  337|    103|        string_list->allocated_count *= 2;
  338|    103|    }
  339|   206k|    return VK_SUCCESS;
  340|   206k|}
append_str_to_string_list:
  342|   206k|VkResult append_str_to_string_list(const struct loader_instance *inst, struct loader_string_list *string_list, char *str) {
  343|   206k|    assert(string_list && str);
  344|   206k|    VkResult res = increase_str_capacity_by_at_least_one(inst, string_list);
  345|   206k|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (345:9): [True: 0, False: 206k]
  ------------------
  346|      0|        loader_instance_heap_free(inst, str);  // Must clean up in case of failure
  347|      0|        return res;
  348|      0|    }
  349|   206k|    string_list->list[string_list->count++] = str;
  350|   206k|    return VK_SUCCESS;
  351|   206k|}
append_str_to_string_list_if_unique:
  354|  86.0k|                                             char *str) {
  355|  86.0k|    if (is_string_in_string_list(string_list, str)) {
  ------------------
  |  Branch (355:9): [True: 9.86k, False: 76.1k]
  ------------------
  356|       |        // Since this string is a duplicate and this function takes ownership, we need to free it.
  357|  9.86k|        loader_instance_heap_free(inst, str);
  358|  9.86k|        return VK_SUCCESS;
  359|  9.86k|    }
  360|  76.1k|    return append_str_to_string_list(inst, string_list, str);
  361|  86.0k|}
copy_str_to_string_list:
  379|  7.78k|                                 size_t str_len) {
  380|  7.78k|    assert(string_list && str);
  381|  7.78k|    char *new_str = loader_instance_heap_calloc(inst, str_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  382|  7.78k|    if (NULL == new_str) {
  ------------------
  |  Branch (382:9): [True: 0, False: 7.78k]
  ------------------
  383|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  384|      0|    }
  385|  7.78k|    loader_strncpy(new_str, str_len + 1, str, str_len);
  386|  7.78k|    new_str[str_len] = '\0';
  387|  7.78k|    return append_str_to_string_list(inst, string_list, new_str);
  388|  7.78k|}
free_string_list:
  410|  1.37M|void free_string_list(const struct loader_instance *inst, struct loader_string_list *string_list) {
  411|  1.37M|    assert(string_list);
  412|  1.37M|    if (string_list->list) {
  ------------------
  |  Branch (412:9): [True: 68.6k, False: 1.30M]
  ------------------
  413|   275k|        for (uint32_t i = 0; i < string_list->count; i++) {
  ------------------
  |  Branch (413:30): [True: 206k, False: 68.6k]
  ------------------
  414|   206k|            loader_instance_heap_free(inst, string_list->list[i]);
  415|       |            string_list->list[i] = NULL;
  416|   206k|        }
  417|  68.6k|        loader_instance_heap_free(inst, (void *)string_list->list);
  418|  68.6k|    }
  419|  1.37M|    memset(string_list, 0, sizeof(struct loader_string_list));
  420|  1.37M|}
loader_parse_version_string:
  697|   187k|uint32_t loader_parse_version_string(char *vers_str) {
  698|   187k|    uint32_t variant = 0;
  699|   187k|    uint32_t major = 0;
  700|   187k|    uint32_t minor = 0;
  701|   187k|    uint32_t patch = 0;
  702|   187k|    char *vers_tok;
  703|   187k|    char *context = NULL;
  704|   187k|    if (!vers_str) {
  ------------------
  |  Branch (704:9): [True: 0, False: 187k]
  ------------------
  705|      0|        return 0;
  706|      0|    }
  707|       |
  708|   187k|    vers_tok = thread_safe_strtok(vers_str, ".\"\n\r", &context);
  709|   187k|    if (NULL != vers_tok) {
  ------------------
  |  Branch (709:9): [True: 103k, False: 83.7k]
  ------------------
  710|   103k|        major = (uint16_t)strtoul(vers_tok, NULL, 10);
  711|   103k|        vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  712|   103k|        if (NULL != vers_tok) {
  ------------------
  |  Branch (712:13): [True: 55.6k, False: 47.9k]
  ------------------
  713|  55.6k|            minor = (uint16_t)strtoul(vers_tok, NULL, 10);
  714|  55.6k|            vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  715|  55.6k|            if (NULL != vers_tok) {
  ------------------
  |  Branch (715:17): [True: 51.0k, False: 4.58k]
  ------------------
  716|  51.0k|                patch = (uint16_t)strtoul(vers_tok, NULL, 10);
  717|  51.0k|                vers_tok = thread_safe_strtok(NULL, ".\"\n\r", &context);
  718|       |                // check that we are using a 4 part version string
  719|  51.0k|                if (NULL != vers_tok) {
  ------------------
  |  Branch (719:21): [True: 1.19k, False: 49.8k]
  ------------------
  720|       |                    // if we are, move the values over into the correct place
  721|  1.19k|                    variant = major;
  722|  1.19k|                    major = minor;
  723|  1.19k|                    minor = patch;
  724|  1.19k|                    patch = (uint16_t)strtoul(vers_tok, NULL, 10);
  725|  1.19k|                }
  726|  51.0k|            }
  727|  55.6k|        }
  728|   103k|    }
  729|       |
  730|       |    return VK_MAKE_API_VERSION(variant, major, minor, patch);
  731|   187k|}
compare_vk_extension_properties:
  733|   740k|bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2) {
  734|   740k|    return strcmp(op1->extensionName, op2->extensionName) == 0 ? true : false;
  ------------------
  |  Branch (734:12): [True: 5.53k, False: 734k]
  ------------------
  735|   740k|}
has_vk_extension_property:
  747|  22.9k|bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list) {
  748|   414k|    for (uint32_t i = 0; i < ext_list->count; i++) {
  ------------------
  |  Branch (748:26): [True: 393k, False: 21.0k]
  ------------------
  749|   393k|        if (compare_vk_extension_properties(&ext_list->list[i], vk_ext_prop)) return true;
  ------------------
  |  Branch (749:13): [True: 1.96k, False: 391k]
  ------------------
  750|   393k|    }
  751|  21.0k|    return false;
  752|  22.9k|}
has_vk_dev_ext_property:
  755|  21.3k|bool has_vk_dev_ext_property(const VkExtensionProperties *ext_prop, const struct loader_device_extension_list *ext_list) {
  756|   364k|    for (uint32_t i = 0; i < ext_list->count; i++) {
  ------------------
  |  Branch (756:26): [True: 346k, False: 17.7k]
  ------------------
  757|   346k|        if (compare_vk_extension_properties(&ext_list->list[i].props, ext_prop)) return true;
  ------------------
  |  Branch (757:13): [True: 3.57k, False: 343k]
  ------------------
  758|   346k|    }
  759|  17.7k|    return false;
  760|  21.3k|}
loader_append_layer_property:
  763|   139k|                                      struct loader_layer_properties *layer_property) {
  764|   139k|    VkResult res = VK_SUCCESS;
  765|   139k|    if (layer_list->capacity == 0) {
  ------------------
  |  Branch (765:9): [True: 3.55k, False: 135k]
  ------------------
  766|  3.55k|        res = loader_init_generic_list(inst, (struct loader_generic_list *)layer_list, sizeof(struct loader_layer_properties));
  767|  3.55k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (767:13): [True: 0, False: 3.55k]
  ------------------
  768|      0|            goto out;
  769|      0|        }
  770|  3.55k|    }
  771|       |
  772|       |    // Ensure enough room to add an entry
  773|   139k|    if ((layer_list->count + 1) * sizeof(struct loader_layer_properties) > layer_list->capacity) {
  ------------------
  |  Branch (773:9): [True: 603, False: 138k]
  ------------------
  774|    603|        void *new_ptr = loader_instance_heap_realloc(inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2,
  775|    603|                                                     VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  776|    603|        if (NULL == new_ptr) {
  ------------------
  |  Branch (776:13): [True: 0, False: 603]
  ------------------
  777|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_append_layer_property: realloc failed for layer list");
  778|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  779|      0|            goto out;
  780|      0|        }
  781|    603|        layer_list->list = new_ptr;
  782|    603|        layer_list->capacity *= 2;
  783|    603|    }
  784|   139k|    memcpy(&layer_list->list[layer_list->count], layer_property, sizeof(struct loader_layer_properties));
  785|   139k|    layer_list->count++;
  786|   139k|    memset(layer_property, 0, sizeof(struct loader_layer_properties));
  787|   139k|out:
  788|   139k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (788:9): [True: 0, False: 139k]
  ------------------
  789|      0|        loader_free_layer_properties(inst, layer_property);
  790|      0|    }
  791|   139k|    return res;
  792|   139k|}
loader_find_layer_property:
  795|  16.8k|struct loader_layer_properties *loader_find_layer_property(const char *name, const struct loader_layer_list *layer_list) {
  796|  1.13M|    for (uint32_t i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (796:26): [True: 1.12M, False: 8.85k]
  ------------------
  797|  1.12M|        const VkLayerProperties *item = &layer_list->list[i].info;
  798|  1.12M|        if (strcmp(name, item->layerName) == 0) return &layer_list->list[i];
  ------------------
  |  Branch (798:13): [True: 7.95k, False: 1.11M]
  ------------------
  799|  1.12M|    }
  800|  8.85k|    return NULL;
  801|  16.8k|}
loader_find_layer_name_in_blacklist:
  824|  13.3k|bool loader_find_layer_name_in_blacklist(const char *layer_name, struct loader_layer_properties *meta_layer_props) {
  825|  13.3k|    for (uint32_t black_layer = 0; black_layer < meta_layer_props->blacklist_layer_names.count; ++black_layer) {
  ------------------
  |  Branch (825:36): [True: 0, False: 13.3k]
  ------------------
  826|      0|        if (!strcmp(meta_layer_props->blacklist_layer_names.list[black_layer], layer_name)) {
  ------------------
  |  Branch (826:13): [True: 0, False: 0]
  ------------------
  827|      0|            return true;
  828|      0|        }
  829|      0|    }
  830|  13.3k|    return false;
  831|  13.3k|}
loader_delete_layer_list_and_properties:
  835|  20.5k|                                                                  struct loader_layer_list *layer_list) {
  836|  20.5k|    uint32_t i;
  837|  20.5k|    if (!layer_list) return;
  ------------------
  |  Branch (837:9): [True: 0, False: 20.5k]
  ------------------
  838|       |
  839|   136k|    for (i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (839:17): [True: 115k, False: 20.5k]
  ------------------
  840|   115k|        if (layer_list->list[i].lib_handle) {
  ------------------
  |  Branch (840:13): [True: 0, False: 115k]
  ------------------
  841|      0|            loader_platform_close_library(layer_list->list[i].lib_handle);
  842|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Unloading layer library %s",
  843|      0|                       layer_list->list[i].lib_name);
  844|      0|            layer_list->list[i].lib_handle = NULL;
  845|      0|        }
  846|   115k|        loader_free_layer_properties(inst, &(layer_list->list[i]));
  847|   115k|    }
  848|  20.5k|    layer_list->count = 0;
  849|       |
  850|  20.5k|    if (layer_list->capacity > 0) {
  ------------------
  |  Branch (850:9): [True: 3.98k, False: 16.5k]
  ------------------
  851|  3.98k|        layer_list->capacity = 0;
  852|  3.98k|        loader_instance_heap_free(inst, layer_list->list);
  853|  3.98k|    }
  854|  20.5k|    memset(layer_list, 0, sizeof(struct loader_layer_list));
  855|  20.5k|}
loader_remove_layer_in_list:
  858|  23.2k|                                 uint32_t layer_to_remove) {
  859|  23.2k|    if (layer_list == NULL || layer_to_remove >= layer_list->count) {
  ------------------
  |  Branch (859:9): [True: 0, False: 23.2k]
  |  Branch (859:31): [True: 0, False: 23.2k]
  ------------------
  860|      0|        return;
  861|      0|    }
  862|  23.2k|    loader_free_layer_properties(inst, &(layer_list->list[layer_to_remove]));
  863|       |
  864|       |    // Remove the current invalid meta-layer from the layer list.  Use memmove since we are
  865|       |    // overlapping the source and destination addresses.
  866|  23.2k|    if (layer_to_remove + 1 <= layer_list->count) {
  ------------------
  |  Branch (866:9): [True: 23.2k, False: 0]
  ------------------
  867|  23.2k|        memmove(&layer_list->list[layer_to_remove], &layer_list->list[layer_to_remove + 1],
  868|  23.2k|                sizeof(struct loader_layer_properties) * (layer_list->count - 1 - layer_to_remove));
  869|  23.2k|    }
  870|       |    // Decrement the count (because we now have one less) and decrement the loop index since we need to
  871|       |    // re-check this index.
  872|  23.2k|    layer_list->count--;
  873|  23.2k|}
loader_remove_layers_in_blacklist:
  877|    365|void loader_remove_layers_in_blacklist(const struct loader_instance *inst, struct loader_layer_list *layer_list) {
  878|    365|    struct loader_layer_properties *override_prop = loader_find_layer_property(VK_OVERRIDE_LAYER_NAME, layer_list);
  ------------------
  |  |  142|    365|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  879|    365|    if (NULL == override_prop) {
  ------------------
  |  Branch (879:9): [True: 0, False: 365]
  ------------------
  880|      0|        return;
  881|      0|    }
  882|       |
  883|  15.0k|    for (int32_t j = 0; j < (int32_t)(layer_list->count); j++) {
  ------------------
  |  Branch (883:25): [True: 14.6k, False: 365]
  ------------------
  884|  14.6k|        struct loader_layer_properties cur_layer_prop = layer_list->list[j];
  885|  14.6k|        const char *cur_layer_name = &cur_layer_prop.info.layerName[0];
  886|       |
  887|       |        // Skip the override layer itself.
  888|  14.6k|        if (!strcmp(VK_OVERRIDE_LAYER_NAME, cur_layer_name)) {
  ------------------
  |  |  142|  14.6k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (888:13): [True: 1.28k, False: 13.3k]
  ------------------
  889|  1.28k|            continue;
  890|  1.28k|        }
  891|       |
  892|       |        // If found in the override layer's blacklist, remove it
  893|  13.3k|        if (loader_find_layer_name_in_blacklist(cur_layer_name, override_prop)) {
  ------------------
  |  Branch (893:13): [True: 0, False: 13.3k]
  ------------------
  894|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  895|      0|                       "loader_remove_layers_in_blacklist: Override layer is active and layer %s is in the blacklist inside of it. "
  896|      0|                       "Removing that layer from current layer list.",
  897|      0|                       cur_layer_name);
  898|      0|            loader_remove_layer_in_list(inst, layer_list, j);
  899|      0|            j--;
  900|       |
  901|       |            // Re-do the query for the override layer
  902|      0|            override_prop = loader_find_layer_property(VK_OVERRIDE_LAYER_NAME, layer_list);
  ------------------
  |  |  142|      0|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  903|      0|        }
  904|  13.3k|    }
  905|    365|}
loader_init_generic_list:
 1062|  8.20k|VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size) {
 1063|  8.20k|    size_t capacity = 32 * element_size;
 1064|  8.20k|    list_info->count = 0;
 1065|  8.20k|    list_info->capacity = 0;
 1066|  8.20k|    list_info->list = loader_instance_heap_calloc(inst, capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1067|  8.20k|    if (list_info->list == NULL) {
  ------------------
  |  Branch (1067:9): [True: 0, False: 8.20k]
  ------------------
 1068|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_init_generic_list: Failed to allocate space for generic list");
 1069|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
 1070|      0|    }
 1071|  8.20k|    list_info->capacity = capacity;
 1072|  8.20k|    return VK_SUCCESS;
 1073|  8.20k|}
loader_destroy_generic_list:
 1091|   683k|void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list) {
 1092|   683k|    loader_instance_heap_free(inst, list->list);
 1093|   683k|    memset(list, 0, sizeof(struct loader_generic_list));
 1094|   683k|}
loader_add_to_ext_list:
 1147|  20.9k|                                uint32_t prop_list_count, const VkExtensionProperties *props) {
 1148|  20.9k|    if (ext_list->list == NULL || ext_list->capacity == 0) {
  ------------------
  |  Branch (1148:9): [True: 1.44k, False: 19.5k]
  |  Branch (1148:35): [True: 0, False: 19.5k]
  ------------------
 1149|  1.44k|        VkResult res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(VkExtensionProperties));
 1150|  1.44k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1150:13): [True: 0, False: 1.44k]
  ------------------
 1151|      0|            return res;
 1152|      0|        }
 1153|  1.44k|    }
 1154|       |
 1155|  41.8k|    for (uint32_t i = 0; i < prop_list_count; i++) {
  ------------------
  |  Branch (1155:26): [True: 20.9k, False: 20.9k]
  ------------------
 1156|  20.9k|        const VkExtensionProperties *cur_ext = &props[i];
 1157|       |
 1158|       |        // look for duplicates
 1159|  20.9k|        if (has_vk_extension_property(cur_ext, ext_list)) {
  ------------------
  |  Branch (1159:13): [True: 1.84k, False: 19.1k]
  ------------------
 1160|  1.84k|            continue;
 1161|  1.84k|        }
 1162|       |
 1163|       |        // add to list at end
 1164|       |        // check for enough capacity
 1165|  19.1k|        if (ext_list->count * sizeof(VkExtensionProperties) >= ext_list->capacity) {
  ------------------
  |  Branch (1165:13): [True: 446, False: 18.6k]
  ------------------
 1166|    446|            void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
 1167|    446|                                                         VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1168|    446|            if (new_ptr == NULL) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 446]
  ------------------
 1169|      0|                loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1170|      0|                           "loader_add_to_ext_list: Failed to reallocate space for extension list");
 1171|      0|                return VK_ERROR_OUT_OF_HOST_MEMORY;
 1172|      0|            }
 1173|    446|            ext_list->list = new_ptr;
 1174|       |
 1175|       |            // double capacity
 1176|    446|            ext_list->capacity *= 2;
 1177|    446|        }
 1178|       |
 1179|       |        // every caller passes the address of an array element or on-stack struct, never NULL
 1180|       |        // NOLINTNEXTLINE(clang-analyzer-core.NonNullParamChecker)
 1181|  19.1k|        memcpy(&ext_list->list[ext_list->count], cur_ext, sizeof(VkExtensionProperties));
 1182|  19.1k|        ext_list->count++;
 1183|  19.1k|    }
 1184|  20.9k|    return VK_SUCCESS;
 1185|  20.9k|}
loader_add_to_dev_ext_list:
 1192|  16.5k|                                    const VkExtensionProperties *props, struct loader_string_list *entrys) {
 1193|  16.5k|    VkResult res = VK_SUCCESS;
 1194|  16.5k|    bool should_free_entrys = true;
 1195|  16.5k|    if (ext_list->list == NULL || ext_list->capacity == 0) {
  ------------------
  |  Branch (1195:9): [True: 2.77k, False: 13.7k]
  |  Branch (1195:35): [True: 0, False: 13.7k]
  ------------------
 1196|  2.77k|        res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, sizeof(struct loader_dev_ext_props));
 1197|  2.77k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1197:13): [True: 0, False: 2.77k]
  ------------------
 1198|      0|            goto out;
 1199|      0|        }
 1200|  2.77k|    }
 1201|       |
 1202|       |    // look for duplicates
 1203|  16.5k|    if (has_vk_dev_ext_property(props, ext_list)) {
  ------------------
  |  Branch (1203:9): [True: 2.76k, False: 13.7k]
  ------------------
 1204|  2.76k|        goto out;
 1205|  2.76k|    }
 1206|       |
 1207|  13.7k|    uint32_t idx = ext_list->count;
 1208|       |    // add to list at end
 1209|       |    // check for enough capacity
 1210|  13.7k|    if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) {
  ------------------
  |  Branch (1210:9): [True: 208, False: 13.5k]
  ------------------
 1211|    208|        void *new_ptr = loader_instance_heap_realloc(inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2,
 1212|    208|                                                     VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1213|       |
 1214|    208|        if (NULL == new_ptr) {
  ------------------
  |  Branch (1214:13): [True: 0, False: 208]
  ------------------
 1215|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1216|      0|                       "loader_add_to_dev_ext_list: Failed to reallocate space for device extension list");
 1217|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1218|      0|            goto out;
 1219|      0|        }
 1220|    208|        ext_list->list = new_ptr;
 1221|       |
 1222|       |        // double capacity
 1223|    208|        ext_list->capacity *= 2;
 1224|    208|    }
 1225|       |
 1226|       |    // every caller passes the address of an array element or on-stack struct, never NULL
 1227|       |    // NOLINTNEXTLINE(clang-analyzer-core.NonNullParamChecker)
 1228|  13.7k|    memcpy(&ext_list->list[idx].props, props, sizeof(*props));
 1229|  13.7k|    if (entrys) {
  ------------------
  |  Branch (1229:9): [True: 1.57k, False: 12.1k]
  ------------------
 1230|  1.57k|        ext_list->list[idx].entrypoints = *entrys;
 1231|  1.57k|        should_free_entrys = false;
 1232|  12.1k|    } else {
 1233|  12.1k|        memset(&ext_list->list[idx].entrypoints, 0, sizeof(ext_list->list[idx].entrypoints));
 1234|  12.1k|    }
 1235|  13.7k|    ext_list->count++;
 1236|  16.5k|out:
 1237|  16.5k|    if (NULL != entrys && should_free_entrys) {
  ------------------
  |  Branch (1237:9): [True: 2.66k, False: 13.8k]
  |  Branch (1237:27): [True: 1.08k, False: 1.57k]
  ------------------
 1238|  1.08k|        free_string_list(inst, entrys);
 1239|  1.08k|    }
 1240|  16.5k|    return res;
 1241|  13.7k|}
loader_destroy_pointer_layer_list:
 1266|  13.7k|void loader_destroy_pointer_layer_list(const struct loader_instance *inst, struct loader_pointer_layer_list *layer_list) {
 1267|  13.7k|    loader_instance_heap_free(inst, (void *)layer_list->list);
 1268|  13.7k|    memset(layer_list, 0, sizeof(struct loader_pointer_layer_list));
 1269|  13.7k|}
loader_layer_is_available:
 1300|  17.3k|                               const struct loader_layer_properties *prop) {
 1301|  17.3k|    bool available = true;
 1302|  17.3k|    bool is_implicit = (0 == (prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER));
 1303|  17.3k|    bool disabled_by_type =
 1304|  17.3k|        is_implicit ? filters->disable_filter.disable_all_implicit : filters->disable_filter.disable_all_explicit;
  ------------------
  |  Branch (1304:9): [True: 7.66k, False: 9.66k]
  ------------------
 1305|  17.3k|    if ((filters->disable_filter.disable_all || disabled_by_type ||
  ------------------
  |  Branch (1305:10): [True: 0, False: 17.3k]
  |  Branch (1305:49): [True: 0, False: 17.3k]
  ------------------
 1306|  17.3k|         check_name_matches_filter_environment_var(prop->info.layerName, &filters->disable_filter.additional_filters)) &&
  ------------------
  |  Branch (1306:10): [True: 0, False: 17.3k]
  ------------------
 1307|      0|        !check_name_matches_filter_environment_var(prop->info.layerName, &filters->allow_filter)) {
  ------------------
  |  Branch (1307:9): [True: 0, False: 0]
  ------------------
 1308|      0|        available = false;
 1309|      0|    }
 1310|  17.3k|    if (check_name_matches_filter_environment_var(prop->info.layerName, &filters->enable_filter)) {
  ------------------
  |  Branch (1310:9): [True: 151, False: 17.1k]
  ------------------
 1311|    151|        available = true;
 1312|  17.1k|    } else if (!available) {
  ------------------
  |  Branch (1312:16): [True: 0, False: 17.1k]
  ------------------
 1313|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1314|      0|                   "Layer \"%s\" forced disabled because name matches filter of env var \'%s\'.", prop->info.layerName,
 1315|      0|                   VK_LAYERS_DISABLE_ENV_VAR);
  ------------------
  |  |  120|      0|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
 1316|      0|    }
 1317|       |
 1318|  17.3k|    return available;
 1319|  17.3k|}
loader_implicit_layer_is_enabled:
 1368|  1.70k|                                      const struct loader_layer_properties *prop) {
 1369|  1.70k|    bool enable = false;
 1370|  1.70k|    bool forced_disabled = false;
 1371|  1.70k|    bool forced_enabled = false;
 1372|       |
 1373|  1.70k|    if ((filters->disable_filter.disable_all || filters->disable_filter.disable_all_implicit ||
  ------------------
  |  Branch (1373:10): [True: 0, False: 1.70k]
  |  Branch (1373:49): [True: 0, False: 1.70k]
  ------------------
 1374|  1.70k|         check_name_matches_filter_environment_var(prop->info.layerName, &filters->disable_filter.additional_filters)) &&
  ------------------
  |  Branch (1374:10): [True: 0, False: 1.70k]
  ------------------
 1375|      0|        !check_name_matches_filter_environment_var(prop->info.layerName, &filters->allow_filter)) {
  ------------------
  |  Branch (1375:9): [True: 0, False: 0]
  ------------------
 1376|      0|        forced_disabled = true;
 1377|      0|    }
 1378|  1.70k|    if (check_name_matches_filter_environment_var(prop->info.layerName, &filters->enable_filter)) {
  ------------------
  |  Branch (1378:9): [True: 0, False: 1.70k]
  ------------------
 1379|      0|        forced_enabled = true;
 1380|      0|    }
 1381|       |
 1382|       |    // If no enable_environment variable is specified, this implicit layer is always be enabled by default.
 1383|  1.70k|    if (NULL == prop->enable_env_var.name) {
  ------------------
  |  Branch (1383:9): [True: 1.58k, False: 117]
  ------------------
 1384|  1.58k|        enable = true;
 1385|  1.58k|    } else {
 1386|    117|        char *env_value = loader_getenv(prop->enable_env_var.name, inst);
 1387|    117|        if (env_value && !strcmp(prop->enable_env_var.value, env_value)) {
  ------------------
  |  Branch (1387:13): [True: 110, False: 7]
  |  Branch (1387:26): [True: 0, False: 110]
  ------------------
 1388|      0|            enable = true;
 1389|      0|        }
 1390|       |
 1391|       |        // Otherwise, only enable this layer if the enable environment variable is defined
 1392|    117|        loader_free_getenv(env_value, inst);
 1393|    117|    }
 1394|       |
 1395|  1.70k|    if (forced_enabled) {
  ------------------
  |  Branch (1395:9): [True: 0, False: 1.70k]
  ------------------
 1396|       |        // Only report a message that we've forced on a layer if it wouldn't have been enabled
 1397|       |        // normally.
 1398|      0|        if (!enable) {
  ------------------
  |  Branch (1398:13): [True: 0, False: 0]
  ------------------
 1399|      0|            enable = true;
 1400|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1401|      0|                       "Implicit layer \"%s\" forced enabled due to env var \'%s\'.", prop->info.layerName,
 1402|      0|                       VK_LAYERS_ENABLE_ENV_VAR);
  ------------------
  |  |  119|      0|#define VK_LAYERS_ENABLE_ENV_VAR "VK_LOADER_LAYERS_ENABLE"
  ------------------
 1403|      0|        }
 1404|  1.70k|    } else if (enable && forced_disabled) {
  ------------------
  |  Branch (1404:16): [True: 1.58k, False: 117]
  |  Branch (1404:26): [True: 0, False: 1.58k]
  ------------------
 1405|      0|        enable = false;
 1406|       |        // Report a message that we've forced off a layer if it would have been enabled normally.
 1407|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1408|      0|                   "Implicit layer \"%s\" forced disabled because name matches filter of env var \'%s\'.", prop->info.layerName,
 1409|      0|                   VK_LAYERS_DISABLE_ENV_VAR);
  ------------------
  |  |  120|      0|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
 1410|      0|        return enable;
 1411|      0|    }
 1412|       |
 1413|       |    // The disable_environment has priority over everything else.  If it is defined, the layer is always
 1414|       |    // disabled.
 1415|  1.70k|    if (NULL != prop->disable_env_var.name) {
  ------------------
  |  Branch (1415:9): [True: 870, False: 830]
  ------------------
 1416|    870|        char *env_value = loader_getenv(prop->disable_env_var.name, inst);
 1417|    870|        if (NULL != env_value) {
  ------------------
  |  Branch (1417:13): [True: 11, False: 859]
  ------------------
 1418|     11|            enable = false;
 1419|     11|        }
 1420|    870|        loader_free_getenv(env_value, inst);
 1421|    870|    } else if ((prop->type_flags & VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER) == 0) {
  ------------------
  |  Branch (1421:16): [True: 0, False: 830]
  ------------------
 1422|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 1423|      0|                   "Implicit layer \"%s\" missing disabled environment variable!", prop->info.layerName);
 1424|      0|    }
 1425|       |
 1426|       |    // Enable this layer if it is included in the override layer
 1427|  1.70k|    if (inst != NULL && inst->override_layer_present) {
  ------------------
  |  Branch (1427:9): [True: 1.70k, False: 0]
  |  Branch (1427:25): [True: 0, False: 1.70k]
  ------------------
 1428|      0|        struct loader_layer_properties *override = NULL;
 1429|      0|        for (uint32_t i = 0; i < inst->instance_layer_list.count; ++i) {
  ------------------
  |  Branch (1429:30): [True: 0, False: 0]
  ------------------
 1430|      0|            if (strcmp(inst->instance_layer_list.list[i].info.layerName, VK_OVERRIDE_LAYER_NAME) == 0) {
  ------------------
  |  |  142|      0|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (1430:17): [True: 0, False: 0]
  ------------------
 1431|      0|                override = &inst->instance_layer_list.list[i];
 1432|      0|                break;
 1433|      0|            }
 1434|      0|        }
 1435|      0|        if (override != NULL) {
  ------------------
  |  Branch (1435:13): [True: 0, False: 0]
  ------------------
 1436|      0|            for (uint32_t i = 0; i < override->component_layer_names.count; ++i) {
  ------------------
  |  Branch (1436:34): [True: 0, False: 0]
  ------------------
 1437|      0|                if (strcmp(override->component_layer_names.list[i], prop->info.layerName) == 0) {
  ------------------
  |  Branch (1437:21): [True: 0, False: 0]
  ------------------
 1438|      0|                    enable = true;
 1439|      0|                    break;
 1440|      0|                }
 1441|      0|            }
 1442|      0|        }
 1443|      0|    }
 1444|       |
 1445|  1.70k|    return enable;
 1446|  1.70k|}
loader_clear_scanned_icd_list:
 1882|  6.86k|void loader_clear_scanned_icd_list(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) {
 1883|  6.86k|    if (0 != icd_tramp_list->capacity && icd_tramp_list->scanned_list) {
  ------------------
  |  Branch (1883:9): [True: 5, False: 6.85k]
  |  Branch (1883:42): [True: 5, False: 0]
  ------------------
 1884|      5|        for (uint32_t i = 0; i < icd_tramp_list->count; i++) {
  ------------------
  |  Branch (1884:30): [True: 0, False: 5]
  ------------------
 1885|      0|            if (icd_tramp_list->scanned_list[i].handle) {
  ------------------
  |  Branch (1885:17): [True: 0, False: 0]
  ------------------
 1886|      0|                loader_platform_close_library(icd_tramp_list->scanned_list[i].handle);
 1887|       |                icd_tramp_list->scanned_list[i].handle = NULL;
 1888|      0|            }
 1889|      0|            loader_instance_heap_free(inst, icd_tramp_list->scanned_list[i].lib_name);
 1890|      0|        }
 1891|      5|        loader_instance_heap_free(inst, icd_tramp_list->scanned_list);
 1892|      5|    }
 1893|  6.86k|    memset(icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list));
 1894|  6.86k|}
loader_init_scanned_icd_list:
 1896|      5|VkResult loader_init_scanned_icd_list(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list) {
 1897|      5|    VkResult res = VK_SUCCESS;
 1898|      5|    loader_clear_scanned_icd_list(inst, icd_tramp_list);
 1899|      5|    icd_tramp_list->capacity = 8 * sizeof(struct loader_scanned_icd);
 1900|      5|    icd_tramp_list->scanned_list = loader_instance_heap_alloc(inst, icd_tramp_list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 1901|      5|    if (NULL == icd_tramp_list->scanned_list) {
  ------------------
  |  Branch (1901:9): [True: 0, False: 5]
  ------------------
 1902|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 1903|      0|                   "loader_init_scanned_icd_list: Realloc failed for layer list when attempting to add new layer");
 1904|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1905|      0|    }
 1906|      5|    return res;
 1907|      5|}
loader_scan_for_direct_drivers:
 2045|      5|                                        struct loader_icd_tramp_list *icd_tramp_list, bool *direct_driver_loading_exclusive_mode) {
 2046|      5|    if (NULL == pCreateInfo) {
  ------------------
  |  Branch (2046:9): [True: 0, False: 5]
  ------------------
 2047|       |        // Don't do this logic unless we are being called from vkCreateInstance, when pCreateInfo will be non-null
 2048|      0|        return VK_SUCCESS;
 2049|      0|    }
 2050|      5|    bool direct_driver_loading_enabled = false;
 2051|       |    // Try to if VK_LUNARG_direct_driver_loading is enabled and if we are using it exclusively
 2052|       |    // Skip this step if inst is NULL, aka when this function is being called before instance creation
 2053|      5|    if (inst != NULL && pCreateInfo->ppEnabledExtensionNames && pCreateInfo->enabledExtensionCount > 0) {
  ------------------
  |  Branch (2053:9): [True: 5, False: 0]
  |  Branch (2053:25): [True: 0, False: 5]
  |  Branch (2053:65): [True: 0, False: 0]
  ------------------
 2054|       |        // Look through the enabled extension list, make sure VK_LUNARG_direct_driver_loading is present
 2055|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
  ------------------
  |  Branch (2055:30): [True: 0, False: 0]
  ------------------
 2056|      0|            if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME) == 0) {
  ------------------
  |  Branch (2056:17): [True: 0, False: 0]
  ------------------
 2057|      0|                direct_driver_loading_enabled = true;
 2058|      0|                break;
 2059|      0|            }
 2060|      0|        }
 2061|      0|    }
 2062|      5|    const VkDirectDriverLoadingListLUNARG *ddl_list = NULL;
 2063|       |    // Find the VkDirectDriverLoadingListLUNARG struct in the pNext chain of vkInstanceCreateInfo
 2064|      5|    const void *pNext = pCreateInfo->pNext;
 2065|      5|    while (pNext) {
  ------------------
  |  Branch (2065:12): [True: 0, False: 5]
  ------------------
 2066|      0|        VkBaseInStructure out_structure = {0};
 2067|      0|        memcpy(&out_structure, pNext, sizeof(VkBaseInStructure));
 2068|      0|        if (out_structure.sType == VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG) {
  ------------------
  |  Branch (2068:13): [True: 0, False: 0]
  ------------------
 2069|      0|            ddl_list = (VkDirectDriverLoadingListLUNARG *)pNext;
 2070|      0|            break;
 2071|      0|        }
 2072|      0|        pNext = out_structure.pNext;
 2073|      0|    }
 2074|      5|    if (NULL == ddl_list) {
  ------------------
  |  Branch (2074:9): [True: 5, False: 0]
  ------------------
 2075|      5|        if (direct_driver_loading_enabled) {
  ------------------
  |  Branch (2075:13): [True: 0, False: 5]
  ------------------
 2076|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2077|      0|                       "loader_scan_for_direct_drivers: The VK_LUNARG_direct_driver_loading extension was enabled but the "
 2078|      0|                       "pNext chain of "
 2079|      0|                       "VkInstanceCreateInfo did not contain the "
 2080|      0|                       "VkDirectDriverLoadingListLUNARG structure.");
 2081|      0|        }
 2082|       |        // Always want to exit early if there was no VkDirectDriverLoadingListLUNARG in the pNext chain
 2083|      5|        return VK_SUCCESS;
 2084|      5|    }
 2085|       |
 2086|      0|    if (!direct_driver_loading_enabled) {
  ------------------
  |  Branch (2086:9): [True: 0, False: 0]
  ------------------
 2087|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2088|      0|                   "loader_scan_for_direct_drivers: The pNext chain of VkInstanceCreateInfo contained the "
 2089|      0|                   "VkDirectDriverLoadingListLUNARG structure, but the VK_LUNARG_direct_driver_loading extension was "
 2090|      0|                   "not enabled.");
 2091|      0|        return VK_SUCCESS;
 2092|      0|    }
 2093|       |    // If we are using exclusive mode, skip looking for any more drivers from system or environment variables
 2094|      0|    if (ddl_list->mode == VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG) {
  ------------------
  |  Branch (2094:9): [True: 0, False: 0]
  ------------------
 2095|      0|        *direct_driver_loading_exclusive_mode = true;
 2096|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2097|      0|                   "loader_scan_for_direct_drivers: The VK_LUNARG_direct_driver_loading extension is active and specified "
 2098|      0|                   "VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG, skipping system and environment "
 2099|      0|                   "variable driver search mechanisms.");
 2100|      0|    }
 2101|      0|    if (NULL == ddl_list->pDrivers) {
  ------------------
  |  Branch (2101:9): [True: 0, False: 0]
  ------------------
 2102|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2103|      0|                   "loader_scan_for_direct_drivers: The VkDirectDriverLoadingListLUNARG structure in the pNext chain of "
 2104|      0|                   "VkInstanceCreateInfo has a NULL pDrivers member.");
 2105|      0|        return VK_SUCCESS;
 2106|      0|    }
 2107|      0|    if (ddl_list->driverCount == 0) {
  ------------------
  |  Branch (2107:9): [True: 0, False: 0]
  ------------------
 2108|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 2109|      0|                   "loader_scan_for_direct_drivers: The VkDirectDriverLoadingListLUNARG structure in the pNext chain of "
 2110|      0|                   "VkInstanceCreateInfo has a non-null pDrivers member but a driverCount member with a value "
 2111|      0|                   "of zero.");
 2112|      0|        return VK_SUCCESS;
 2113|      0|    }
 2114|       |    // Go through all VkDirectDriverLoadingInfoLUNARG entries and add each driver
 2115|       |    // Because icd_tramp's are prepended, this will result in the drivers appearing at the end
 2116|      0|    for (uint32_t i = 0; i < ddl_list->driverCount; i++) {
  ------------------
  |  Branch (2116:26): [True: 0, False: 0]
  ------------------
 2117|      0|        VkResult res = loader_add_direct_driver(inst, i, &ddl_list->pDrivers[i], icd_tramp_list);
 2118|      0|        if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2118:13): [True: 0, False: 0]
  ------------------
 2119|      0|            return res;
 2120|      0|        }
 2121|      0|    }
 2122|       |
 2123|      0|    return VK_SUCCESS;
 2124|      0|}
loader_initialize:
 2356|      2|void loader_initialize(void) {
 2357|      2|    loader_platform_thread_create_mutex(&loader_lock);
 2358|      2|    loader_platform_thread_create_mutex(&loader_preload_icd_lock);
 2359|      2|    init_global_loader_settings();
 2360|      2|#endif
 2361|       |
 2362|       |    // initialize logging
 2363|      2|    loader_init_global_debug_level();
 2364|       |#if defined(_WIN32)
 2365|       |    windows_initialization();
 2366|       |#endif
 2367|       |
 2368|      2|    loader_api_version version = loader_make_full_version(VK_HEADER_VERSION_COMPLETE);
 2369|      2|    loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "Vulkan Loader Version %d.%d.%d", version.major, version.minor, version.patch);
 2370|       |
 2371|       |#if defined(GIT_BRANCH_NAME) && defined(GIT_TAG_INFO)
 2372|       |    loader_log(NULL, VULKAN_LOADER_INFO_BIT, 0, "[Vulkan Loader Git - Tag: " GIT_BRANCH_NAME ", Branch/Commit: " GIT_TAG_INFO "]");
 2373|       |#endif
 2374|       |
 2375|      2|    char *loader_disable_dynamic_library_unloading_env_var = loader_getenv("VK_LOADER_DISABLE_DYNAMIC_LIBRARY_UNLOADING", NULL);
 2376|      2|    if (loader_disable_dynamic_library_unloading_env_var &&
  ------------------
  |  Branch (2376:9): [True: 0, False: 2]
  ------------------
 2377|       |        // NOLINTNEXTLINE(bugprone-not-null-terminated-result) - n=2 intentionally excludes "1x" values like "10"
 2378|      0|        0 == strncmp(loader_disable_dynamic_library_unloading_env_var, "1", 2)) {
  ------------------
  |  Branch (2378:9): [True: 0, False: 0]
  ------------------
 2379|      0|        loader_disable_dynamic_library_unloading = true;
 2380|      0|        loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: library unloading is disabled");
 2381|      2|    } else {
 2382|      2|        loader_disable_dynamic_library_unloading = false;
 2383|      2|    }
 2384|      2|    loader_free_getenv(loader_disable_dynamic_library_unloading_env_var, NULL);
 2385|       |#if defined(LOADER_USE_UNSAFE_FILE_SEARCH)
 2386|       |    loader_log(NULL, VULKAN_LOADER_WARN_BIT, 0, "Vulkan Loader: unsafe searching is enabled");
 2387|       |#endif
 2388|       |#if defined(_WIN32)
 2389|       |    return TRUE;
 2390|       |#endif
 2391|      2|}
loader_init_library:
 2428|      2|__attribute__((constructor)) void loader_init_library(void) { loader_initialize(); }
loader_get_next_path:
 2439|  94.1k|char *loader_get_next_path(char *path) {
 2440|  94.1k|    uint32_t len;
 2441|  94.1k|    char *next;
 2442|       |
 2443|  94.1k|    if (path == NULL) return NULL;
  ------------------
  |  Branch (2443:9): [True: 0, False: 94.1k]
  ------------------
 2444|  94.1k|    next = strchr(path, PATH_SEPARATOR);
  ------------------
  |  |  154|  94.1k|#define PATH_SEPARATOR ':'
  ------------------
 2445|  94.1k|    if (next == NULL) {
  ------------------
  |  Branch (2445:9): [True: 94.1k, False: 0]
  ------------------
 2446|  94.1k|        len = (uint32_t)strlen(path);
 2447|  94.1k|        next = path + len;
 2448|  94.1k|    } else {
 2449|      0|        *next = '\0';
 2450|      0|        next++;
 2451|      0|    }
 2452|       |
 2453|  94.1k|    return next;
 2454|  94.1k|}
combine_manifest_directory_and_library_path:
 2464|  57.9k|                                                     const char *manifest_file_path, char **out_fullpath) {
 2465|  57.9k|    assert(library_path && manifest_file_path && out_fullpath);
 2466|  57.9k|    if (loader_platform_is_path_absolute(library_path)) {
  ------------------
  |  Branch (2466:9): [True: 493, False: 57.4k]
  ------------------
 2467|    493|        *out_fullpath = library_path;
 2468|    493|        return VK_SUCCESS;
 2469|    493|    }
 2470|  57.4k|    VkResult res = VK_SUCCESS;
 2471|       |
 2472|  57.4k|    size_t library_path_len = strlen(library_path);
 2473|  57.4k|    size_t manifest_file_path_str_len = strlen(manifest_file_path);
 2474|  57.4k|    bool library_path_contains_directory_symbol = false;
 2475|  1.56M|    for (size_t i = 0; i < library_path_len; i++) {
  ------------------
  |  Branch (2475:24): [True: 1.55M, False: 5.94k]
  ------------------
 2476|  1.55M|        if (library_path[i] == DIRECTORY_SYMBOL) {
  ------------------
  |  |  155|  1.55M|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (2476:13): [True: 51.5k, False: 1.50M]
  ------------------
 2477|  51.5k|            library_path_contains_directory_symbol = true;
 2478|  51.5k|            break;
 2479|  51.5k|        }
 2480|  1.55M|    }
 2481|       |    // Means that the library_path is neither absolute nor relative - thus we should not modify it at all
 2482|  57.4k|    if (!library_path_contains_directory_symbol) {
  ------------------
  |  Branch (2482:9): [True: 5.94k, False: 51.5k]
  ------------------
 2483|  5.94k|        *out_fullpath = library_path;
 2484|  5.94k|        return VK_SUCCESS;
 2485|  5.94k|    }
 2486|       |    // must include both a directory symbol and the null terminator
 2487|  51.5k|    size_t new_str_len = library_path_len + manifest_file_path_str_len + 1 + 1;
 2488|       |
 2489|  51.5k|    *out_fullpath = loader_instance_heap_calloc(inst, new_str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 2490|  51.5k|    if (NULL == *out_fullpath) {
  ------------------
  |  Branch (2490:9): [True: 0, False: 51.5k]
  ------------------
 2491|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 2492|      0|        goto out;
 2493|      0|    }
 2494|  51.5k|    size_t cur_loc_in_out_fullpath = 0;
 2495|       |    // look for the last occurrence of DIRECTORY_SYMBOL in manifest_file_path
 2496|  51.5k|    size_t last_directory_symbol = 0;
 2497|  51.5k|    bool found_directory_symbol = false;
 2498|   938k|    for (size_t i = 0; i < manifest_file_path_str_len; i++) {
  ------------------
  |  Branch (2498:24): [True: 886k, False: 51.5k]
  ------------------
 2499|   886k|        if (manifest_file_path[i] == DIRECTORY_SYMBOL) {
  ------------------
  |  |  155|   886k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (2499:13): [True: 13.8k, False: 872k]
  ------------------
 2500|  13.8k|            last_directory_symbol = i + 1;  // we want to include the symbol
 2501|  13.8k|            found_directory_symbol = true;
 2502|       |            // dont break because we want to find the last occurrence
 2503|  13.8k|        }
 2504|   886k|    }
 2505|       |    // Add manifest_file_path up to the last directory symbol
 2506|  51.5k|    if (found_directory_symbol) {
  ------------------
  |  Branch (2506:9): [True: 1.88k, False: 49.6k]
  ------------------
 2507|  1.88k|        loader_strncpy(*out_fullpath, new_str_len, manifest_file_path, last_directory_symbol);
 2508|  1.88k|        cur_loc_in_out_fullpath += last_directory_symbol;
 2509|  1.88k|    }
 2510|  51.5k|    loader_strncpy(&(*out_fullpath)[cur_loc_in_out_fullpath], new_str_len - cur_loc_in_out_fullpath, library_path,
 2511|  51.5k|                   library_path_len);
 2512|  51.5k|    cur_loc_in_out_fullpath += library_path_len + 1;
 2513|  51.5k|    (*out_fullpath)[cur_loc_in_out_fullpath] = '\0';
 2514|       |
 2515|  51.5k|out:
 2516|  51.5k|    loader_instance_heap_free(inst, library_path);
 2517|       |
 2518|  51.5k|    return res;
 2519|  51.5k|}
loader_get_fullpath:
 2525|  20.5k|void loader_get_fullpath(const char *file, const char *in_dirs, size_t out_size, char *out_fullpath) {
 2526|  20.5k|    if (!loader_platform_is_path(file) && *in_dirs) {
  ------------------
  |  Branch (2526:9): [True: 20.5k, False: 69]
  |  Branch (2526:43): [True: 20.5k, False: 0]
  ------------------
 2527|  20.5k|        size_t dirs_copy_len = strlen(in_dirs) + 1;
 2528|  20.5k|        char *dirs_copy = loader_stack_alloc(dirs_copy_len);
  ------------------
  |  |   42|  20.5k|#define loader_stack_alloc(size) alloca(size)
  ------------------
 2529|  20.5k|        loader_strncpy(dirs_copy, dirs_copy_len, in_dirs, dirs_copy_len);
 2530|       |
 2531|       |        // find if file exists after prepending paths in given list
 2532|       |        // for (dir = dirs_copy; *dir && (next_dir = loader_get_next_path(dir)); dir = next_dir) {
 2533|  20.5k|        char *dir = dirs_copy;
 2534|  20.5k|        char *next_dir = loader_get_next_path(dir);
 2535|  21.0k|        while (*dir && next_dir) {
  ------------------
  |  Branch (2535:16): [True: 20.5k, False: 575]
  |  Branch (2535:24): [True: 20.5k, False: 0]
  ------------------
 2536|  20.5k|            int path_concat_ret = snprintf(out_fullpath, out_size, "%s%c%s", dir, DIRECTORY_SYMBOL, file);
  ------------------
  |  |  155|  20.5k|#define DIRECTORY_SYMBOL '/'
  ------------------
 2537|  20.5k|            if (path_concat_ret < 0) {
  ------------------
  |  Branch (2537:17): [True: 0, False: 20.5k]
  ------------------
 2538|      0|                continue;
 2539|      0|            }
 2540|  20.5k|            if (loader_platform_file_exists(out_fullpath)) {
  ------------------
  |  Branch (2540:17): [True: 19.9k, False: 575]
  ------------------
 2541|  19.9k|                return;
 2542|  19.9k|            }
 2543|    575|            dir = next_dir;
 2544|    575|            next_dir = loader_get_next_path(dir);
 2545|    575|        }
 2546|  20.5k|    }
 2547|       |
 2548|    644|    (void)snprintf(out_fullpath, out_size, "%s", file);
 2549|    644|}
verify_meta_layer_component_layers:
 2556|  21.5k|                                        struct loader_layer_list *instance_layers, bool *already_checked_meta_layers) {
 2557|  21.5k|    struct loader_layer_properties *prop = &instance_layers->list[prop_index];
 2558|  21.5k|    loader_api_version meta_layer_version = loader_make_version(prop->info.specVersion);
 2559|       |
 2560|  21.5k|    if (NULL == already_checked_meta_layers) {
  ------------------
  |  Branch (2560:9): [True: 17.6k, False: 3.92k]
  ------------------
 2561|  17.6k|        already_checked_meta_layers = loader_stack_alloc(sizeof(bool) * instance_layers->count);
  ------------------
  |  |   42|  17.6k|#define loader_stack_alloc(size) alloca(size)
  ------------------
 2562|  17.6k|        if (already_checked_meta_layers == NULL) {
  ------------------
  |  Branch (2562:13): [True: 0, False: 17.6k]
  ------------------
 2563|      0|            return false;
 2564|      0|        }
 2565|  17.6k|        memset(already_checked_meta_layers, 0, sizeof(bool) * instance_layers->count);
 2566|  17.6k|    }
 2567|       |
 2568|       |    // Mark this meta layer as 'already checked', indicating which layers have already been recursed.
 2569|  21.5k|    already_checked_meta_layers[prop_index] = true;
 2570|       |
 2571|  24.0k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2571:35): [True: 7.69k, False: 16.3k]
  ------------------
 2572|  7.69k|        struct loader_layer_properties *comp_prop =
 2573|  7.69k|            loader_find_layer_property(prop->component_layer_names.list[comp_layer], instance_layers);
 2574|  7.69k|        if (comp_prop == NULL) {
  ------------------
  |  Branch (2574:13): [True: 2.00k, False: 5.69k]
  ------------------
 2575|  2.00k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2576|  2.00k|                       "verify_meta_layer_component_layers: Meta-layer %s can't find component layer %s at index %d."
 2577|  2.00k|                       "  Skipping this layer.",
 2578|  2.00k|                       prop->info.layerName, prop->component_layer_names.list[comp_layer], comp_layer);
 2579|       |
 2580|  2.00k|            return false;
 2581|  2.00k|        }
 2582|       |
 2583|       |        // Check the version of each layer, they need to be at least MAJOR and MINOR
 2584|  5.69k|        loader_api_version comp_prop_version = loader_make_version(comp_prop->info.specVersion);
 2585|  5.69k|        if (!loader_check_version_meets_required(meta_layer_version, comp_prop_version)) {
  ------------------
  |  Branch (2585:13): [True: 536, False: 5.16k]
  ------------------
 2586|    536|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2587|    536|                       "verify_meta_layer_component_layers: Meta-layer uses API version %d.%d, but component "
 2588|    536|                       "layer %d has API version %d.%d that is lower.  Skipping this layer.",
 2589|    536|                       meta_layer_version.major, meta_layer_version.minor, comp_layer, comp_prop_version.major,
 2590|    536|                       comp_prop_version.minor);
 2591|       |
 2592|    536|            return false;
 2593|    536|        }
 2594|       |
 2595|       |        // Make sure the layer isn't using it's own name
 2596|  5.16k|        if (!strcmp(prop->info.layerName, prop->component_layer_names.list[comp_layer])) {
  ------------------
  |  Branch (2596:13): [True: 181, False: 4.98k]
  ------------------
 2597|    181|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2598|    181|                       "verify_meta_layer_component_layers: Meta-layer %s lists itself in its component layer "
 2599|    181|                       "list at index %d.  Skipping this layer.",
 2600|    181|                       prop->info.layerName, comp_layer);
 2601|       |
 2602|    181|            return false;
 2603|    181|        }
 2604|  4.98k|        if (comp_prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
  ------------------
  |  Branch (2604:13): [True: 4.58k, False: 400]
  ------------------
 2605|  4.58k|            size_t comp_prop_index = INT32_MAX;
 2606|       |            // Make sure we haven't verified this meta layer before
 2607|   873k|            for (uint32_t i = 0; i < instance_layers->count; i++) {
  ------------------
  |  Branch (2607:34): [True: 868k, False: 4.58k]
  ------------------
 2608|   868k|                if (strcmp(comp_prop->info.layerName, instance_layers->list[i].info.layerName) == 0) {
  ------------------
  |  Branch (2608:21): [True: 190k, False: 678k]
  ------------------
 2609|   190k|                    comp_prop_index = i;
 2610|   190k|                }
 2611|   868k|            }
 2612|  4.58k|            if (comp_prop_index != INT32_MAX && already_checked_meta_layers[comp_prop_index]) {
  ------------------
  |  Branch (2612:17): [True: 4.58k, False: 0]
  |  Branch (2612:49): [True: 656, False: 3.92k]
  ------------------
 2613|    656|                loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2614|    656|                           "verify_meta_layer_component_layers: Recursive dependency between Meta-layer %s and  Meta-layer %s.  "
 2615|    656|                           "Skipping this layer.",
 2616|    656|                           instance_layers->list[prop_index].info.layerName, comp_prop->info.layerName);
 2617|    656|                return false;
 2618|    656|            }
 2619|       |
 2620|  3.92k|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 2621|  3.92k|                       "verify_meta_layer_component_layers: Adding meta-layer %s which also contains meta-layer %s",
 2622|  3.92k|                       prop->info.layerName, comp_prop->info.layerName);
 2623|       |
 2624|       |            // Make sure if the layer is using a meta-layer in its component list that we also verify that.
 2625|  3.92k|            if (!verify_meta_layer_component_layers(inst, comp_prop_index, instance_layers, already_checked_meta_layers)) {
  ------------------
  |  Branch (2625:17): [True: 1.86k, False: 2.05k]
  ------------------
 2626|  1.86k|                loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2627|  1.86k|                           "Meta-layer %s component layer %s can not find all component layers."
 2628|  1.86k|                           "  Skipping this layer.",
 2629|  1.86k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer]);
 2630|  1.86k|                return false;
 2631|  1.86k|            }
 2632|  3.92k|        }
 2633|  4.98k|    }
 2634|       |    // Didn't exit early so that means it passed all checks
 2635|  16.3k|    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2636|  16.3k|               "Meta-layer \"%s\" all %d component layers appear to be valid.", prop->info.layerName,
 2637|  16.3k|               prop->component_layer_names.count);
 2638|       |
 2639|       |    // If layer logging is on, list the internals included in the meta-layer
 2640|  18.6k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2640:35): [True: 2.30k, False: 16.3k]
  ------------------
 2641|  2.30k|        loader_log(inst, VULKAN_LOADER_LAYER_BIT, 0, "  [%d] %s", comp_layer, prop->component_layer_names.list[comp_layer]);
 2642|  2.30k|    }
 2643|       |    return true;
 2644|  21.5k|}
update_meta_layer_extensions_from_component_layers:
 2650|  14.2k|                                                            struct loader_layer_list *instance_layers) {
 2651|  14.2k|    VkResult res = VK_SUCCESS;
 2652|  16.1k|    for (uint32_t comp_layer = 0; comp_layer < prop->component_layer_names.count; comp_layer++) {
  ------------------
  |  Branch (2652:35): [True: 1.88k, False: 14.2k]
  ------------------
 2653|  1.88k|        struct loader_layer_properties *comp_prop =
 2654|  1.88k|            loader_find_layer_property(prop->component_layer_names.list[comp_layer], instance_layers);
 2655|       |
 2656|  1.88k|        if (NULL != comp_prop->instance_extension_list.list) {
  ------------------
  |  Branch (2656:13): [True: 203, False: 1.68k]
  ------------------
 2657|  2.23k|            for (uint32_t ext = 0; ext < comp_prop->instance_extension_list.count; ext++) {
  ------------------
  |  Branch (2657:36): [True: 2.03k, False: 203]
  ------------------
 2658|  2.03k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Meta-layer %s component layer %s adding instance extension %s",
 2659|  2.03k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer],
 2660|  2.03k|                           comp_prop->instance_extension_list.list[ext].extensionName);
 2661|       |
 2662|  2.03k|                if (!has_vk_extension_property(&comp_prop->instance_extension_list.list[ext], &prop->instance_extension_list)) {
  ------------------
  |  Branch (2662:21): [True: 1.91k, False: 118]
  ------------------
 2663|  1.91k|                    res = loader_add_to_ext_list(inst, &prop->instance_extension_list, 1,
 2664|  1.91k|                                                 &comp_prop->instance_extension_list.list[ext]);
 2665|  1.91k|                    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2665:25): [True: 0, False: 1.91k]
  ------------------
 2666|      0|                        return res;
 2667|      0|                    }
 2668|  1.91k|                }
 2669|  2.03k|            }
 2670|    203|        }
 2671|  1.88k|        if (NULL != comp_prop->device_extension_list.list) {
  ------------------
  |  Branch (2671:13): [True: 474, False: 1.41k]
  ------------------
 2672|  5.26k|            for (uint32_t ext = 0; ext < comp_prop->device_extension_list.count; ext++) {
  ------------------
  |  Branch (2672:36): [True: 4.78k, False: 474]
  ------------------
 2673|  4.78k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Meta-layer %s component layer %s adding device extension %s",
 2674|  4.78k|                           prop->info.layerName, prop->component_layer_names.list[comp_layer],
 2675|  4.78k|                           comp_prop->device_extension_list.list[ext].props.extensionName);
 2676|       |
 2677|  4.78k|                if (!has_vk_dev_ext_property(&comp_prop->device_extension_list.list[ext].props, &prop->device_extension_list)) {
  ------------------
  |  Branch (2677:21): [True: 3.97k, False: 810]
  ------------------
 2678|  3.97k|                    res = loader_add_to_dev_ext_list(inst, &prop->device_extension_list,
 2679|  3.97k|                                                     &comp_prop->device_extension_list.list[ext].props, NULL);
 2680|  3.97k|                    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2680:25): [True: 0, False: 3.97k]
  ------------------
 2681|      0|                        return res;
 2682|      0|                    }
 2683|  3.97k|                }
 2684|  4.78k|            }
 2685|    474|        }
 2686|  1.88k|    }
 2687|  14.2k|    return res;
 2688|  14.2k|}
verify_all_meta_layers:
 2692|  5.10k|                                struct loader_layer_list *instance_layers, bool *override_layer_present) {
 2693|  5.10k|    VkResult res = VK_SUCCESS;
 2694|  5.10k|    *override_layer_present = false;
 2695|  25.8k|    for (int32_t i = 0; i < (int32_t)instance_layers->count; i++) {
  ------------------
  |  Branch (2695:25): [True: 20.7k, False: 5.10k]
  ------------------
 2696|  20.7k|        struct loader_layer_properties *prop = &instance_layers->list[i];
 2697|       |
 2698|       |        // If this is a meta-layer, make sure it is valid
 2699|  20.7k|        if (prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) {
  ------------------
  |  Branch (2699:13): [True: 17.6k, False: 3.04k]
  ------------------
 2700|  17.6k|            if (verify_meta_layer_component_layers(inst, i, instance_layers, NULL)) {
  ------------------
  |  Branch (2700:17): [True: 14.2k, False: 3.37k]
  ------------------
 2701|       |                // If any meta layer is valid, update its extension list to include the extensions from its component layers.
 2702|  14.2k|                res = update_meta_layer_extensions_from_component_layers(inst, prop, instance_layers);
 2703|  14.2k|                if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (2703:21): [True: 0, False: 14.2k]
  ------------------
 2704|      0|                    return res;
 2705|      0|                }
 2706|  14.2k|                if (prop->is_override && loader_implicit_layer_is_enabled(inst, filters, prop)) {
  ------------------
  |  Branch (2706:21): [True: 1.21k, False: 13.0k]
  |  Branch (2706:42): [True: 1.19k, False: 20]
  ------------------
 2707|  1.19k|                    *override_layer_present = true;
 2708|  1.19k|                }
 2709|  14.2k|            } else {
 2710|  3.37k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
 2711|  3.37k|                           "Removing meta-layer %s from instance layer list since it appears invalid.", prop->info.layerName);
 2712|       |
 2713|  3.37k|                loader_remove_layer_in_list(inst, instance_layers, i);
 2714|  3.37k|                i--;
 2715|  3.37k|            }
 2716|  17.6k|        }
 2717|  20.7k|    }
 2718|  5.10k|    return res;
 2719|  5.10k|}
remove_all_non_valid_override_layers:
 2723|  5.10k|void remove_all_non_valid_override_layers(struct loader_instance *inst, struct loader_layer_list *instance_layers) {
 2724|  5.10k|    if (instance_layers == NULL) {
  ------------------
  |  Branch (2724:9): [True: 0, False: 5.10k]
  ------------------
 2725|      0|        return;
 2726|      0|    }
 2727|       |
 2728|  5.10k|    char cur_path[1024];
 2729|  5.10k|    char *ret = loader_platform_executable_path(cur_path, 1024);
 2730|  5.10k|    if (NULL == ret) {
  ------------------
  |  Branch (2730:9): [True: 0, False: 5.10k]
  ------------------
 2731|      0|        return;
 2732|      0|    }
 2733|       |    // Find out if there is an override layer with same the app_key_path as the path to the current executable.
 2734|       |    // If more than one is found, remove it and use the first layer
 2735|       |    // Remove any layers which aren't global and do not have the same app_key_path as the path to the current executable.
 2736|  5.10k|    bool found_active_override_layer = false;
 2737|  5.10k|    int global_layer_index = -1;
 2738|  15.0k|    for (uint32_t i = 0; i < instance_layers->count; i++) {
  ------------------
  |  Branch (2738:26): [True: 9.97k, False: 5.10k]
  ------------------
 2739|  9.97k|        struct loader_layer_properties *props = &instance_layers->list[i];
 2740|  9.97k|        if (strcmp(props->info.layerName, VK_OVERRIDE_LAYER_NAME) == 0) {
  ------------------
  |  |  142|  9.97k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (2740:13): [True: 1.18k, False: 8.78k]
  ------------------
 2741|  1.18k|            if (props->app_key_paths.count > 0) {  // not the global layer
  ------------------
  |  Branch (2741:17): [True: 180, False: 1.00k]
  ------------------
 2742|  13.3k|                for (uint32_t j = 0; j < props->app_key_paths.count; j++) {
  ------------------
  |  Branch (2742:38): [True: 13.2k, False: 180]
  ------------------
 2743|  13.2k|                    if (strcmp(props->app_key_paths.list[j], cur_path) == 0) {
  ------------------
  |  Branch (2743:25): [True: 0, False: 13.2k]
  ------------------
 2744|      0|                        if (!found_active_override_layer) {
  ------------------
  |  Branch (2744:29): [True: 0, False: 0]
  ------------------
 2745|      0|                            found_active_override_layer = true;
 2746|      0|                        } else {
 2747|      0|                            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2748|      0|                                       "remove_all_non_valid_override_layers: Multiple override layers where the same path in "
 2749|      0|                                       "app_keys "
 2750|      0|                                       "was found. Using the first layer found");
 2751|       |
 2752|       |                            // Remove duplicate active override layers that have the same app_key_path
 2753|      0|                            loader_remove_layer_in_list(inst, instance_layers, i);
 2754|      0|                            i--;
 2755|      0|                        }
 2756|      0|                    }
 2757|  13.2k|                }
 2758|    180|                if (!found_active_override_layer) {
  ------------------
  |  Branch (2758:21): [True: 180, False: 0]
  ------------------
 2759|    180|                    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2760|    180|                               "--Override layer found but not used because app \'%s\' is not in \'app_keys\' list!", cur_path);
 2761|       |
 2762|       |                    // Remove non-global override layers that don't have an app_key that matches cur_path
 2763|    180|                    loader_remove_layer_in_list(inst, instance_layers, i);
 2764|    180|                    i--;
 2765|    180|                }
 2766|  1.00k|            } else {
 2767|  1.00k|                if (global_layer_index == -1) {
  ------------------
  |  Branch (2767:21): [True: 487, False: 519]
  ------------------
 2768|    487|                    global_layer_index = (int)i;
 2769|    519|                } else {
 2770|    519|                    loader_log(
 2771|    519|                        inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2772|    519|                        "remove_all_non_valid_override_layers: Multiple global override layers found. Using the first global "
 2773|    519|                        "layer found");
 2774|    519|                    loader_remove_layer_in_list(inst, instance_layers, i);
 2775|    519|                    i--;
 2776|    519|                }
 2777|  1.00k|            }
 2778|  1.18k|        }
 2779|  9.97k|    }
 2780|       |    // Remove global layer if layer with same the app_key_path as the path to the current executable is found
 2781|  5.10k|    if (found_active_override_layer && global_layer_index >= 0) {
  ------------------
  |  Branch (2781:9): [True: 0, False: 5.10k]
  |  Branch (2781:40): [True: 0, False: 0]
  ------------------
 2782|      0|        loader_remove_layer_in_list(inst, instance_layers, global_layer_index);
 2783|      0|    }
 2784|       |    // Should be at most 1 override layer in the list now.
 2785|  5.10k|    if (found_active_override_layer) {
  ------------------
  |  Branch (2785:9): [True: 0, False: 5.10k]
  ------------------
 2786|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Using the override layer for app key %s", cur_path);
 2787|  5.10k|    } else if (global_layer_index >= 0) {
  ------------------
  |  Branch (2787:16): [True: 487, False: 4.61k]
  ------------------
 2788|    487|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Using the global override layer");
 2789|    487|    }
 2790|  5.10k|}
loader_read_layer_json:
 2804|   300k|                                cJSON *layer_node, loader_api_version version, bool is_implicit, char *filename) {
 2805|   300k|    assert(layer_instance_list);
 2806|   300k|    char *library_path = NULL;
 2807|   300k|    VkResult result = VK_SUCCESS;
 2808|   300k|    struct loader_layer_properties props = {0};
 2809|       |
 2810|   300k|    result = loader_copy_to_new_str(inst, filename, &props.manifest_file_name);
 2811|   300k|    if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2811:9): [True: 0, False: 300k]
  ------------------
 2812|      0|        goto out;
 2813|      0|    }
 2814|       |
 2815|       |    // Parse name
 2816|       |
 2817|   300k|    result = loader_parse_json_string_to_existing_str(layer_node, "name", VK_MAX_EXTENSION_NAME_SIZE, props.info.layerName);
 2818|   300k|    if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2818:9): [True: 56.4k, False: 243k]
  ------------------
 2819|  56.4k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2820|  56.4k|                   "Layer located at %s didn't find required layer value \"name\" in manifest JSON file, skipping this layer",
 2821|  56.4k|                   filename);
 2822|  56.4k|        goto out;
 2823|  56.4k|    }
 2824|       |
 2825|       |    // Check if this layer's name matches the override layer name, set is_override to true if so.
 2826|   243k|    if (!strcmp(props.info.layerName, VK_OVERRIDE_LAYER_NAME)) {
  ------------------
  |  |  142|   243k|#define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
  ------------------
  |  Branch (2826:9): [True: 6.26k, False: 237k]
  ------------------
 2827|  6.26k|        props.is_override = true;
 2828|  6.26k|    }
 2829|       |
 2830|   243k|    if (0 != strncmp(props.info.layerName, "VK_LAYER_", 9)) {
  ------------------
  |  Branch (2830:9): [True: 233k, False: 9.99k]
  ------------------
 2831|   233k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0, "Layer name %s does not conform to naming standard (Policy #LLP_LAYER_3)",
 2832|   233k|                   props.info.layerName);
 2833|   233k|    }
 2834|       |
 2835|       |    // Parse type
 2836|   243k|    char *type = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "type"));
 2837|   243k|    if (NULL == type) {
  ------------------
  |  Branch (2837:9): [True: 19.0k, False: 224k]
  ------------------
 2838|  19.0k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2839|  19.0k|                   "Layer located at %s didn't find required layer value \"type\" in manifest JSON file, skipping this layer",
 2840|  19.0k|                   filename);
 2841|  19.0k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2842|  19.0k|        goto out;
 2843|  19.0k|    }
 2844|       |
 2845|       |    // Add list entry
 2846|   224k|    if (!strcmp(type, "DEVICE")) {
  ------------------
  |  Branch (2846:9): [True: 325, False: 224k]
  ------------------
 2847|    325|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Device layers are deprecated. Skipping layer %s",
 2848|    325|                   props.info.layerName);
 2849|    325|        result = VK_ERROR_INITIALIZATION_FAILED;
 2850|    325|        goto out;
 2851|    325|    }
 2852|       |
 2853|       |    // Allow either GLOBAL or INSTANCE type interchangeably to handle layers that must work with older loaders
 2854|   224k|    if (!strcmp(type, "INSTANCE") || !strcmp(type, "GLOBAL")) {
  ------------------
  |  Branch (2854:9): [True: 173k, False: 51.3k]
  |  Branch (2854:38): [True: 35.9k, False: 15.4k]
  ------------------
 2855|   209k|        props.type_flags = VK_LAYER_TYPE_FLAG_INSTANCE_LAYER;
 2856|   209k|        if (!is_implicit) {
  ------------------
  |  Branch (2856:13): [True: 190k, False: 18.4k]
  ------------------
 2857|   190k|            props.type_flags |= VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER;
 2858|   190k|        }
 2859|   209k|    } else {
 2860|  15.4k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2861|  15.4k|        goto out;
 2862|  15.4k|    }
 2863|       |
 2864|       |    // Parse api_version
 2865|   209k|    char *api_version = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "api_version"));
 2866|   209k|    if (NULL == api_version) {
  ------------------
  |  Branch (2866:9): [True: 30.6k, False: 178k]
  ------------------
 2867|  30.6k|        loader_log(
 2868|  30.6k|            inst, VULKAN_LOADER_WARN_BIT, 0,
 2869|  30.6k|            "Layer located at %s didn't find required layer value \"api_version\" in manifest JSON file, skipping this layer",
 2870|  30.6k|            filename);
 2871|  30.6k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2872|  30.6k|        goto out;
 2873|  30.6k|    }
 2874|       |
 2875|   178k|    props.info.specVersion = loader_parse_version_string(api_version);
 2876|       |
 2877|       |    // Make sure the layer's manifest doesn't contain a non zero variant value
 2878|   178k|    if (VK_API_VERSION_VARIANT(props.info.specVersion) != 0) {
  ------------------
  |  Branch (2878:9): [True: 1.30k, False: 177k]
  ------------------
 2879|  1.30k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 2880|  1.30k|                   "Layer \"%s\" has an \'api_version\' field which contains a non-zero variant value of %d. "
 2881|  1.30k|                   " Skipping Layer.",
 2882|  1.30k|                   props.info.layerName, VK_API_VERSION_VARIANT(props.info.specVersion));
 2883|  1.30k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2884|  1.30k|        goto out;
 2885|  1.30k|    }
 2886|       |
 2887|       |    // Parse implementation_version
 2888|   177k|    char *implementation_version = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "implementation_version"));
 2889|   177k|    if (NULL == implementation_version) {
  ------------------
  |  Branch (2889:9): [True: 15.4k, False: 161k]
  ------------------
 2890|  15.4k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2891|  15.4k|                   "Layer located at %s didn't find required layer value \"implementation_version\" in manifest JSON file, "
 2892|  15.4k|                   "skipping this layer",
 2893|  15.4k|                   filename);
 2894|  15.4k|        result = VK_ERROR_INITIALIZATION_FAILED;
 2895|  15.4k|        goto out;
 2896|  15.4k|    }
 2897|   161k|    props.info.implementationVersion = (uint32_t)strtoul(implementation_version, NULL, 10);
 2898|       |
 2899|       |    // Parse description
 2900|       |
 2901|   161k|    result = loader_parse_json_string_to_existing_str(layer_node, "description", VK_MAX_DESCRIPTION_SIZE, props.info.description);
 2902|   161k|    if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2902:9): [True: 23.7k, False: 137k]
  ------------------
 2903|  23.7k|        loader_log(
 2904|  23.7k|            inst, VULKAN_LOADER_WARN_BIT, 0,
 2905|  23.7k|            "Layer located at %s didn't find required layer value \"description\" in manifest JSON file, skipping this layer",
 2906|  23.7k|            filename);
 2907|  23.7k|        goto out;
 2908|  23.7k|    }
 2909|       |
 2910|       |    // Parse library_path
 2911|       |
 2912|       |    // Library path no longer required unless component_layers is also not defined
 2913|   137k|    result = loader_parse_json_string(layer_node, "library_path", &library_path);
 2914|   137k|    if (result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (2914:9): [True: 0, False: 137k]
  ------------------
 2915|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2916|      0|                   "Skipping layer \"%s\" due to problem accessing the library_path value in the manifest JSON file",
 2917|      0|                   props.info.layerName);
 2918|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
 2919|      0|        goto out;
 2920|      0|    }
 2921|   137k|    if (NULL != library_path) {
  ------------------
  |  Branch (2921:9): [True: 58.2k, False: 79.6k]
  ------------------
 2922|  58.2k|        if (NULL != loader_cJSON_GetObjectItem(layer_node, "component_layers")) {
  ------------------
  |  Branch (2922:13): [True: 303, False: 57.9k]
  ------------------
 2923|    303|            loader_log(
 2924|    303|                inst, VULKAN_LOADER_WARN_BIT, 0,
 2925|    303|                "Layer \"%s\" contains meta-layer-specific component_layers, but also defining layer library path.  Both are not "
 2926|    303|                "compatible, so skipping this layer",
 2927|    303|                props.info.layerName);
 2928|    303|            result = VK_ERROR_INITIALIZATION_FAILED;
 2929|    303|            loader_instance_heap_free(inst, library_path);
 2930|    303|            goto out;
 2931|    303|        }
 2932|       |
 2933|       |        // This function takes ownership of library_path_str - so we don't need to clean it up
 2934|  57.9k|        result = combine_manifest_directory_and_library_path(inst, library_path, filename, &props.lib_name);
 2935|  57.9k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (2935:13): [True: 0, False: 57.9k]
  ------------------
 2936|  57.9k|    }
 2937|       |
 2938|       |    // Parse component_layers
 2939|       |
 2940|   137k|    if (NULL == library_path) {
  ------------------
  |  Branch (2940:9): [True: 79.6k, False: 57.9k]
  ------------------
 2941|  79.6k|        if (!loader_check_version_meets_required(LOADER_VERSION_1_1_0, version)) {
  ------------------
  |  |  271|  79.6k|#define LOADER_VERSION_1_1_0 loader_combine_version(1, 1, 0)
  ------------------
  |  Branch (2941:13): [True: 17.0k, False: 62.5k]
  ------------------
 2942|  17.0k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2943|  17.0k|                       "Layer \"%s\" contains meta-layer-specific component_layers, but using older JSON file version.",
 2944|  17.0k|                       props.info.layerName);
 2945|  17.0k|        }
 2946|       |
 2947|  79.6k|        result = loader_parse_json_array_of_strings(inst, layer_node, "component_layers", &(props.component_layer_names));
 2948|  79.6k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2948:13): [True: 0, False: 79.6k]
  ------------------
 2949|      0|            goto out;
 2950|      0|        }
 2951|  79.6k|        if (VK_ERROR_INITIALIZATION_FAILED == result) {
  ------------------
  |  Branch (2951:13): [True: 18.3k, False: 61.2k]
  ------------------
 2952|  18.3k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2953|  18.3k|                       "Layer \"%s\" is missing both library_path and component_layers fields.  One or the other MUST be defined.  "
 2954|  18.3k|                       "Skipping this layer",
 2955|  18.3k|                       props.info.layerName);
 2956|  18.3k|            goto out;
 2957|  18.3k|        }
 2958|       |        // This is now, officially, a meta-layer
 2959|  61.2k|        props.type_flags |= VK_LAYER_TYPE_FLAG_META_LAYER;
 2960|  61.2k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Encountered meta-layer \"%s\"",
 2961|  61.2k|                   props.info.layerName);
 2962|  61.2k|    }
 2963|       |
 2964|       |    // Parse blacklisted_layers
 2965|       |
 2966|   119k|    if (props.is_override) {
  ------------------
  |  Branch (2966:9): [True: 3.38k, False: 115k]
  ------------------
 2967|  3.38k|        result = loader_parse_json_array_of_strings(inst, layer_node, "blacklisted_layers", &(props.blacklist_layer_names));
 2968|  3.38k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2968:13): [True: 0, False: 3.38k]
  ------------------
 2969|      0|            goto out;
 2970|      0|        }
 2971|  3.38k|    }
 2972|       |
 2973|       |    // Parse override_paths
 2974|       |
 2975|   119k|    result = loader_parse_json_array_of_strings(inst, layer_node, "override_paths", &(props.override_paths));
 2976|   119k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == result) {
  ------------------
  |  Branch (2976:9): [True: 0, False: 119k]
  ------------------
 2977|      0|        goto out;
 2978|      0|    }
 2979|   119k|    if (NULL != props.override_paths.list && !loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (2979:9): [True: 1.92k, False: 117k]
  |  Branch (2979:46): [True: 1.08k, False: 838]
  ------------------
 2980|  1.08k|        loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2981|  1.08k|                   "Layer \"%s\" contains meta-layer-specific override paths, but using older JSON file version.",
 2982|  1.08k|                   props.info.layerName);
 2983|  1.08k|    }
 2984|       |
 2985|       |    // Parse disable_environment
 2986|       |
 2987|   119k|    if (is_implicit) {
  ------------------
  |  Branch (2987:9): [True: 12.4k, False: 106k]
  ------------------
 2988|  12.4k|        cJSON *disable_environment = loader_cJSON_GetObjectItem(layer_node, "disable_environment");
 2989|  12.4k|        if (disable_environment == NULL) {
  ------------------
  |  Branch (2989:13): [True: 2.29k, False: 10.1k]
  ------------------
 2990|  2.29k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 2991|  2.29k|                       "Layer \"%s\" doesn't contain required layer object disable_environment in the manifest JSON file, skipping "
 2992|  2.29k|                       "this layer",
 2993|  2.29k|                       props.info.layerName);
 2994|  2.29k|            result = VK_ERROR_INITIALIZATION_FAILED;
 2995|  2.29k|            goto out;
 2996|  2.29k|        }
 2997|       |
 2998|  10.1k|        if (!disable_environment->child || disable_environment->child->type != cJSON_String ||
  ------------------
  |  |  101|  20.2k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (2998:13): [True: 29, False: 10.1k]
  |  Branch (2998:44): [True: 40, False: 10.0k]
  ------------------
 2999|  10.0k|            !disable_environment->child->string || !disable_environment->child->valuestring) {
  ------------------
  |  Branch (2999:13): [True: 44, False: 10.0k]
  |  Branch (2999:52): [True: 0, False: 10.0k]
  ------------------
 3000|    113|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 3001|    113|                       "Layer \"%s\" doesn't contain required child value in object disable_environment in the manifest JSON file, "
 3002|    113|                       "skipping this layer (Policy #LLP_LAYER_9)",
 3003|    113|                       props.info.layerName);
 3004|    113|            result = VK_ERROR_INITIALIZATION_FAILED;
 3005|    113|            goto out;
 3006|    113|        }
 3007|  10.0k|        result = loader_copy_to_new_str(inst, disable_environment->child->string, &(props.disable_env_var.name));
 3008|  10.0k|        if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3008:13): [True: 0, False: 10.0k]
  ------------------
 3009|  10.0k|        result = loader_copy_to_new_str(inst, disable_environment->child->valuestring, &(props.disable_env_var.value));
 3010|  10.0k|        if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3010:13): [True: 0, False: 10.0k]
  ------------------
 3011|  10.0k|    }
 3012|       |
 3013|       |    // Now get all optional items and objects and put in list:
 3014|       |    // functions
 3015|       |    // instance_extensions
 3016|       |    // device_extensions
 3017|       |    // enable_environment (implicit layers only)
 3018|       |    // library_arch
 3019|       |
 3020|       |    // Layer interface functions
 3021|       |    //    vkGetInstanceProcAddr
 3022|       |    //    vkGetDeviceProcAddr
 3023|       |    //    vkNegotiateLoaderLayerInterfaceVersion (starting with JSON file 1.1.0)
 3024|   116k|    cJSON *functions = loader_cJSON_GetObjectItem(layer_node, "functions");
 3025|   116k|    if (functions != NULL) {
  ------------------
  |  Branch (3025:9): [True: 538, False: 116k]
  ------------------
 3026|    538|        if (loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3026:13): [True: 136, False: 402]
  ------------------
 3027|    136|            result = loader_parse_json_string(functions, "vkNegotiateLoaderLayerInterfaceVersion",
 3028|    136|                                              &props.functions.str_negotiate_interface);
 3029|    136|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3029:17): [True: 0, False: 136]
  ------------------
 3030|    136|        }
 3031|    538|        result = loader_parse_json_string(functions, "vkGetInstanceProcAddr", &props.functions.str_gipa);
 3032|    538|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3032:13): [True: 0, False: 538]
  ------------------
 3033|       |
 3034|    538|        if (NULL == props.functions.str_negotiate_interface && props.functions.str_gipa &&
  ------------------
  |  Branch (3034:13): [True: 538, False: 0]
  |  Branch (3034:64): [True: 0, False: 538]
  ------------------
 3035|      0|            loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3035:13): [True: 0, False: 0]
  ------------------
 3036|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3037|      0|                       "Layer \"%s\" using deprecated \'vkGetInstanceProcAddr\' tag which was deprecated starting with JSON "
 3038|      0|                       "file version 1.1.0. The new vkNegotiateLoaderLayerInterfaceVersion function is preferred, though for "
 3039|      0|                       "compatibility reasons it may be desirable to continue using the deprecated tag.",
 3040|      0|                       props.info.layerName);
 3041|      0|        }
 3042|       |
 3043|    538|        result = loader_parse_json_string(functions, "vkGetDeviceProcAddr", &props.functions.str_gdpa);
 3044|    538|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3044:13): [True: 0, False: 538]
  ------------------
 3045|       |
 3046|    538|        if (NULL == props.functions.str_negotiate_interface && props.functions.str_gdpa &&
  ------------------
  |  Branch (3046:13): [True: 538, False: 0]
  |  Branch (3046:64): [True: 0, False: 538]
  ------------------
 3047|      0|            loader_check_version_meets_required(loader_combine_version(1, 1, 0), version)) {
  ------------------
  |  Branch (3047:13): [True: 0, False: 0]
  ------------------
 3048|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3049|      0|                       "Layer \"%s\" using deprecated \'vkGetDeviceProcAddr\' tag which was deprecated starting with JSON "
 3050|      0|                       "file version 1.1.0. The new vkNegotiateLoaderLayerInterfaceVersion function is preferred, though for "
 3051|      0|                       "compatibility reasons it may be desirable to continue using the deprecated tag.",
 3052|      0|                       props.info.layerName);
 3053|      0|        }
 3054|    538|    }
 3055|       |
 3056|       |    // instance_extensions
 3057|       |    //   array of {
 3058|       |    //     name
 3059|       |    //     spec_version
 3060|       |    //   }
 3061|       |
 3062|   116k|    cJSON *instance_extensions = loader_cJSON_GetObjectItem(layer_node, "instance_extensions");
 3063|   116k|    if (instance_extensions != NULL && instance_extensions->type == cJSON_Array) {
  ------------------
  |  |  102|  1.82k|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (3063:9): [True: 1.82k, False: 115k]
  |  Branch (3063:40): [True: 1.37k, False: 448]
  ------------------
 3064|  1.37k|        cJSON *ext_item = NULL;
 3065|  26.2k|        cJSON_ArrayForEach(ext_item, instance_extensions) {
  ------------------
  |  |  213|  27.5k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 1.37k, False: 0]
  |  |  |  Branch (213:61): [True: 26.2k, False: 1.37k]
  |  |  ------------------
  ------------------
 3066|  26.2k|            if (ext_item->type != cJSON_Object) {
  ------------------
  |  |  103|  26.2k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3066:17): [True: 1.98k, False: 24.2k]
  ------------------
 3067|  1.98k|                continue;
 3068|  1.98k|            }
 3069|       |
 3070|  24.2k|            VkExtensionProperties ext_prop = {0};
 3071|  24.2k|            result = loader_parse_json_string_to_existing_str(ext_item, "name", VK_MAX_EXTENSION_NAME_SIZE, ext_prop.extensionName);
 3072|  24.2k|            if (result == VK_ERROR_INITIALIZATION_FAILED) {
  ------------------
  |  Branch (3072:17): [True: 4.84k, False: 19.3k]
  ------------------
 3073|  4.84k|                continue;
 3074|  4.84k|            }
 3075|  19.3k|            char *spec_version = NULL;
 3076|  19.3k|            result = loader_parse_json_string(ext_item, "spec_version", &spec_version);
 3077|  19.3k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3077:17): [True: 0, False: 19.3k]
  ------------------
 3078|  19.3k|            if (NULL != spec_version) {
  ------------------
  |  Branch (3078:17): [True: 502, False: 18.8k]
  ------------------
 3079|    502|                ext_prop.specVersion = (uint32_t)strtoul(spec_version, NULL, 10);
 3080|    502|            }
 3081|  19.3k|            loader_instance_heap_free(inst, spec_version);
 3082|  19.3k|            bool ext_unsupported = wsi_unsupported_instance_extension(&ext_prop);
 3083|  19.3k|            if (!ext_unsupported) {
  ------------------
  |  Branch (3083:17): [True: 19.0k, False: 354]
  ------------------
 3084|  19.0k|                result = loader_add_to_ext_list(inst, &props.instance_extension_list, 1, &ext_prop);
 3085|  19.0k|                if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3085:21): [True: 0, False: 19.0k]
  ------------------
 3086|  19.0k|            }
 3087|  19.3k|        }
 3088|  1.37k|    }
 3089|       |
 3090|       |    // device_extensions
 3091|       |    //   array of {
 3092|       |    //     name
 3093|       |    //     spec_version
 3094|       |    //     entrypoints
 3095|       |    //   }
 3096|   116k|    cJSON *device_extensions = loader_cJSON_GetObjectItem(layer_node, "device_extensions");
 3097|   116k|    if (device_extensions != NULL && device_extensions->type == cJSON_Array) {
  ------------------
  |  |  102|  7.44k|#define cJSON_Array (1 << 5)
  ------------------
  |  Branch (3097:9): [True: 7.44k, False: 109k]
  |  Branch (3097:38): [True: 6.97k, False: 471]
  ------------------
 3098|  6.97k|        cJSON *ext_item = NULL;
 3099|  20.2k|        cJSON_ArrayForEach(ext_item, device_extensions) {
  ------------------
  |  |  213|  27.1k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 6.97k, False: 0]
  |  |  |  Branch (213:61): [True: 20.2k, False: 6.97k]
  |  |  ------------------
  ------------------
 3100|  20.2k|            if (ext_item->type != cJSON_Object) {
  ------------------
  |  |  103|  20.2k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3100:17): [True: 3.81k, False: 16.3k]
  ------------------
 3101|  3.81k|                continue;
 3102|  3.81k|            }
 3103|       |
 3104|  16.3k|            VkExtensionProperties ext_prop = {0};
 3105|  16.3k|            result = loader_parse_json_string_to_existing_str(ext_item, "name", VK_MAX_EXTENSION_NAME_SIZE, ext_prop.extensionName);
 3106|  16.3k|            if (result == VK_ERROR_INITIALIZATION_FAILED) {
  ------------------
  |  Branch (3106:17): [True: 3.83k, False: 12.5k]
  ------------------
 3107|  3.83k|                continue;
 3108|  3.83k|            }
 3109|       |
 3110|  12.5k|            char *spec_version = NULL;
 3111|  12.5k|            result = loader_parse_json_string(ext_item, "spec_version", &spec_version);
 3112|  12.5k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3112:17): [True: 0, False: 12.5k]
  ------------------
 3113|  12.5k|            if (NULL != spec_version) {
  ------------------
  |  Branch (3113:17): [True: 527, False: 12.0k]
  ------------------
 3114|    527|                ext_prop.specVersion = (uint32_t)strtoul(spec_version, NULL, 10);
 3115|    527|            }
 3116|  12.5k|            loader_instance_heap_free(inst, spec_version);
 3117|       |
 3118|  12.5k|            cJSON *entrypoints = loader_cJSON_GetObjectItem(ext_item, "entrypoints");
 3119|  12.5k|            if (entrypoints == NULL) {
  ------------------
  |  Branch (3119:17): [True: 9.88k, False: 2.66k]
  ------------------
 3120|  9.88k|                result = loader_add_to_dev_ext_list(inst, &props.device_extension_list, &ext_prop, NULL);
 3121|  9.88k|                if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3121:21): [True: 0, False: 9.88k]
  ------------------
 3122|  9.88k|                continue;
 3123|  9.88k|            }
 3124|       |
 3125|  2.66k|            struct loader_string_list entrys = {0};
 3126|  2.66k|            result = loader_parse_json_array_of_strings(inst, ext_item, "entrypoints", &entrys);
 3127|  2.66k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3127:17): [True: 0, False: 2.66k]
  ------------------
 3128|  2.66k|            result = loader_add_to_dev_ext_list(inst, &props.device_extension_list, &ext_prop, &entrys);
 3129|  2.66k|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3129:17): [True: 0, False: 2.66k]
  ------------------
 3130|  2.66k|        }
 3131|  6.97k|    }
 3132|   116k|    if (is_implicit) {
  ------------------
  |  Branch (3132:9): [True: 10.0k, False: 106k]
  ------------------
 3133|  10.0k|        cJSON *enable_environment = loader_cJSON_GetObjectItem(layer_node, "enable_environment");
 3134|       |
 3135|       |        // enable_environment is optional
 3136|  10.0k|        if (enable_environment && enable_environment->child && enable_environment->child->type == cJSON_String &&
  ------------------
  |  |  101|  10.7k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (3136:13): [True: 1.40k, False: 8.61k]
  |  Branch (3136:35): [True: 757, False: 652]
  |  Branch (3136:64): [True: 740, False: 17]
  ------------------
 3137|    740|            enable_environment->child->string && enable_environment->child->valuestring) {
  ------------------
  |  Branch (3137:13): [True: 697, False: 43]
  |  Branch (3137:50): [True: 697, False: 0]
  ------------------
 3138|    697|            result = loader_copy_to_new_str(inst, enable_environment->child->string, &(props.enable_env_var.name));
 3139|    697|            if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3139:17): [True: 0, False: 697]
  ------------------
 3140|    697|            result = loader_copy_to_new_str(inst, enable_environment->child->valuestring, &(props.enable_env_var.value));
 3141|    697|            if (VK_SUCCESS != result) goto out;
  ------------------
  |  Branch (3141:17): [True: 0, False: 697]
  ------------------
 3142|    697|        }
 3143|  10.0k|    }
 3144|       |
 3145|       |    // Read in the pre-instance stuff
 3146|   116k|    cJSON *pre_instance = loader_cJSON_GetObjectItem(layer_node, "pre_instance_functions");
 3147|   116k|    if (NULL != pre_instance) {
  ------------------
  |  Branch (3147:9): [True: 486, False: 116k]
  ------------------
 3148|       |        // Supported versions started in 1.1.2, so anything newer
 3149|    486|        if (!loader_check_version_meets_required(loader_combine_version(1, 1, 2), version)) {
  ------------------
  |  Branch (3149:13): [True: 209, False: 277]
  ------------------
 3150|    209|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3151|    209|                       "Found pre_instance_functions section in layer from \"%s\". This section is only valid in manifest version "
 3152|    209|                       "1.1.2 or later. The section will be ignored",
 3153|    209|                       filename);
 3154|    277|        } else if (!is_implicit) {
  ------------------
  |  Branch (3154:20): [True: 203, False: 74]
  ------------------
 3155|    203|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
 3156|    203|                       "Found pre_instance_functions section in explicit layer from \"%s\". This section is only valid in implicit "
 3157|    203|                       "layers. The section will be ignored",
 3158|    203|                       filename);
 3159|    203|        } else {
 3160|     74|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceExtensionProperties",
 3161|     74|                                              &props.pre_instance_functions.enumerate_instance_extension_properties);
 3162|     74|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3162:17): [True: 0, False: 74]
  ------------------
 3163|       |
 3164|     74|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceLayerProperties",
 3165|     74|                                              &props.pre_instance_functions.enumerate_instance_layer_properties);
 3166|     74|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3166:17): [True: 0, False: 74]
  ------------------
 3167|       |
 3168|     74|            result = loader_parse_json_string(pre_instance, "vkEnumerateInstanceVersion",
 3169|     74|                                              &props.pre_instance_functions.enumerate_instance_version);
 3170|     74|            if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3170:17): [True: 0, False: 74]
  ------------------
 3171|     74|        }
 3172|    486|    }
 3173|       |
 3174|   116k|    if (loader_cJSON_GetObjectItem(layer_node, "app_keys")) {
  ------------------
  |  Branch (3174:9): [True: 2.91k, False: 113k]
  ------------------
 3175|  2.91k|        if (!props.is_override) {
  ------------------
  |  Branch (3175:13): [True: 1.60k, False: 1.31k]
  ------------------
 3176|  1.60k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3177|  1.60k|                       "Layer %s contains app_keys, but any app_keys can only be provided by the override meta layer. "
 3178|  1.60k|                       "These will be ignored.",
 3179|  1.60k|                       props.info.layerName);
 3180|  1.60k|        }
 3181|       |
 3182|  2.91k|        result = loader_parse_json_array_of_strings(inst, layer_node, "app_keys", &props.app_key_paths);
 3183|  2.91k|        if (result == VK_ERROR_OUT_OF_HOST_MEMORY) goto out;
  ------------------
  |  Branch (3183:13): [True: 0, False: 2.91k]
  ------------------
 3184|  2.91k|    }
 3185|       |
 3186|   116k|    char *library_arch = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(layer_node, "library_arch"));
 3187|   116k|    if (NULL != library_arch) {
  ------------------
  |  Branch (3187:9): [True: 274, False: 116k]
  ------------------
 3188|    274|        if ((strncmp(library_arch, "32", 2) == 0 && sizeof(void *) != 4) ||
  ------------------
  |  Branch (3188:14): [True: 195, False: 79]
  |  Branch (3188:53): [True: 0, Folded]
  ------------------
 3189|    195|            (strncmp(library_arch, "64", 2) == 0 && sizeof(void *) != 8)) {
  ------------------
  |  Branch (3189:14): [True: 0, False: 79]
  |  Branch (3189:53): [Folded, False: 0]
  ------------------
 3190|    195|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 3191|    195|                       "The library architecture in layer %s doesn't match the current running architecture, skipping this layer",
 3192|    195|                       filename);
 3193|    195|            result = VK_ERROR_INITIALIZATION_FAILED;
 3194|    195|            goto out;
 3195|    195|        }
 3196|    274|    }
 3197|       |
 3198|   116k|    result = VK_SUCCESS;
 3199|       |
 3200|   300k|out:
 3201|       |    // Try to append the layer property
 3202|   300k|    if (VK_SUCCESS == result) {
  ------------------
  |  Branch (3202:9): [True: 116k, False: 183k]
  ------------------
 3203|   116k|        result = loader_append_layer_property(inst, layer_instance_list, &props);
 3204|   116k|    }
 3205|       |    // If appending fails - free all the memory allocated in it
 3206|   300k|    if (VK_SUCCESS != result) {
  ------------------
  |  Branch (3206:9): [True: 183k, False: 116k]
  ------------------
 3207|   183k|        loader_free_layer_properties(inst, &props);
 3208|   183k|    }
 3209|   300k|    return result;
 3210|   116k|}
is_valid_layer_json_version:
 3212|  8.88k|bool is_valid_layer_json_version(const loader_api_version *layer_json) {
 3213|       |    // Supported versions are: 1.0.0, 1.0.1, 1.1.0 - 1.1.2, and 1.2.0 - 1.2.1.
 3214|  8.88k|    if ((layer_json->major == 1 && layer_json->minor == 2 && layer_json->patch < 2) ||
  ------------------
  |  Branch (3214:10): [True: 1.71k, False: 7.16k]
  |  Branch (3214:36): [True: 193, False: 1.52k]
  |  Branch (3214:62): [True: 150, False: 43]
  ------------------
 3215|  8.73k|        (layer_json->major == 1 && layer_json->minor == 1 && layer_json->patch < 3) ||
  ------------------
  |  Branch (3215:10): [True: 1.56k, False: 7.16k]
  |  Branch (3215:36): [True: 591, False: 974]
  |  Branch (3215:62): [True: 252, False: 339]
  ------------------
 3216|  8.48k|        (layer_json->major == 1 && layer_json->minor == 0 && layer_json->patch < 2)) {
  ------------------
  |  Branch (3216:10): [True: 1.31k, False: 7.16k]
  |  Branch (3216:36): [True: 726, False: 587]
  |  Branch (3216:62): [True: 603, False: 123]
  ------------------
 3217|  1.00k|        return true;
 3218|  1.00k|    }
 3219|  7.87k|    return false;
 3220|  8.88k|}
loader_add_layer_properties:
 3232|  11.0k|                                     bool is_implicit, char *filename) {
 3233|       |    // The following Fields in layer manifest file that are required:
 3234|       |    //   - "file_format_version"
 3235|       |    //   - If more than one "layer" object are used, then the "layers" array is
 3236|       |    //     required
 3237|  11.0k|    VkResult result = VK_ERROR_INITIALIZATION_FAILED;
 3238|       |    // Make sure sure the top level json value is an object
 3239|  11.0k|    if (!json || json->type != cJSON_Object) {
  ------------------
  |  |  103|  11.0k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3239:9): [True: 0, False: 11.0k]
  |  Branch (3239:18): [True: 2.06k, False: 8.98k]
  ------------------
 3240|  2.06k|        goto out;
 3241|  2.06k|    }
 3242|  8.98k|    char *file_vers = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(json, "file_format_version"));
 3243|  8.98k|    if (NULL == file_vers) {
  ------------------
  |  Branch (3243:9): [True: 104, False: 8.88k]
  ------------------
 3244|    104|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3245|    104|                   "loader_add_layer_properties: Manifest %s missing required field file_format_version", filename);
 3246|    104|        goto out;
 3247|    104|    }
 3248|       |
 3249|  8.88k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Found manifest file %s (file version %s)", filename, file_vers);
 3250|       |    // Get the major/minor/and patch as integers for easier comparison
 3251|  8.88k|    loader_api_version json_version = loader_make_full_version(loader_parse_version_string(file_vers));
 3252|       |
 3253|  8.88k|    if (!is_valid_layer_json_version(&json_version)) {
  ------------------
  |  Branch (3253:9): [True: 7.87k, False: 1.00k]
  ------------------
 3254|  7.87k|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3255|  7.87k|                   "loader_add_layer_properties: %s has unknown layer manifest file version %d.%d.%d.  May cause errors.", filename,
 3256|  7.87k|                   json_version.major, json_version.minor, json_version.patch);
 3257|  7.87k|    }
 3258|       |
 3259|       |    // If "layers" is present, read in the array of layer objects
 3260|  8.88k|    cJSON *layers_node = loader_cJSON_GetObjectItem(json, "layers");
 3261|  8.88k|    if (layers_node != NULL) {
  ------------------
  |  Branch (3261:9): [True: 7.66k, False: 1.21k]
  ------------------
 3262|       |        // Supported versions started in 1.0.1, so anything newer
 3263|  7.66k|        if (!loader_check_version_meets_required(loader_combine_version(1, 0, 1), json_version)) {
  ------------------
  |  Branch (3263:13): [True: 2.79k, False: 4.86k]
  ------------------
 3264|  2.79k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3265|  2.79k|                       "loader_add_layer_properties: \'layers\' tag not supported until file version 1.0.1, but %s is reporting "
 3266|  2.79k|                       "version %s",
 3267|  2.79k|                       filename, file_vers);
 3268|  2.79k|        }
 3269|  7.66k|        cJSON *layer_node = NULL;
 3270|   297k|        cJSON_ArrayForEach(layer_node, layers_node) {
  ------------------
  |  |  213|   304k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 7.66k, False: 0]
  |  |  |  Branch (213:61): [True: 297k, False: 7.10k]
  |  |  ------------------
  ------------------
 3271|   297k|            if (layer_node->type != cJSON_Object) {
  ------------------
  |  |  103|   297k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (3271:17): [True: 560, False: 297k]
  ------------------
 3272|    560|                loader_log(
 3273|    560|                    inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3274|    560|                    "loader_add_layer_properties: Array element in \"layers\" field in manifest JSON file %s is not an object.  "
 3275|    560|                    "Skipping this file",
 3276|    560|                    filename);
 3277|    560|                goto out;
 3278|    560|            }
 3279|   297k|            result = loader_read_layer_json(inst, layer_instance_list, layer_node, json_version, is_implicit, filename);
 3280|   297k|        }
 3281|  7.66k|    } else {
 3282|       |        // Otherwise, try to read in individual layers
 3283|  1.21k|        cJSON *layer_node = loader_cJSON_GetObjectItem(json, "layer");
 3284|  1.21k|        if (layer_node == NULL) {
  ------------------
  |  Branch (3284:13): [True: 710, False: 506]
  ------------------
 3285|       |            // Don't warn if this happens to be an ICD manifest
 3286|    710|            if (loader_cJSON_GetObjectItem(json, "ICD") == NULL) {
  ------------------
  |  Branch (3286:17): [True: 691, False: 19]
  ------------------
 3287|    691|                loader_log(
 3288|    691|                    inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3289|    691|                    "loader_add_layer_properties: Can not find 'layer' object in manifest JSON file %s.  Skipping this file.",
 3290|    691|                    filename);
 3291|    691|            }
 3292|    710|            goto out;
 3293|    710|        }
 3294|       |        // Loop through all "layer" objects in the file to get a count of them
 3295|       |        // first.
 3296|    506|        uint16_t layer_count = 0;
 3297|    506|        cJSON *tempNode = layer_node;
 3298|  3.84k|        do {
 3299|  3.84k|            tempNode = tempNode->next;
 3300|  3.84k|            layer_count++;
 3301|  3.84k|        } while (tempNode != NULL);
  ------------------
  |  Branch (3301:18): [True: 3.34k, False: 506]
  ------------------
 3302|       |
 3303|       |        // Throw a warning if we encounter multiple "layer" objects in file
 3304|       |        // versions newer than 1.0.0.  Having multiple objects with the same
 3305|       |        // name at the same level is actually a JSON standard violation.
 3306|    506|        if (layer_count > 1 && loader_check_version_meets_required(loader_combine_version(1, 0, 1), json_version)) {
  ------------------
  |  Branch (3306:13): [True: 420, False: 86]
  |  Branch (3306:32): [True: 184, False: 236]
  ------------------
 3307|    184|            loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3308|    184|                       "loader_add_layer_properties: Multiple 'layer' nodes are deprecated starting in file version \"1.0.1\".  "
 3309|    184|                       "Please use 'layers' : [] array instead in %s.",
 3310|    184|                       filename);
 3311|    322|        } else {
 3312|  3.33k|            do {
 3313|  3.33k|                result = loader_read_layer_json(inst, layer_instance_list, layer_node, json_version, is_implicit, filename);
 3314|  3.33k|                layer_node = layer_node->next;
 3315|  3.33k|            } while (layer_node != NULL);
  ------------------
  |  Branch (3315:22): [True: 3.01k, False: 322]
  ------------------
 3316|    322|        }
 3317|    506|    }
 3318|       |
 3319|  11.0k|out:
 3320|       |
 3321|  11.0k|    return result;
 3322|  8.88k|}
copy_data_file_info:
 3326|  74.9k|                             size_t relative_path_size, struct loader_string_list *search_paths) {
 3327|  74.9k|    if (NULL != cur_path) {
  ------------------
  |  Branch (3327:9): [True: 74.9k, False: 0]
  ------------------
 3328|  74.9k|        uint32_t start = 0;
 3329|  74.9k|        uint32_t stop = 0;
 3330|       |
 3331|   161k|        while (cur_path[start] != '\0') {
  ------------------
  |  Branch (3331:16): [True: 86.1k, False: 74.9k]
  ------------------
 3332|  99.4k|            while (cur_path[start] == PATH_SEPARATOR && cur_path[start] != '\0') {
  ------------------
  |  |  154|   198k|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (3332:20): [True: 13.2k, False: 86.1k]
  |  Branch (3332:57): [True: 13.2k, False: 0]
  ------------------
 3333|  13.2k|                start++;
 3334|  13.2k|            }
 3335|  86.1k|            stop = start;
 3336|  31.6M|            while (cur_path[stop] != PATH_SEPARATOR && cur_path[stop] != '\0') {
  ------------------
  |  |  154|  63.3M|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (3336:20): [True: 31.6M, False: 11.5k]
  |  Branch (3336:56): [True: 31.6M, False: 74.5k]
  ------------------
 3337|  31.6M|                stop++;
 3338|  31.6M|            }
 3339|  86.1k|            const size_t s = stop - start;
 3340|  86.1k|            if (s) {
  ------------------
  |  Branch (3340:17): [True: 86.0k, False: 102]
  ------------------
 3341|       |                // space enough for base path, relative path, path separator, and null terminator
 3342|  86.0k|                size_t new_str_len = s + relative_path_size + 2;
 3343|       |
 3344|  86.0k|                char *new_str = loader_instance_heap_calloc(inst, new_str_len, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 3345|  86.0k|                if (NULL == new_str) {
  ------------------
  |  Branch (3345:21): [True: 0, False: 86.0k]
  ------------------
 3346|      0|                    return VK_ERROR_OUT_OF_HOST_MEMORY;
 3347|      0|                }
 3348|  86.0k|                memcpy(new_str, &cur_path[start], s);
 3349|  86.0k|                new_str[s] = '\0';
 3350|       |
 3351|       |                // If this is a specific JSON file, just add it and don't add any
 3352|       |                // relative path or directory symbol to it.
 3353|  86.0k|                if (!is_json(new_str, s)) {
  ------------------
  |  Branch (3353:21): [True: 84.5k, False: 1.43k]
  ------------------
 3354|       |                    // Add the relative directory if present.
 3355|  84.5k|                    if (relative_path_size > 0) {
  ------------------
  |  Branch (3355:25): [True: 70.0k, False: 14.5k]
  ------------------
 3356|  70.0k|                        char *rel_start = new_str + s;
 3357|       |
 3358|       |                        // If last symbol written was not a directory symbol, add it.
 3359|  70.0k|                        if (*(rel_start - 1) != DIRECTORY_SYMBOL) {
  ------------------
  |  |  155|  70.0k|#define DIRECTORY_SYMBOL '/'
  ------------------
  |  Branch (3359:29): [True: 70.0k, False: 0]
  ------------------
 3360|  70.0k|                            *rel_start++ = DIRECTORY_SYMBOL;
  ------------------
  |  |  155|  70.0k|#define DIRECTORY_SYMBOL '/'
  ------------------
 3361|  70.0k|                        }
 3362|  70.0k|                        memcpy(rel_start, relative_path, relative_path_size);
 3363|  70.0k|                        rel_start[relative_path_size] = '\0';
 3364|  70.0k|                    }
 3365|  84.5k|                }
 3366|       |
 3367|  86.0k|                VkResult res = append_str_to_string_list_if_unique(inst, search_paths, new_str);
 3368|  86.0k|                if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3368:21): [True: 0, False: 86.0k]
  ------------------
 3369|      0|                    return res;
 3370|      0|                }
 3371|  86.0k|                start = stop;
 3372|  86.0k|            }
 3373|  86.1k|        }
 3374|  74.9k|    }
 3375|  74.9k|    return VK_SUCCESS;
 3376|  74.9k|}
add_if_manifest_file:
 3379|  20.5k|VkResult add_if_manifest_file(const struct loader_instance *inst, const char *file_name, struct loader_string_list *out_files) {
 3380|  20.5k|    assert(NULL != file_name && "add_if_manifest_file: Received NULL pointer for file_name");
 3381|  20.5k|    assert(NULL != out_files && "add_if_manifest_file: Received NULL pointer for out_files");
 3382|       |
 3383|       |    // Look for files ending with ".json" suffix
 3384|  20.5k|    size_t name_len = strlen(file_name);
 3385|  20.5k|    if (!is_json(file_name, name_len)) {
  ------------------
  |  Branch (3385:9): [True: 12.7k, False: 7.78k]
  ------------------
 3386|       |        // Use incomplete to indicate invalid name, but to keep going.
 3387|  12.7k|        return VK_INCOMPLETE;
 3388|  12.7k|    }
 3389|       |
 3390|  7.78k|    return copy_str_to_string_list(inst, out_files, file_name, name_len);
 3391|  20.5k|}
add_data_files:
 3412|  10.2k|                        struct loader_string_list *out_files) {
 3413|  10.2k|    VkResult vk_result = VK_SUCCESS;
 3414|  10.2k|    char full_path[2048];
 3415|  10.2k|#if !defined(_WIN32)
 3416|  10.2k|    char temp_path[2048];
 3417|  10.2k|#endif
 3418|       |
 3419|  83.2k|    for (size_t i = 0; i < search_paths->count; i++) {
  ------------------
  |  Branch (3419:24): [True: 73.0k, False: 10.2k]
  ------------------
 3420|       |        // Now, parse the paths
 3421|  73.0k|        char *next_file = search_paths->list[i];
 3422|   146k|        while (NULL != next_file && *next_file != '\0') {
  ------------------
  |  Branch (3422:16): [True: 146k, False: 0]
  |  Branch (3422:37): [True: 73.0k, False: 73.0k]
  ------------------
 3423|  73.0k|            char *name = NULL;
 3424|  73.0k|            char *cur_file = next_file;
 3425|  73.0k|            next_file = loader_get_next_path(cur_file);
 3426|       |
 3427|       |            // Is this a JSON file, then try to open it.
 3428|  73.0k|            size_t len = strlen(cur_file);
 3429|  73.0k|            if (is_json(cur_file, len)) {
  ------------------
  |  Branch (3429:17): [True: 686, False: 72.3k]
  ------------------
 3430|       |#if defined(_WIN32)
 3431|       |                name = cur_file;
 3432|       |#elif COMMON_UNIX_PLATFORMS
 3433|       |                // Only Linux has relative paths, make a copy of location so it isn't modified
 3434|    686|                size_t str_len;
 3435|    686|                if (NULL != next_file) {
  ------------------
  |  Branch (3435:21): [True: 686, False: 0]
  ------------------
 3436|    686|                    str_len = next_file - cur_file + 1;
 3437|    686|                } else {
 3438|      0|                    str_len = strlen(cur_file) + 1;
 3439|      0|                }
 3440|    686|                if (str_len > sizeof(temp_path)) {
  ------------------
  |  Branch (3440:21): [True: 72, False: 614]
  ------------------
 3441|     72|                    loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "add_data_files: Path to %s too long", cur_file);
 3442|     72|                    continue;
 3443|     72|                }
 3444|    614|                strncpy(temp_path, cur_file, str_len);
 3445|    614|                name = temp_path;
 3446|       |#else
 3447|       |#warning add_data_files must define relative path copy for this platform
 3448|       |#endif
 3449|    614|                loader_get_fullpath(cur_file, name, sizeof(full_path), full_path);
 3450|    614|                name = full_path;
 3451|       |
 3452|    614|                VkResult local_res;
 3453|    614|                local_res = add_if_manifest_file(inst, name, out_files);
 3454|       |
 3455|       |                // Incomplete means this was not a valid data file.
 3456|    614|                if (local_res == VK_INCOMPLETE) {
  ------------------
  |  Branch (3456:21): [True: 0, False: 614]
  ------------------
 3457|      0|                    continue;
 3458|      0|                }
 3459|    614|                if (local_res != VK_SUCCESS) {
  ------------------
  |  Branch (3459:21): [True: 0, False: 614]
  ------------------
 3460|      0|                    vk_result = local_res;
 3461|      0|                    break;
 3462|      0|                }
 3463|  72.3k|            } else {  // Otherwise, treat it as a directory
 3464|  72.3k|                DIR *dir_stream = loader_opendir(inst, cur_file);
 3465|  72.3k|                if (NULL == dir_stream) {
  ------------------
  |  Branch (3465:21): [True: 66.8k, False: 5.50k]
  ------------------
 3466|  66.8k|                    continue;
 3467|  66.8k|                }
 3468|  25.4k|                while (1) {
  ------------------
  |  Branch (3468:24): [True: 25.4k, Folded]
  ------------------
 3469|  25.4k|                    errno = 0;
 3470|       |                    // NOLINTNEXTLINE(concurrency-mt-unsafe) - readdir is safe here since each thread uses its own dir_stream
 3471|  25.4k|                    struct dirent *dir_entry = readdir(dir_stream);
 3472|  25.4k|#if !defined(WIN32)  // Windows doesn't use readdir, don't check errors on functions which aren't called
 3473|  25.4k|                    if (errno != 0) {
  ------------------
  |  Branch (3473:25): [True: 0, False: 25.4k]
  ------------------
 3474|       |                        // NOLINTNEXTLINE(concurrency-mt-unsafe) - strerror's static buffer is used immediately and not retained
 3475|      0|                        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "readdir failed with %d: %s", errno, strerror(errno));
 3476|      0|                        break;
 3477|      0|                    }
 3478|  25.4k|#endif
 3479|  25.4k|                    if (NULL == dir_entry) {
  ------------------
  |  Branch (3479:25): [True: 5.50k, False: 19.9k]
  ------------------
 3480|  5.50k|                        break;
 3481|  5.50k|                    }
 3482|       |
 3483|  19.9k|                    name = &(dir_entry->d_name[0]);
 3484|       |                    // 'name' is the bare filename, 'cur_file' is the directory being scanned; the substring "file" in
 3485|       |                    // cur_file just confuses the naming heuristic below.
 3486|       |                    // NOLINTNEXTLINE(readability-suspicious-call-argument) - arguments are correctly ordered, not swapped
 3487|  19.9k|                    loader_get_fullpath(name, cur_file, sizeof(full_path), full_path);
 3488|  19.9k|                    name = full_path;
 3489|       |
 3490|  19.9k|                    VkResult local_res;
 3491|  19.9k|                    local_res = add_if_manifest_file(inst, name, out_files);
 3492|       |
 3493|       |                    // Incomplete means this was not a valid data file.
 3494|  19.9k|                    if (local_res == VK_INCOMPLETE) {
  ------------------
  |  Branch (3494:25): [True: 12.7k, False: 7.17k]
  ------------------
 3495|  12.7k|                        continue;
 3496|  12.7k|                    }
 3497|  7.17k|                    if (local_res != VK_SUCCESS) {
  ------------------
  |  Branch (3497:25): [True: 0, False: 7.17k]
  ------------------
 3498|      0|                        vk_result = local_res;
 3499|      0|                        break;
 3500|      0|                    }
 3501|  7.17k|                }
 3502|  5.50k|                loader_closedir(inst, dir_stream);
 3503|  5.50k|                if (vk_result != VK_SUCCESS) {
  ------------------
  |  Branch (3503:21): [True: 0, False: 5.50k]
  ------------------
 3504|      0|                    goto out;
 3505|      0|                }
 3506|  5.50k|            }
 3507|  73.0k|        }
 3508|  73.0k|    }
 3509|       |
 3510|  10.2k|out:
 3511|       |
 3512|  10.2k|    return vk_result;
 3513|  10.2k|}
read_data_files_in_search_paths:
 3519|  10.2k|                                         struct loader_string_list *out_files) {
 3520|  10.2k|    VkResult vk_result = VK_SUCCESS;
 3521|  10.2k|    char *override_env = NULL;
 3522|  10.2k|    char *additional_env = NULL;
 3523|  10.2k|    struct loader_string_list search_paths = {0};
 3524|       |
 3525|  10.2k|#if COMMON_UNIX_PLATFORMS
 3526|  10.2k|    const char *relative_location = NULL;  // Only used on unix platforms
 3527|  10.2k|    size_t rel_size = 0;                   // unused in windows, dont declare so no compiler warnings are generated
 3528|  10.2k|#endif
 3529|       |
 3530|       |#if defined(__APPLE__)
 3531|       |    char *bundle_path = NULL;
 3532|       |    char *search_only_in_bundle_env_var = loader_secure_getenv(VK_LOADER_SEARCH_ONLY_IN_BUNDLE_ENV_VAR, inst);
 3533|       |#endif
 3534|       |
 3535|       |#if defined(_WIN32)
 3536|       |    char *package_path = NULL;
 3537|       |#elif COMMON_UNIX_PLATFORMS
 3538|       |    // Determine how much space is needed to generate the full search path
 3539|       |    // for the current manifest files.
 3540|  10.2k|    char *xdg_config_home = loader_secure_getenv("XDG_CONFIG_HOME", inst);
 3541|  10.2k|    char *xdg_config_dirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst);
 3542|       |
 3543|  10.2k|#if !defined(__Fuchsia__) && !defined(__QNX__)
 3544|  10.2k|    if (NULL == xdg_config_dirs || '\0' == xdg_config_dirs[0]) {
  ------------------
  |  Branch (3544:9): [True: 10.2k, False: 0]
  |  Branch (3544:36): [True: 0, False: 0]
  ------------------
 3545|  10.2k|        xdg_config_dirs = FALLBACK_CONFIG_DIRS;
 3546|  10.2k|    }
 3547|  10.2k|#endif
 3548|       |
 3549|  10.2k|    char *xdg_data_home = loader_secure_getenv("XDG_DATA_HOME", inst);
 3550|  10.2k|    char *xdg_data_dirs = loader_secure_getenv("XDG_DATA_DIRS", inst);
 3551|       |
 3552|  10.2k|#if !defined(__Fuchsia__) && !defined(__QNX__)
 3553|  10.2k|    if (NULL == xdg_data_dirs || '\0' == xdg_data_dirs[0]) {
  ------------------
  |  Branch (3553:9): [True: 10.2k, False: 0]
  |  Branch (3553:34): [True: 0, False: 0]
  ------------------
 3554|  10.2k|        xdg_data_dirs = FALLBACK_DATA_DIRS;
 3555|  10.2k|    }
 3556|  10.2k|#endif
 3557|       |
 3558|  10.2k|    char *home = NULL;
 3559|  10.2k|    char *default_data_home = NULL;
 3560|  10.2k|    char *default_config_home = NULL;
 3561|  10.2k|    char *home_data_dir = NULL;
 3562|  10.2k|    char *home_config_dir = NULL;
 3563|       |
 3564|       |    // Only use HOME if XDG_DATA_HOME is not present on the system
 3565|  10.2k|    home = loader_secure_getenv("HOME", inst);
 3566|  10.2k|    if (home != NULL) {
  ------------------
  |  Branch (3566:9): [True: 10.2k, False: 0]
  ------------------
 3567|  10.2k|        if (NULL == xdg_config_home || '\0' == xdg_config_home[0]) {
  ------------------
  |  Branch (3567:13): [True: 10.2k, False: 0]
  |  Branch (3567:40): [True: 0, False: 0]
  ------------------
 3568|  10.2k|            const char config_suffix[] = "/.config";
 3569|  10.2k|            size_t default_config_home_len = strlen(home) + sizeof(config_suffix) + 1;
 3570|  10.2k|            default_config_home = loader_instance_heap_calloc(inst, default_config_home_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3571|  10.2k|            if (default_config_home == NULL) {
  ------------------
  |  Branch (3571:17): [True: 0, False: 10.2k]
  ------------------
 3572|      0|                vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3573|      0|                goto out;
 3574|      0|            }
 3575|  10.2k|            strncpy(default_config_home, home, default_config_home_len);
 3576|  10.2k|            strncat(default_config_home, config_suffix, default_config_home_len);
 3577|  10.2k|        }
 3578|  10.2k|        if (NULL == xdg_data_home || '\0' == xdg_data_home[0]) {
  ------------------
  |  Branch (3578:13): [True: 10.2k, False: 0]
  |  Branch (3578:38): [True: 0, False: 0]
  ------------------
 3579|  10.2k|            const char data_suffix[] = "/.local/share";
 3580|  10.2k|            size_t default_data_home_len = strlen(home) + sizeof(data_suffix) + 1;
 3581|  10.2k|            default_data_home = loader_instance_heap_calloc(inst, default_data_home_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3582|  10.2k|            if (default_data_home == NULL) {
  ------------------
  |  Branch (3582:17): [True: 0, False: 10.2k]
  ------------------
 3583|      0|                vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3584|      0|                goto out;
 3585|      0|            }
 3586|  10.2k|            strncpy(default_data_home, home, default_data_home_len);
 3587|  10.2k|            strncat(default_data_home, data_suffix, default_data_home_len);
 3588|  10.2k|        }
 3589|  10.2k|    }
 3590|       |
 3591|  10.2k|    if (NULL != default_config_home) {
  ------------------
  |  Branch (3591:9): [True: 10.2k, False: 0]
  ------------------
 3592|  10.2k|        home_config_dir = default_config_home;
 3593|  10.2k|    } else {
 3594|      0|        home_config_dir = xdg_config_home;
 3595|      0|    }
 3596|  10.2k|    if (NULL != default_data_home) {
  ------------------
  |  Branch (3596:9): [True: 10.2k, False: 0]
  ------------------
 3597|  10.2k|        home_data_dir = default_data_home;
 3598|  10.2k|    } else {
 3599|      0|        home_data_dir = xdg_data_home;
 3600|      0|    }
 3601|       |#else
 3602|       |#warning read_data_files_in_search_paths unsupported platform
 3603|       |#endif
 3604|       |
 3605|  10.2k|    switch (manifest_type) {
 3606|      5|        case LOADER_DATA_FILE_MANIFEST_DRIVER:
  ------------------
  |  Branch (3606:9): [True: 5, False: 10.2k]
  ------------------
 3607|      5|            if (loader_settings_should_use_driver_environment_variables(inst)) {
  ------------------
  |  Branch (3607:17): [True: 5, False: 0]
  ------------------
 3608|      5|                override_env = loader_secure_getenv(VK_DRIVER_FILES_ENV_VAR, inst);
  ------------------
  |  |  113|      5|#define VK_DRIVER_FILES_ENV_VAR "VK_DRIVER_FILES"
  ------------------
 3609|      5|                if (NULL == override_env) {
  ------------------
  |  Branch (3609:21): [True: 5, False: 0]
  ------------------
 3610|       |                    // Not there, so fall back to the old name
 3611|      5|                    override_env = loader_secure_getenv(VK_ICD_FILENAMES_ENV_VAR, inst);
  ------------------
  |  |  112|      5|#define VK_ICD_FILENAMES_ENV_VAR "VK_ICD_FILENAMES"  // Deprecated in v1.3.207 loader
  ------------------
 3612|      5|                }
 3613|      5|                additional_env = loader_secure_getenv(VK_ADDITIONAL_DRIVER_FILES_ENV_VAR, inst);
  ------------------
  |  |  116|      5|#define VK_ADDITIONAL_DRIVER_FILES_ENV_VAR "VK_ADD_DRIVER_FILES"
  ------------------
 3614|      5|            }
 3615|      5|#if COMMON_UNIX_PLATFORMS
 3616|      5|            relative_location = VK_DRIVERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  165|      5|#define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
  |  |  ------------------
  |  |  |  |  157|      5|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
  |  |  ------------------
  |  |  |  |  158|      5|#define VULKAN_ICDCONF_DIR "icd.d"
  |  |  ------------------
  ------------------
 3617|      5|#endif
 3618|       |#if defined(_WIN32)
 3619|       |            package_path = windows_get_app_package_manifest_path(inst);
 3620|       |#endif
 3621|      5|            break;
 3622|  5.10k|        case LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER:
  ------------------
  |  Branch (3622:9): [True: 5.10k, False: 5.10k]
  ------------------
 3623|  5.10k|            override_env = loader_secure_getenv(VK_IMPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  130|  5.10k|#define VK_IMPLICIT_LAYER_PATH_ENV_VAR "VK_IMPLICIT_LAYER_PATH"
  ------------------
 3624|  5.10k|            additional_env = loader_secure_getenv(VK_ADDITIONAL_IMPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  131|  5.10k|#define VK_ADDITIONAL_IMPLICIT_LAYER_PATH_ENV_VAR "VK_ADD_IMPLICIT_LAYER_PATH"
  ------------------
 3625|  5.10k|#if COMMON_UNIX_PLATFORMS
 3626|  5.10k|            relative_location = VK_ILAYERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  168|  5.10k|#define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  157|  5.10k|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  162|  5.10k|#define VULKAN_ILAYERCONF_DIR "implicit_layer.d"
  |  |  ------------------
  ------------------
 3627|  5.10k|#endif
 3628|       |#if defined(_WIN32)
 3629|       |            package_path = windows_get_app_package_manifest_path(inst);
 3630|       |#endif
 3631|  5.10k|            break;
 3632|  5.10k|        case LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER:
  ------------------
  |  Branch (3632:9): [True: 5.10k, False: 5.10k]
  ------------------
 3633|  5.10k|            override_env = loader_secure_getenv(VK_EXPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  114|  5.10k|#define VK_EXPLICIT_LAYER_PATH_ENV_VAR "VK_LAYER_PATH"
  ------------------
 3634|  5.10k|            additional_env = loader_secure_getenv(VK_ADDITIONAL_EXPLICIT_LAYER_PATH_ENV_VAR, inst);
  ------------------
  |  |  117|  5.10k|#define VK_ADDITIONAL_EXPLICIT_LAYER_PATH_ENV_VAR "VK_ADD_LAYER_PATH"
  ------------------
 3635|  5.10k|#if COMMON_UNIX_PLATFORMS
 3636|  5.10k|            relative_location = VK_ELAYERS_INFO_RELATIVE_DIR;
  ------------------
  |  |  167|  5.10k|#define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  157|  5.10k|#define VULKAN_DIR "vulkan/"
  |  |  ------------------
  |  |               #define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
  |  |  ------------------
  |  |  |  |  161|  5.10k|#define VULKAN_ELAYERCONF_DIR "explicit_layer.d"
  |  |  ------------------
  ------------------
 3637|  5.10k|#endif
 3638|  5.10k|            break;
 3639|      0|        default:
  ------------------
  |  Branch (3639:9): [True: 0, False: 10.2k]
  ------------------
 3640|      0|            assert(false && "Shouldn't get here!");
 3641|      0|            break;
 3642|  10.2k|    }
 3643|       |
 3644|       |    // Log a message when VK_LAYER_PATH is set but the override layer paths take priority
 3645|  10.2k|    if (manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER &&
  ------------------
  |  Branch (3645:9): [True: 5.10k, False: 5.10k]
  ------------------
 3646|  5.10k|        (NULL != override_env && NULL != path_overrides && path_overrides->count > 0)) {
  ------------------
  |  Branch (3646:10): [True: 0, False: 5.10k]
  |  Branch (3646:34): [True: 0, False: 0]
  |  Branch (3646:60): [True: 0, False: 0]
  ------------------
 3647|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0,
 3648|      0|                   "Ignoring VK_LAYER_PATH. The Override layer is active and has override paths set, which takes priority. "
 3649|      0|                   "VK_LAYER_PATH is set to %s",
 3650|      0|                   override_env);
 3651|      0|    }
 3652|       |
 3653|       |    // Add the remaining paths to the list
 3654|  10.2k|    if (NULL != path_overrides && path_overrides->count > 0) {
  ------------------
  |  Branch (3654:9): [True: 5.10k, False: 5.10k]
  |  Branch (3654:35): [True: 212, False: 4.89k]
  ------------------
 3655|  3.28k|        for (size_t i = 0; i < path_overrides->count; i++) {
  ------------------
  |  Branch (3655:28): [True: 3.07k, False: 212]
  ------------------
 3656|  3.07k|            if (NULL != path_overrides->list[i]) {
  ------------------
  |  Branch (3656:17): [True: 3.07k, False: 0]
  ------------------
 3657|  3.07k|                if (manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER) {
  ------------------
  |  Branch (3657:21): [True: 3.07k, False: 0]
  ------------------
 3658|  3.07k|                    loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_LAYER_BIT, 0, "%s", path_overrides->list[i]);
 3659|  3.07k|                }
 3660|  3.07k|                vk_result = copy_data_file_info(inst, path_overrides->list[i], NULL, 0, &search_paths);
 3661|  3.07k|                if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3661:21): [True: 0, False: 3.07k]
  ------------------
 3662|      0|                    goto out;
 3663|      0|                }
 3664|  3.07k|            }
 3665|  3.07k|        }
 3666|  10.0k|    } else if (override_env != NULL) {
  ------------------
  |  Branch (3666:16): [True: 0, False: 10.0k]
  ------------------
 3667|      0|        vk_result = copy_data_file_info(inst, override_env, NULL, 0, &search_paths);
 3668|      0|        if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3668:13): [True: 0, False: 0]
  ------------------
 3669|      0|            goto out;
 3670|      0|        }
 3671|  10.0k|    } else {
 3672|       |        // Add any additional search paths defined in the additive environment variable
 3673|  10.0k|        if (NULL != additional_env) {
  ------------------
  |  Branch (3673:13): [True: 0, False: 10.0k]
  ------------------
 3674|      0|            vk_result = copy_data_file_info(inst, additional_env, NULL, 0, &search_paths);
 3675|      0|            if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3675:17): [True: 0, False: 0]
  ------------------
 3676|      0|                goto out;
 3677|      0|            }
 3678|      0|        }
 3679|       |
 3680|       |#if defined(_WIN32)
 3681|       |        if (NULL != package_path) {
 3682|       |            vk_result = copy_data_file_info(inst, package_path, NULL, 0, &search_paths);
 3683|       |            if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
 3684|       |                goto out;
 3685|       |            }
 3686|       |        }
 3687|       |#elif COMMON_UNIX_PLATFORMS
 3688|  10.0k|        bool search_outside_of_bundle = true;
 3689|       |
 3690|  10.0k|        rel_size = strlen(relative_location);
 3691|  10.0k|        if (rel_size > 0) {
  ------------------
  |  Branch (3691:13): [True: 10.0k, False: 0]
  ------------------
 3692|       |#if defined(__APPLE__)
 3693|       |            // Add the bundle's Resources dir to the beginning of the search path.
 3694|       |            // Looks for manifests in the bundle first, before any system directories.
 3695|       |            // This also appears to work unmodified for iOS, it finds the app bundle on the devices
 3696|       |            // file system. (RSW)
 3697|       |            CFBundleRef main_bundle = CFBundleGetMainBundle();
 3698|       |            if (NULL != main_bundle) {
 3699|       |                CFURLRef ref = CFBundleCopyResourcesDirectoryURL(main_bundle);
 3700|       |                if (NULL != ref) {
 3701|       |                    // Allocate large scratch buffer to hold the bundles path, the relative location inside the bundle, plus a path
 3702|       |                    // separator and null terminator. Since we are using a while loop, initialize length with half the intended size
 3703|       |                    size_t bundle_path_len = (MAXPATHLEN + rel_size + 2) / 2;
 3704|       |                    bool bundle_query_success = false;
 3705|       |                    uint32_t retry_count = 0;
 3706|       |                    while (!bundle_query_success && retry_count < 4) {
 3707|       |                        void *new_bundle_path = loader_instance_heap_realloc(
 3708|       |                            inst, bundle_path, bundle_path_len, bundle_path_len * 2, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
 3709|       |                        if (NULL == new_bundle_path) {
 3710|       |                            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3711|       |                                       "read_data_files_in_search_paths: Failed to allocate space for bundle path of length %d",
 3712|       |                                       (uint32_t)bundle_path_len * 2);
 3713|       |                            vk_result = VK_ERROR_OUT_OF_HOST_MEMORY;
 3714|       |                            goto out;
 3715|       |                        }
 3716|       |                        bundle_path = new_bundle_path;
 3717|       |                        bundle_path_len = bundle_path_len * 2;
 3718|       |                        memset(bundle_path, 0, bundle_path_len);
 3719|       |                        bundle_query_success = CFURLGetFileSystemRepresentation(ref, TRUE, (UInt8 *)bundle_path, bundle_path_len);
 3720|       |                        retry_count++;
 3721|       |                    }
 3722|       |
 3723|       |                    if (bundle_query_success) {
 3724|       |                        size_t cur_bundle_len = strlen(bundle_path);
 3725|       |
 3726|       |                        if (cur_bundle_len + rel_size + 2 > bundle_path_len) {
 3727|       |                            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 3728|       |                                       "read_data_files_in_search_paths: bundle_path %s of size %d does not have enough space to "
 3729|       |                                       "append relative_path",
 3730|       |                                       bundle_path, (uint32_t)bundle_path_len);
 3731|       |                            vk_result = VK_ERROR_INITIALIZATION_FAILED;
 3732|       |                            goto out;
 3733|       |                        }
 3734|       |                        bundle_path[cur_bundle_len] = DIRECTORY_SYMBOL;
 3735|       |                        cur_bundle_len++;
 3736|       |                        memcpy(bundle_path + cur_bundle_len, relative_location, rel_size);
 3737|       |                        cur_bundle_len += rel_size;
 3738|       |                        bundle_path[cur_bundle_len] = '\0';
 3739|       |
 3740|       |                        vk_result = copy_data_file_info(inst, bundle_path, NULL, 0, &search_paths);
 3741|       |                        if (vk_result == VK_ERROR_OUT_OF_HOST_MEMORY) {
 3742|       |                            goto out;
 3743|       |                        }
 3744|       |                    }
 3745|       |                    CFRelease(ref);
 3746|       |                }
 3747|       |            }
 3748|       |
 3749|       |            if (NULL != search_only_in_bundle_env_var) {
 3750|       |                search_outside_of_bundle = false;
 3751|       |            }
 3752|       |#endif  // __APPLE__
 3753|  10.0k|            if (search_outside_of_bundle) {
  ------------------
  |  Branch (3753:17): [True: 10.0k, False: 0]
  ------------------
 3754|       |                // Only add the home folders if not NULL
 3755|  10.0k|                if (NULL != home_config_dir) {
  ------------------
  |  Branch (3755:21): [True: 10.0k, False: 0]
  ------------------
 3756|  10.0k|                    vk_result = copy_data_file_info(inst, home_config_dir, relative_location, rel_size, &search_paths);
 3757|  10.0k|                    if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3757:25): [True: 0, False: 10.0k]
  ------------------
 3758|      0|                        goto out;
 3759|      0|                    }
 3760|  10.0k|                }
 3761|  10.0k|                vk_result = copy_data_file_info(inst, xdg_config_dirs, relative_location, rel_size, &search_paths);
 3762|  10.0k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3762:21): [True: 0, False: 10.0k]
  ------------------
 3763|      0|                    goto out;
 3764|      0|                }
 3765|  10.0k|                vk_result = copy_data_file_info(inst, SYSCONFDIR, relative_location, rel_size, &search_paths);
 3766|  10.0k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3766:21): [True: 0, False: 10.0k]
  ------------------
 3767|      0|                    goto out;
 3768|      0|                }
 3769|  10.0k|#if defined(EXTRASYSCONFDIR)
 3770|  10.0k|                vk_result = copy_data_file_info(inst, EXTRASYSCONFDIR, relative_location, rel_size, &search_paths);
 3771|  10.0k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3771:21): [True: 0, False: 10.0k]
  ------------------
 3772|      0|                    goto out;
 3773|      0|                }
 3774|  10.0k|#endif
 3775|       |
 3776|       |                // Only add the home folders if not NULL
 3777|  10.0k|                if (NULL != home_data_dir) {
  ------------------
  |  Branch (3777:21): [True: 10.0k, False: 0]
  ------------------
 3778|  10.0k|                    vk_result = copy_data_file_info(inst, home_data_dir, relative_location, rel_size, &search_paths);
 3779|  10.0k|                    if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3779:25): [True: 0, False: 10.0k]
  ------------------
 3780|      0|                        goto out;
 3781|      0|                    }
 3782|  10.0k|                }
 3783|  10.0k|                vk_result = copy_data_file_info(inst, xdg_data_dirs, relative_location, rel_size, &search_paths);
 3784|  10.0k|                if (VK_SUCCESS != vk_result) {
  ------------------
  |  Branch (3784:21): [True: 0, False: 10.0k]
  ------------------
 3785|      0|                    goto out;
 3786|      0|                }
 3787|  10.0k|            }
 3788|  10.0k|        }
 3789|       |#else
 3790|       |#warning read_data_files_in_search_paths unsupported platform
 3791|       |#endif
 3792|  10.0k|    }
 3793|       |
 3794|       |    // Print out the paths being searched if debugging is enabled
 3795|  10.2k|    uint32_t log_flags = 0;
 3796|       |
 3797|  10.2k|    if (manifest_type == LOADER_DATA_FILE_MANIFEST_DRIVER) {
  ------------------
  |  Branch (3797:9): [True: 5, False: 10.2k]
  ------------------
 3798|      5|        log_flags = VULKAN_LOADER_DRIVER_BIT;
 3799|      5|        loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Searching for driver manifest files");
 3800|  10.2k|    } else {
 3801|  10.2k|        log_flags = VULKAN_LOADER_LAYER_BIT;
 3802|  10.2k|        loader_log(inst, VULKAN_LOADER_LAYER_BIT, 0, "Searching for %s layer manifest files",
 3803|  10.2k|                   manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER ? "explicit" : "implicit");
  ------------------
  |  Branch (3803:20): [True: 5.10k, False: 5.10k]
  ------------------
 3804|  10.2k|    }
 3805|  10.2k|    loader_log(inst, log_flags, 0, "   In following locations:");
 3806|       |
 3807|  83.2k|    for (size_t i = 0; i < search_paths.count; i++) {
  ------------------
  |  Branch (3807:24): [True: 73.0k, False: 10.2k]
  ------------------
 3808|  73.0k|        loader_log(inst, log_flags, 0, "      %s", search_paths.list[i]);
 3809|  73.0k|    }
 3810|       |
 3811|       |    // Now, parse the paths and add any manifest files found in them.
 3812|  10.2k|    vk_result = add_data_files(inst, &search_paths, out_files);
 3813|       |
 3814|  10.2k|    if (log_flags != 0 && out_files->count > 0) {
  ------------------
  |  Branch (3814:9): [True: 10.2k, False: 0]
  |  Branch (3814:27): [True: 4.38k, False: 5.83k]
  ------------------
 3815|  4.38k|        loader_log(inst, log_flags, 0, "   Found the following files:");
 3816|  12.1k|        for (uint32_t cur_file = 0; cur_file < out_files->count; ++cur_file) {
  ------------------
  |  Branch (3816:37): [True: 7.78k, False: 4.38k]
  ------------------
 3817|  7.78k|            loader_log(inst, log_flags, 0, "      %s", out_files->list[cur_file]);
 3818|  7.78k|        }
 3819|  5.83k|    } else {
 3820|  5.83k|        loader_log(inst, log_flags, 0, "   Found no files");
 3821|  5.83k|    }
 3822|       |
 3823|  10.2k|    if ((NULL != path_overrides && path_overrides->count > 0) || NULL != override_env) {
  ------------------
  |  Branch (3823:10): [True: 5.10k, False: 5.10k]
  |  Branch (3823:36): [True: 212, False: 4.89k]
  |  Branch (3823:66): [True: 0, False: 10.0k]
  ------------------
 3824|    212|        *override_active = true;
 3825|  10.0k|    } else {
 3826|  10.0k|        *override_active = false;
 3827|  10.0k|    }
 3828|       |
 3829|  10.2k|out:
 3830|       |
 3831|  10.2k|    loader_free_getenv(additional_env, inst);
 3832|  10.2k|    loader_free_getenv(override_env, inst);
 3833|       |#if defined(_WIN32)
 3834|       |    loader_instance_heap_free(inst, package_path);
 3835|       |#elif COMMON_UNIX_PLATFORMS
 3836|       |#if defined(__APPLE__)
 3837|       |    loader_instance_heap_free(inst, bundle_path);
 3838|       |    loader_free_getenv(search_only_in_bundle_env_var, inst);
 3839|       |#endif
 3840|  10.2k|    loader_free_getenv(xdg_config_home, inst);
 3841|  10.2k|    loader_free_getenv(xdg_config_dirs, inst);
 3842|  10.2k|    loader_free_getenv(xdg_data_home, inst);
 3843|  10.2k|    loader_free_getenv(xdg_data_dirs, inst);
 3844|  10.2k|    loader_free_getenv(xdg_data_home, inst);
 3845|  10.2k|    loader_free_getenv(home, inst);
 3846|  10.2k|    loader_instance_heap_free(inst, default_data_home);
 3847|  10.2k|    loader_instance_heap_free(inst, default_config_home);
 3848|       |#else
 3849|       |#warning read_data_files_in_search_paths unsupported platform
 3850|       |#endif
 3851|       |
 3852|  10.2k|    free_string_list(inst, &search_paths);
 3853|       |
 3854|  10.2k|    return vk_result;
 3855|  10.2k|}
loader_get_data_files:
 3881|  10.2k|                               const struct loader_string_list *path_overrides, struct loader_string_list *out_files) {
 3882|  10.2k|    VkResult res = VK_SUCCESS;
 3883|  10.2k|    bool override_active = false;
 3884|       |
 3885|       |    // Free and init the out_files information so there's no false data left from uninitialized variables.
 3886|  10.2k|    free_string_list(inst, out_files);
 3887|       |
 3888|  10.2k|    res = read_data_files_in_search_paths(inst, manifest_type, path_overrides, &override_active, out_files);
 3889|  10.2k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3889:9): [True: 0, False: 10.2k]
  ------------------
 3890|      0|        goto out;
 3891|      0|    }
 3892|       |
 3893|       |#if defined(_WIN32)
 3894|       |    // Read the registry if the override wasn't active.
 3895|       |    if (!override_active) {
 3896|       |        bool warn_if_not_present = false;
 3897|       |        char *registry_location = NULL;
 3898|       |
 3899|       |        switch (manifest_type) {
 3900|       |            default:
 3901|       |                goto out;
 3902|       |            case LOADER_DATA_FILE_MANIFEST_DRIVER:
 3903|       |                warn_if_not_present = true;
 3904|       |                registry_location = VK_DRIVERS_INFO_REGISTRY_LOC;
 3905|       |                break;
 3906|       |            case LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER:
 3907|       |                registry_location = VK_ILAYERS_INFO_REGISTRY_LOC;
 3908|       |                break;
 3909|       |            case LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER:
 3910|       |                warn_if_not_present = true;
 3911|       |                registry_location = VK_ELAYERS_INFO_REGISTRY_LOC;
 3912|       |                break;
 3913|       |        }
 3914|       |        VkResult tmp_res =
 3915|       |            windows_read_data_files_in_registry(inst, manifest_type, warn_if_not_present, registry_location, out_files);
 3916|       |        // Only return an error if there was an error this time, and no manifest files from before.
 3917|       |        if (VK_SUCCESS != tmp_res && out_files->count == 0) {
 3918|       |            res = tmp_res;
 3919|       |            goto out;
 3920|       |        }
 3921|       |    }
 3922|       |#endif
 3923|       |
 3924|  10.2k|out:
 3925|       |
 3926|  10.2k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (3926:9): [True: 0, False: 10.2k]
  ------------------
 3927|      0|        free_string_list(inst, out_files);
 3928|      0|    }
 3929|       |
 3930|  10.2k|    return res;
 3931|  10.2k|}
loader_parse_icd_manifest:
 3941|      1|                                   bool *skipped_portability_drivers) {
 3942|      1|    VkResult res = VK_SUCCESS;
 3943|      1|    cJSON *icd_manifest_json = NULL;
 3944|       |
 3945|      1|    if (file_str == NULL) {
  ------------------
  |  Branch (3945:9): [True: 0, False: 1]
  ------------------
 3946|      0|        goto out;
 3947|      0|    }
 3948|       |
 3949|      1|    res = loader_get_json(inst, file_str, &icd_manifest_json);
 3950|      1|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (3950:9): [True: 0, False: 1]
  ------------------
 3951|      0|        goto out;
 3952|      0|    }
 3953|      1|    if (res != VK_SUCCESS || NULL == icd_manifest_json) {
  ------------------
  |  Branch (3953:9): [True: 0, False: 1]
  |  Branch (3953:30): [True: 1, False: 0]
  ------------------
 3954|      1|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3955|      1|        goto out;
 3956|      1|    }
 3957|       |
 3958|      0|    cJSON *file_format_version_json = loader_cJSON_GetObjectItem(icd_manifest_json, "file_format_version");
 3959|      0|    if (file_format_version_json == NULL) {
  ------------------
  |  Branch (3959:9): [True: 0, False: 0]
  ------------------
 3960|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3961|      0|                   "loader_parse_icd_manifest: ICD JSON %s does not have a \'file_format_version\' field. Skipping ICD JSON.",
 3962|      0|                   file_str);
 3963|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3964|      0|        goto out;
 3965|      0|    }
 3966|       |
 3967|      0|    char *file_vers_str = loader_cJSON_GetStringValue(file_format_version_json);
 3968|      0|    if (NULL == file_vers_str) {
  ------------------
  |  Branch (3968:9): [True: 0, False: 0]
  ------------------
 3969|       |        // Only reason the print can fail is if there was an allocation issue
 3970|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3971|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'file_format_version\' field. Skipping ICD JSON",
 3972|      0|                   file_str);
 3973|      0|        goto out;
 3974|      0|    }
 3975|      0|    loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Found ICD manifest file %s, version %s", file_str, file_vers_str);
 3976|       |
 3977|       |    // Get the version of the driver manifest
 3978|      0|    loader_api_version json_file_version = loader_make_full_version(loader_parse_version_string(file_vers_str));
 3979|       |
 3980|       |    // Loader only knows versions 1.0.0 and 1.0.1, anything above it is unknown
 3981|      0|    if (loader_check_version_meets_required(loader_combine_version(1, 0, 2), json_file_version)) {
  ------------------
  |  Branch (3981:9): [True: 0, False: 0]
  ------------------
 3982|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3983|      0|                   "loader_parse_icd_manifest: %s has unknown icd manifest file version %d.%d.%d. May cause errors.", file_str,
 3984|      0|                   json_file_version.major, json_file_version.minor, json_file_version.patch);
 3985|      0|    }
 3986|       |
 3987|      0|    cJSON *itemICD = loader_cJSON_GetObjectItem(icd_manifest_json, "ICD");
 3988|      0|    if (itemICD == NULL) {
  ------------------
  |  Branch (3988:9): [True: 0, False: 0]
  ------------------
 3989|       |        // Don't warn if this happens to be a layer manifest file
 3990|      0|        if (loader_cJSON_GetObjectItem(icd_manifest_json, "layer") == NULL &&
  ------------------
  |  Branch (3990:13): [True: 0, False: 0]
  ------------------
 3991|      0|            loader_cJSON_GetObjectItem(icd_manifest_json, "layers") == NULL) {
  ------------------
  |  Branch (3991:13): [True: 0, False: 0]
  ------------------
 3992|      0|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 3993|      0|                       "loader_parse_icd_manifest: Can not find \'ICD\' object in ICD JSON file %s. Skipping ICD JSON", file_str);
 3994|      0|        }
 3995|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 3996|      0|        goto out;
 3997|      0|    }
 3998|       |
 3999|      0|    cJSON *library_path_json = loader_cJSON_GetObjectItem(itemICD, "library_path");
 4000|      0|    if (library_path_json == NULL) {
  ------------------
  |  Branch (4000:9): [True: 0, False: 0]
  ------------------
 4001|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4002|      0|                   "loader_parse_icd_manifest: Failed to find \'library_path\' object in ICD JSON file %s. Skipping ICD JSON.",
 4003|      0|                   file_str);
 4004|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4005|      0|        goto out;
 4006|      0|    }
 4007|      0|    bool out_of_memory = false;
 4008|      0|    char *library_path = loader_cJSON_Print(library_path_json, &out_of_memory);
 4009|      0|    if (out_of_memory) {
  ------------------
  |  Branch (4009:9): [True: 0, False: 0]
  ------------------
 4010|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4011|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'library_path\' field. Skipping ICD JSON.", file_str);
 4012|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4013|      0|        goto out;
 4014|      0|    } else if (!library_path || strlen(library_path) == 0) {
  ------------------
  |  Branch (4014:16): [True: 0, False: 0]
  |  Branch (4014:33): [True: 0, False: 0]
  ------------------
 4015|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4016|      0|                   "loader_parse_icd_manifest: ICD JSON %s \'library_path\' field is empty. Skipping ICD JSON.", file_str);
 4017|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4018|      0|        loader_instance_heap_free(inst, library_path);
 4019|      0|        goto out;
 4020|      0|    }
 4021|       |
 4022|       |    // Print out the paths being searched if debugging is enabled
 4023|      0|    loader_log(inst, VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "Searching for ICD drivers named %s", library_path);
 4024|       |    // This function takes ownership of library_path - so we don't need to clean it up
 4025|      0|    res = combine_manifest_directory_and_library_path(inst, library_path, file_str, &icd->full_library_path);
 4026|      0|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4026:9): [True: 0, False: 0]
  ------------------
 4027|      0|        goto out;
 4028|      0|    }
 4029|       |
 4030|      0|    cJSON *api_version_json = loader_cJSON_GetObjectItem(itemICD, "api_version");
 4031|      0|    if (api_version_json == NULL) {
  ------------------
  |  Branch (4031:9): [True: 0, False: 0]
  ------------------
 4032|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4033|      0|                   "loader_parse_icd_manifest: ICD JSON %s does not have an \'api_version\' field. Skipping ICD JSON.", file_str);
 4034|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4035|      0|        goto out;
 4036|      0|    }
 4037|      0|    char *version_str = loader_cJSON_GetStringValue(api_version_json);
 4038|      0|    if (NULL == version_str) {
  ------------------
  |  Branch (4038:9): [True: 0, False: 0]
  ------------------
 4039|       |        // Only reason the print can fail is if there was an allocation issue
 4040|      0|        loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4041|      0|                   "loader_parse_icd_manifest: Failed retrieving ICD JSON %s \'api_version\' field. Skipping ICD JSON.", file_str);
 4042|       |
 4043|      0|        goto out;
 4044|      0|    }
 4045|      0|    icd->version = loader_parse_version_string(version_str);
 4046|       |
 4047|      0|    if (VK_API_VERSION_VARIANT(icd->version) != 0) {
  ------------------
  |  Branch (4047:9): [True: 0, False: 0]
  ------------------
 4048|      0|        loader_log(inst, VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4049|      0|                   "loader_parse_icd_manifest: Driver's ICD JSON %s \'api_version\' field contains a non-zero variant value of %d. "
 4050|      0|                   " Skipping ICD JSON.",
 4051|      0|                   file_str, VK_API_VERSION_VARIANT(icd->version));
 4052|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4053|      0|        goto out;
 4054|      0|    }
 4055|       |
 4056|       |    // Skip over ICD's which contain a true "is_portability_driver" value whenever the application doesn't enable
 4057|       |    // portability enumeration.
 4058|      0|    cJSON *is_portability_driver_json = loader_cJSON_GetObjectItem(itemICD, "is_portability_driver");
 4059|      0|    if (loader_cJSON_IsTrue(is_portability_driver_json) && inst && !inst->portability_enumeration_enabled) {
  ------------------
  |  Branch (4059:9): [True: 0, False: 0]
  |  Branch (4059:60): [True: 0, False: 0]
  |  Branch (4059:68): [True: 0, False: 0]
  ------------------
 4060|      0|        if (skipped_portability_drivers) {
  ------------------
  |  Branch (4060:13): [True: 0, False: 0]
  ------------------
 4061|      0|            *skipped_portability_drivers = true;
 4062|      0|        }
 4063|      0|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4064|      0|        goto out;
 4065|      0|    }
 4066|       |
 4067|      0|    char *library_arch_str = loader_cJSON_GetStringValue(loader_cJSON_GetObjectItem(itemICD, "library_arch"));
 4068|      0|    if (library_arch_str != NULL) {
  ------------------
  |  Branch (4068:9): [True: 0, False: 0]
  ------------------
 4069|      0|        if ((strncmp(library_arch_str, "32", 2) == 0 && sizeof(void *) != 4) ||
  ------------------
  |  Branch (4069:14): [True: 0, False: 0]
  |  Branch (4069:57): [True: 0, Folded]
  ------------------
 4070|      0|            (strncmp(library_arch_str, "64", 2) == 0 && sizeof(void *) != 8)) {
  ------------------
  |  Branch (4070:14): [True: 0, False: 0]
  |  Branch (4070:57): [Folded, False: 0]
  ------------------
 4071|      0|            loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
 4072|      0|                       "loader_parse_icd_manifest: Driver library architecture doesn't match the current running "
 4073|      0|                       "architecture, skipping this driver");
 4074|      0|            res = VK_ERROR_INCOMPATIBLE_DRIVER;
 4075|      0|            goto out;
 4076|      0|        }
 4077|      0|    }
 4078|      1|out:
 4079|      1|    loader_cJSON_Delete(icd_manifest_json);
 4080|      1|    return res;
 4081|      0|}
loader_icd_scan:
 4098|      5|                         const VkInstanceCreateInfo *pCreateInfo, bool *skipped_portability_drivers) {
 4099|      5|    VkResult res = VK_SUCCESS;
 4100|      5|    struct loader_string_list manifest_files = {0};
 4101|      5|    struct loader_envvar_filter select_filter = {0};
 4102|      5|    struct loader_envvar_filter disable_filter = {0};
 4103|      5|    struct ICDManifestInfo *icd_details = NULL;
 4104|       |
 4105|       |    // Set up the ICD Trampoline list so elements can be written into it.
 4106|      5|    res = loader_init_scanned_icd_list(inst, icd_tramp_list);
 4107|      5|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (4107:9): [True: 0, False: 5]
  ------------------
 4108|      0|        return res;
 4109|      0|    }
 4110|       |
 4111|      5|    bool direct_driver_loading_exclusive_mode = false;
 4112|      5|    res = loader_scan_for_direct_drivers(inst, pCreateInfo, icd_tramp_list, &direct_driver_loading_exclusive_mode);
 4113|      5|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (4113:9): [True: 0, False: 5]
  ------------------
 4114|      0|        goto out;
 4115|      0|    }
 4116|      5|    if (direct_driver_loading_exclusive_mode) {
  ------------------
  |  Branch (4116:9): [True: 0, False: 5]
  ------------------
 4117|       |        // Make sure to jump over the system & env-var driver discovery mechanisms if exclusive mode is set, even if no drivers
 4118|       |        // were successfully found through the direct driver loading mechanism
 4119|      0|        goto out;
 4120|      0|    }
 4121|       |
 4122|      5|    if (loader_settings_should_use_driver_environment_variables(inst)) {
  ------------------
  |  Branch (4122:9): [True: 5, False: 0]
  ------------------
 4123|       |        // Parse the filter environment variables to determine if we have any special behavior
 4124|      5|        res = parse_generic_filter_environment_var(inst, VK_DRIVERS_SELECT_ENV_VAR, &select_filter);
  ------------------
  |  |  122|      5|#define VK_DRIVERS_SELECT_ENV_VAR "VK_LOADER_DRIVERS_SELECT"
  ------------------
 4125|      5|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4125:13): [True: 0, False: 5]
  ------------------
 4126|      0|            goto out;
 4127|      0|        }
 4128|      5|        res = parse_generic_filter_environment_var(inst, VK_DRIVERS_DISABLE_ENV_VAR, &disable_filter);
  ------------------
  |  |  123|      5|#define VK_DRIVERS_DISABLE_ENV_VAR "VK_LOADER_DRIVERS_DISABLE"
  ------------------
 4129|      5|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4129:13): [True: 0, False: 5]
  ------------------
 4130|      0|            goto out;
 4131|      0|        }
 4132|      5|    }
 4133|       |
 4134|       |    // Get a list of manifest files for ICDs
 4135|      5|    res = loader_get_data_files(inst, LOADER_DATA_FILE_MANIFEST_DRIVER, NULL, &manifest_files);
 4136|      5|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4136:9): [True: 0, False: 5]
  ------------------
 4137|      0|        goto out;
 4138|      0|    }
 4139|       |
 4140|       |    // Add any drivers provided by the loader settings file
 4141|      5|    res = loader_settings_get_additional_driver_files(inst, &manifest_files);
 4142|      5|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4142:9): [True: 0, False: 5]
  ------------------
 4143|      0|        goto out;
 4144|      0|    }
 4145|       |
 4146|      5|    icd_details = loader_stack_alloc(sizeof(struct ICDManifestInfo) * manifest_files.count);
  ------------------
  |  |   42|      5|#define loader_stack_alloc(size) alloca(size)
  ------------------
 4147|      5|    if (NULL == icd_details) {
  ------------------
  |  Branch (4147:9): [True: 0, False: 5]
  ------------------
 4148|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4149|      0|        goto out;
 4150|      0|    }
 4151|      5|    memset(icd_details, 0, sizeof(struct ICDManifestInfo) * manifest_files.count);
 4152|       |
 4153|      6|    for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4153:26): [True: 1, False: 5]
  ------------------
 4154|      1|        VkResult icd_res = VK_SUCCESS;
 4155|       |
 4156|      1|        icd_res = loader_parse_icd_manifest(inst, manifest_files.list[i], &icd_details[i], skipped_portability_drivers);
 4157|      1|        if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_res) {
  ------------------
  |  Branch (4157:13): [True: 0, False: 1]
  ------------------
 4158|      0|            res = icd_res;
 4159|      0|            goto out;
 4160|      1|        } else if (VK_ERROR_INCOMPATIBLE_DRIVER == icd_res) {
  ------------------
  |  Branch (4160:20): [True: 1, False: 0]
  ------------------
 4161|      1|            continue;
 4162|      1|        }
 4163|       |
 4164|      0|        if (select_filter.count > 0 || disable_filter.count > 0) {
  ------------------
  |  Branch (4164:13): [True: 0, False: 0]
  |  Branch (4164:40): [True: 0, False: 0]
  ------------------
 4165|       |            // Get only the filename for comparing to the filters
 4166|      0|            char *just_filename_str = strrchr(manifest_files.list[i], DIRECTORY_SYMBOL);
  ------------------
  |  |  155|      0|#define DIRECTORY_SYMBOL '/'
  ------------------
 4167|       |
 4168|       |            // No directory symbol, just the filename
 4169|      0|            if (NULL == just_filename_str) {
  ------------------
  |  Branch (4169:17): [True: 0, False: 0]
  ------------------
 4170|      0|                just_filename_str = manifest_files.list[i];
 4171|      0|            } else {
 4172|      0|                just_filename_str++;
 4173|      0|            }
 4174|       |
 4175|      0|            bool name_matches_select =
 4176|      0|                (select_filter.count > 0 && check_name_matches_filter_environment_var(just_filename_str, &select_filter));
  ------------------
  |  Branch (4176:18): [True: 0, False: 0]
  |  Branch (4176:45): [True: 0, False: 0]
  ------------------
 4177|      0|            bool name_matches_disable =
 4178|      0|                (disable_filter.count > 0 && check_name_matches_filter_environment_var(just_filename_str, &disable_filter));
  ------------------
  |  Branch (4178:18): [True: 0, False: 0]
  |  Branch (4178:46): [True: 0, False: 0]
  ------------------
 4179|       |
 4180|      0|            if (name_matches_disable && !name_matches_select) {
  ------------------
  |  Branch (4180:17): [True: 0, False: 0]
  |  Branch (4180:41): [True: 0, False: 0]
  ------------------
 4181|      0|                loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4182|      0|                           "Driver \"%s\" ignored because it was disabled by env var \'%s\'", just_filename_str,
 4183|      0|                           VK_DRIVERS_DISABLE_ENV_VAR);
  ------------------
  |  |  123|      0|#define VK_DRIVERS_DISABLE_ENV_VAR "VK_LOADER_DRIVERS_DISABLE"
  ------------------
 4184|      0|                continue;
 4185|      0|            }
 4186|      0|            if (select_filter.count != 0 && !name_matches_select) {
  ------------------
  |  Branch (4186:17): [True: 0, False: 0]
  |  Branch (4186:45): [True: 0, False: 0]
  ------------------
 4187|      0|                loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4188|      0|                           "Driver \"%s\" ignored because not selected by env var \'%s\'", just_filename_str,
 4189|      0|                           VK_DRIVERS_SELECT_ENV_VAR);
  ------------------
  |  |  122|      0|#define VK_DRIVERS_SELECT_ENV_VAR "VK_LOADER_DRIVERS_SELECT"
  ------------------
 4190|      0|                continue;
 4191|      0|            }
 4192|      0|        }
 4193|       |
 4194|      0|        enum loader_layer_library_status lib_status;
 4195|      0|        icd_res =
 4196|      0|            loader_scanned_icd_add(inst, icd_tramp_list, icd_details[i].full_library_path, icd_details[i].version, &lib_status);
 4197|      0|        if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_res) {
  ------------------
  |  Branch (4197:13): [True: 0, False: 0]
  ------------------
 4198|      0|            res = icd_res;
 4199|      0|            goto out;
 4200|      0|        } else if (VK_ERROR_INCOMPATIBLE_DRIVER == icd_res) {
  ------------------
  |  Branch (4200:20): [True: 0, False: 0]
  ------------------
 4201|      0|            switch (lib_status) {
  ------------------
  |  Branch (4201:21): [True: 0, False: 0]
  ------------------
 4202|      0|                case LOADER_LAYER_LIB_NOT_LOADED:
  ------------------
  |  Branch (4202:17): [True: 0, False: 0]
  ------------------
 4203|      0|                case LOADER_LAYER_LIB_ERROR_FAILED_TO_LOAD:
  ------------------
  |  Branch (4203:17): [True: 0, False: 0]
  ------------------
 4204|      0|                    loader_log(inst, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4205|      0|                               "loader_icd_scan: Failed loading library associated with ICD JSON %s. Ignoring this JSON",
 4206|      0|                               icd_details[i].full_library_path);
 4207|      0|                    break;
 4208|      0|                case LOADER_LAYER_LIB_ERROR_WRONG_BIT_TYPE: {
  ------------------
  |  Branch (4208:17): [True: 0, False: 0]
  ------------------
 4209|      0|                    loader_log(inst, VULKAN_LOADER_DRIVER_BIT, 0, "Requested ICD %s was wrong bit-type. Ignoring this JSON",
 4210|      0|                               icd_details[i].full_library_path);
 4211|      0|                    break;
 4212|      0|                }
 4213|      0|                case LOADER_LAYER_LIB_SUCCESS_LOADED:
  ------------------
  |  Branch (4213:17): [True: 0, False: 0]
  ------------------
 4214|      0|                case LOADER_LAYER_LIB_ERROR_OUT_OF_MEMORY:
  ------------------
  |  Branch (4214:17): [True: 0, False: 0]
  ------------------
 4215|       |                    // Shouldn't be able to reach this but if it is, best to report a debug
 4216|      0|                    loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
 4217|      0|                               "Shouldn't reach this. A valid version of requested ICD %s was loaded but something bad "
 4218|      0|                               "happened afterwards.",
 4219|      0|                               icd_details[i].full_library_path);
 4220|      0|                    break;
 4221|      0|            }
 4222|      0|        }
 4223|      0|    }
 4224|       |
 4225|      5|out:
 4226|      5|    if (NULL != icd_details) {
  ------------------
  |  Branch (4226:9): [True: 5, False: 0]
  ------------------
 4227|       |        // Successfully got the icd_details structure, which means we need to free the paths contained within
 4228|      6|        for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4228:30): [True: 1, False: 5]
  ------------------
 4229|      1|            loader_instance_heap_free(inst, icd_details[i].full_library_path);
 4230|      1|        }
 4231|      5|    }
 4232|      5|    free_string_list(inst, &manifest_files);
 4233|      5|    return res;
 4234|      5|}
loader_parse_instance_layers:
 4240|  10.2k|                                      const struct loader_string_list *path_overrides, struct loader_layer_list *instance_layers) {
 4241|  10.2k|    assert(manifest_type == LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER || manifest_type == LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER);
 4242|  10.2k|    VkResult res = VK_SUCCESS;
 4243|  10.2k|    struct loader_string_list manifest_files = {0};
 4244|       |
 4245|  10.2k|    res = loader_get_data_files(inst, manifest_type, path_overrides, &manifest_files);
 4246|  10.2k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4246:9): [True: 0, False: 10.2k]
  ------------------
 4247|      0|        goto out;
 4248|      0|    }
 4249|       |
 4250|  17.9k|    for (uint32_t i = 0; i < manifest_files.count; i++) {
  ------------------
  |  Branch (4250:26): [True: 7.78k, False: 10.2k]
  ------------------
 4251|  7.78k|        char *file_str = manifest_files.list[i];
 4252|  7.78k|        if (file_str == NULL) {
  ------------------
  |  Branch (4252:13): [True: 0, False: 7.78k]
  ------------------
 4253|      0|            continue;
 4254|      0|        }
 4255|       |
 4256|       |        // Parse file into JSON struct
 4257|  7.78k|        cJSON *json = NULL;
 4258|  7.78k|        VkResult local_res = loader_get_json(inst, file_str, &json);
 4259|  7.78k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (4259:13): [True: 0, False: 7.78k]
  ------------------
 4260|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4261|      0|            goto out;
 4262|  7.78k|        } else if (VK_SUCCESS != local_res || NULL == json) {
  ------------------
  |  Branch (4262:20): [True: 122, False: 7.66k]
  |  Branch (4262:47): [True: 2.78k, False: 4.88k]
  ------------------
 4263|  2.90k|            continue;
 4264|  2.90k|        }
 4265|       |
 4266|  4.88k|        local_res = loader_add_layer_properties(inst, instance_layers, json,
 4267|  4.88k|                                                manifest_type == LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, file_str);
 4268|  4.88k|        loader_cJSON_Delete(json);
 4269|       |
 4270|       |        // If the error is anything other than out of memory we still want to try to load the other layers
 4271|  4.88k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (4271:13): [True: 0, False: 4.88k]
  ------------------
 4272|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 4273|      0|            goto out;
 4274|      0|        }
 4275|  4.88k|    }
 4276|  10.2k|out:
 4277|  10.2k|    free_string_list(inst, &manifest_files);
 4278|       |
 4279|  10.2k|    return res;
 4280|  10.2k|}
get_override_layer_override_paths:
 4285|    212|                                           struct loader_string_list *override_paths) {
 4286|    212|    if (prop->override_paths.count > 0) {
  ------------------
  |  Branch (4286:9): [True: 212, False: 0]
  ------------------
 4287|  12.1k|        for (uint32_t j = 0; j < prop->override_paths.count; j++) {
  ------------------
  |  Branch (4287:30): [True: 11.9k, False: 212]
  ------------------
 4288|  11.9k|            VkResult result = copy_data_file_info(inst, prop->override_paths.list[j], NULL, 0, override_paths);
 4289|  11.9k|            if (VK_SUCCESS != result) {
  ------------------
  |  Branch (4289:17): [True: 0, False: 11.9k]
  ------------------
 4290|      0|                return result;
 4291|      0|            }
 4292|  11.9k|            loader_log(inst, VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_LAYER_BIT, 0, "Override layer has override path %s",
 4293|  11.9k|                       prop->override_paths.list[j]);
 4294|  11.9k|        }
 4295|    212|    }
 4296|    212|    return VK_SUCCESS;
 4297|    212|}
loader_remove_duplicate_layers:
 4299|  5.10k|void loader_remove_duplicate_layers(struct loader_instance *inst, struct loader_layer_list *layers) {
 4300|       |    // Remove duplicate layers (that share the same layerName)
 4301|  15.0k|    for (uint32_t i = 0; i < layers->count; ++i) {
  ------------------
  |  Branch (4301:26): [True: 9.93k, False: 5.10k]
  ------------------
 4302|  9.93k|        bool has_duplicate = false;
 4303|  9.93k|        uint32_t duplicate_index = 0;
 4304|  42.7k|        for (uint32_t j = i + 1; j < layers->count; ++j) {
  ------------------
  |  Branch (4304:34): [True: 40.2k, False: 2.52k]
  ------------------
 4305|  40.2k|            if (strcmp(layers->list[i].info.layerName, layers->list[j].info.layerName) == 0) {
  ------------------
  |  Branch (4305:17): [True: 7.40k, False: 32.8k]
  ------------------
 4306|  7.40k|                has_duplicate = true;
 4307|  7.40k|                duplicate_index = j;
 4308|  7.40k|                break;
 4309|  7.40k|            }
 4310|  40.2k|        }
 4311|  9.93k|        if (has_duplicate) {
  ------------------
  |  Branch (4311:13): [True: 7.40k, False: 2.52k]
  ------------------
 4312|  7.40k|            loader_log(inst, VULKAN_LOADER_WARN_BIT, 0, "Removing layer %s (%s) because it is a duplicate of %s (%s)",
 4313|  7.40k|                       layers->list[duplicate_index].info.layerName, layers->list[duplicate_index].manifest_file_name,
 4314|  7.40k|                       layers->list[i].info.layerName, layers->list[i].manifest_file_name);
 4315|  7.40k|            loader_remove_layer_in_list(inst, layers, duplicate_index);
 4316|  7.40k|        }
 4317|  9.93k|    }
 4318|  5.10k|}
loader_scan_for_layers:
 4321|  6.85k|                                const struct loader_envvar_all_filters *filters) {
 4322|  6.85k|    VkResult res = VK_SUCCESS;
 4323|  6.85k|    struct loader_layer_list settings_layers = {0};
 4324|  6.85k|    struct loader_layer_list regular_instance_layers = {0};
 4325|  6.85k|    bool override_layer_valid = false;
 4326|  6.85k|    struct loader_string_list override_paths = {0};
 4327|       |
 4328|  6.85k|    bool should_search_for_other_layers = true;
 4329|  6.85k|    res = get_settings_layers(inst, &settings_layers, &should_search_for_other_layers);
 4330|  6.85k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4330:9): [True: 0, False: 6.85k]
  ------------------
 4331|      0|        goto out;
 4332|      0|    }
 4333|       |
 4334|       |    // If we should not look for layers using other mechanisms, assign settings_layers to instance_layers and jump to the
 4335|       |    // output
 4336|  6.85k|    if (!should_search_for_other_layers) {
  ------------------
  |  Branch (4336:9): [True: 1.75k, False: 5.10k]
  ------------------
 4337|  1.75k|        *instance_layers = settings_layers;
 4338|  1.75k|        memset(&settings_layers, 0, sizeof(struct loader_layer_list));
 4339|  1.75k|        goto out;
 4340|  1.75k|    }
 4341|       |
 4342|  5.10k|    res = loader_parse_instance_layers(inst, LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, NULL, &regular_instance_layers);
 4343|  5.10k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4343:9): [True: 0, False: 5.10k]
  ------------------
 4344|      0|        goto out;
 4345|      0|    }
 4346|       |
 4347|       |    // Remove any extraneous override layers.
 4348|  5.10k|    remove_all_non_valid_override_layers(inst, &regular_instance_layers);
 4349|       |
 4350|       |    // Check to see if the override layer is present, and use it's override paths.
 4351|  11.1k|    for (uint32_t i = 0; i < regular_instance_layers.count; i++) {
  ------------------
  |  Branch (4351:26): [True: 6.25k, False: 4.89k]
  ------------------
 4352|  6.25k|        struct loader_layer_properties *prop = &regular_instance_layers.list[i];
 4353|  6.25k|        if (prop->is_override && loader_implicit_layer_is_enabled(inst, filters, prop) && prop->override_paths.count > 0) {
  ------------------
  |  Branch (4353:13): [True: 487, False: 5.76k]
  |  Branch (4353:34): [True: 379, False: 108]
  |  Branch (4353:91): [True: 212, False: 167]
  ------------------
 4354|    212|            res = get_override_layer_override_paths(inst, prop, &override_paths);
 4355|    212|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4355:17): [True: 0, False: 212]
  ------------------
 4356|      0|                goto out;
 4357|      0|            }
 4358|    212|            break;
 4359|    212|        }
 4360|  6.25k|    }
 4361|       |
 4362|       |    // Get a list of manifest files for explicit layers
 4363|  5.10k|    res = loader_parse_instance_layers(inst, LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER, &override_paths, &regular_instance_layers);
 4364|  5.10k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (4364:9): [True: 0, False: 5.10k]
  ------------------
 4365|      0|        goto out;
 4366|      0|    }
 4367|       |
 4368|       |    // Verify any meta-layers in the list are valid and all the component layers are
 4369|       |    // actually present in the available layer list
 4370|  5.10k|    res = verify_all_meta_layers(inst, filters, &regular_instance_layers, &override_layer_valid);
 4371|  5.10k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (4371:9): [True: 0, False: 5.10k]
  ------------------
 4372|      0|        return res;
 4373|      0|    }
 4374|       |
 4375|  5.10k|    if (override_layer_valid) {
  ------------------
  |  Branch (4375:9): [True: 365, False: 4.73k]
  ------------------
 4376|    365|        loader_remove_layers_in_blacklist(inst, &regular_instance_layers);
 4377|    365|        if (NULL != inst) {
  ------------------
  |  Branch (4377:13): [True: 365, False: 0]
  ------------------
 4378|    365|            inst->override_layer_present = true;
 4379|    365|        }
 4380|    365|    }
 4381|       |
 4382|       |    // Remove disabled layers
 4383|  22.4k|    for (uint32_t i = 0; i < regular_instance_layers.count; ++i) {
  ------------------
  |  Branch (4383:26): [True: 17.3k, False: 5.10k]
  ------------------
 4384|  17.3k|        if (!loader_layer_is_available(inst, filters, &regular_instance_layers.list[i])) {
  ------------------
  |  Branch (4384:13): [True: 0, False: 17.3k]
  ------------------
 4385|      0|            loader_remove_layer_in_list(inst, &regular_instance_layers, i);
 4386|      0|            i--;
 4387|      0|        }
 4388|  17.3k|    }
 4389|       |
 4390|       |    // Make sure no layers have the same layerName
 4391|  5.10k|    loader_remove_duplicate_layers(inst, &regular_instance_layers);
 4392|       |
 4393|  5.10k|    res = combine_settings_layers_with_regular_layers(inst, &settings_layers, &regular_instance_layers, instance_layers);
 4394|       |
 4395|  6.85k|out:
 4396|  6.85k|    loader_delete_layer_list_and_properties(inst, &settings_layers);
 4397|  6.85k|    loader_delete_layer_list_and_properties(inst, &regular_instance_layers);
 4398|       |
 4399|  6.85k|    free_string_list(inst, &override_paths);
 4400|  6.85k|    return res;
 4401|  5.10k|}
loader_validate_layers:
 5607|  6.85k|                                const char *const *ppEnabledLayerNames, const struct loader_layer_list *list) {
 5608|  6.85k|    struct loader_layer_properties *prop;
 5609|       |
 5610|  6.85k|    if (layer_count > 0 && ppEnabledLayerNames == NULL) {
  ------------------
  |  Branch (5610:9): [True: 6.85k, False: 0]
  |  Branch (5610:28): [True: 0, False: 6.85k]
  ------------------
 5611|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5612|      0|                   "loader_validate_layers: ppEnabledLayerNames is NULL but enabledLayerCount is greater than zero");
 5613|      0|        return VK_ERROR_LAYER_NOT_PRESENT;
 5614|      0|    }
 5615|       |
 5616|  6.86k|    for (uint32_t i = 0; i < layer_count; i++) {
  ------------------
  |  Branch (5616:26): [True: 6.85k, False: 5]
  ------------------
 5617|  6.85k|        VkStringErrorFlags result = vk_string_validate(MaxLoaderStringLength, ppEnabledLayerNames[i]);
 5618|  6.85k|        if (result != VK_STRING_ERROR_NONE) {
  ------------------
  |  Branch (5618:13): [True: 0, False: 6.85k]
  ------------------
 5619|      0|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5620|      0|                       "loader_validate_layers: ppEnabledLayerNames contains string that is too long or is badly formed");
 5621|      0|            return VK_ERROR_LAYER_NOT_PRESENT;
 5622|      0|        }
 5623|       |
 5624|  6.85k|        prop = loader_find_layer_property(ppEnabledLayerNames[i], list);
 5625|  6.85k|        if (NULL == prop) {
  ------------------
  |  Branch (5625:13): [True: 6.84k, False: 6]
  ------------------
 5626|  6.84k|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5627|  6.84k|                       "loader_validate_layers: Layer %d does not exist in the list of available layers", i);
 5628|  6.84k|            return VK_ERROR_LAYER_NOT_PRESENT;
 5629|  6.84k|        }
 5630|      6|        if (inst->settings.settings_active && inst->settings.layer_configurations_active &&
  ------------------
  |  Branch (5630:13): [True: 5, False: 1]
  |  Branch (5630:47): [True: 5, False: 0]
  ------------------
 5631|      5|            prop->settings_control_value != LOADER_SETTINGS_LAYER_CONTROL_ON &&
  ------------------
  |  Branch (5631:13): [True: 5, False: 0]
  ------------------
 5632|      5|            prop->settings_control_value != LOADER_SETTINGS_LAYER_CONTROL_DEFAULT) {
  ------------------
  |  Branch (5632:13): [True: 1, False: 4]
  ------------------
 5633|      1|            loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
 5634|      1|                       "loader_validate_layers: Layer %d was explicitly prevented from being enabled by the loader settings file",
 5635|      1|                       i);
 5636|      1|            return VK_ERROR_LAYER_NOT_PRESENT;
 5637|      1|        }
 5638|      6|    }
 5639|      5|    return VK_SUCCESS;
 5640|  6.85k|}
vk_string_validate:
 7542|  6.85k|TEST_FUNCTION_EXPORT VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) {
 7543|  6.85k|    VkStringErrorFlags result = VK_STRING_ERROR_NONE;
 7544|  6.85k|    int num_char_bytes = 0;
 7545|  6.85k|    int i;
 7546|  6.85k|    int j;
 7547|       |
 7548|  6.85k|    if (utf8 == NULL) {
  ------------------
  |  Branch (7548:9): [True: 0, False: 6.85k]
  ------------------
 7549|      0|        return VK_STRING_ERROR_NULL_PTR;
 7550|      0|    }
 7551|       |
 7552|   191k|    for (i = 0; i <= max_length; i++) {
  ------------------
  |  Branch (7552:17): [True: 191k, False: 0]
  ------------------
 7553|   191k|        if (utf8[i] == 0) {
  ------------------
  |  Branch (7553:13): [True: 6.85k, False: 185k]
  ------------------
 7554|  6.85k|            break;
 7555|  6.85k|        }
 7556|   185k|        if (i == max_length) {
  ------------------
  |  Branch (7556:13): [True: 0, False: 185k]
  ------------------
 7557|      0|            result |= VK_STRING_ERROR_LENGTH;
 7558|      0|            break;
 7559|      0|        }
 7560|   185k|        if ((utf8[i] >= 0x20) && (utf8[i] < 0x7f)) {
  ------------------
  |  Branch (7560:13): [True: 185k, False: 0]
  |  Branch (7560:34): [True: 185k, False: 0]
  ------------------
 7561|   185k|            num_char_bytes = 0;
 7562|   185k|        } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) {
  ------------------
  |  Branch (7562:20): [True: 0, False: 0]
  ------------------
 7563|      0|            num_char_bytes = 1;
 7564|      0|        } else if ((utf8[i] & UTF8_TWO_BYTE_MASK) == UTF8_TWO_BYTE_CODE) {
  ------------------
  |  Branch (7564:20): [True: 0, False: 0]
  ------------------
 7565|      0|            num_char_bytes = 2;
 7566|      0|        } else if ((utf8[i] & UTF8_THREE_BYTE_MASK) == UTF8_THREE_BYTE_CODE) {
  ------------------
  |  Branch (7566:20): [True: 0, False: 0]
  ------------------
 7567|      0|            num_char_bytes = 3;
 7568|      0|        } else {
 7569|      0|            result = VK_STRING_ERROR_BAD_DATA;
 7570|      0|        }
 7571|       |
 7572|       |        // Validate the following num_char_bytes of data
 7573|   185k|        for (j = 0; (j < num_char_bytes) && (i < max_length); j++) {
  ------------------
  |  Branch (7573:21): [True: 0, False: 185k]
  |  Branch (7573:45): [True: 0, False: 0]
  ------------------
 7574|      0|            if (++i == max_length) {
  ------------------
  |  Branch (7574:17): [True: 0, False: 0]
  ------------------
 7575|      0|                result |= VK_STRING_ERROR_LENGTH;
 7576|      0|                break;
 7577|      0|            }
 7578|      0|            if (utf8[i] == 0) {
  ------------------
  |  Branch (7578:17): [True: 0, False: 0]
  ------------------
 7579|       |                // The string terminated in the middle of a multi-byte character. Stop here so the
 7580|       |                // continuation-byte scan doesn't read past the terminator.
 7581|      0|                result |= VK_STRING_ERROR_BAD_DATA;
 7582|      0|                return result;
 7583|      0|            }
 7584|      0|            if ((utf8[i] & UTF8_DATA_BYTE_MASK) != UTF8_DATA_BYTE_CODE) {
  ------------------
  |  Branch (7584:17): [True: 0, False: 0]
  ------------------
 7585|      0|                result |= VK_STRING_ERROR_BAD_DATA;
 7586|      0|            }
 7587|      0|        }
 7588|   185k|    }
 7589|  6.85k|    return result;
 7590|  6.85k|}

loader_getenv:
   43|    991|char *loader_getenv(const char *name, const struct loader_instance *inst) {
   44|    991|    if (NULL == name) return NULL;
  ------------------
  |  Branch (44:9): [True: 0, False: 991]
  ------------------
   45|       |    // No allocation of memory necessary for Linux, but we should at least touch
   46|       |    // the inst pointer to get rid of compiler warnings.
   47|    991|    (void)inst;
   48|       |    // NOLINTNEXTLINE(concurrency-mt-unsafe) - there is no portable reentrant getenv; the loader never calls setenv concurrently
   49|    991|    return getenv(name);
   50|    991|}
loader_secure_getenv:
   52|   126k|char *loader_secure_getenv(const char *name, const struct loader_instance *inst) {
   53|       |#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
   54|       |    // Apple does not appear to have a secure getenv implementation.
   55|       |    // The main difference between secure getenv and getenv is that secure getenv
   56|       |    // returns NULL if the process is being run with elevated privileges by a normal user.
   57|       |    // The idea is to prevent the reading of malicious environment variables by a process
   58|       |    // that can do damage.
   59|       |    // This algorithm is derived from glibc code that sets an internal
   60|       |    // variable (__libc_enable_secure) if the process is running under setuid or setgid.
   61|       |    return is_high_integrity() ? NULL : loader_getenv(name, inst);
   62|       |#elif defined(__Fuchsia__)
   63|       |    return loader_getenv(name, inst);
   64|       |#else
   65|       |    // Linux
   66|   126k|    char *out;
   67|   126k|#if defined(HAVE_SECURE_GETENV) && !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   68|   126k|    (void)inst;
   69|   126k|    out = secure_getenv(name);
   70|       |#elif defined(HAVE___SECURE_GETENV) && !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   71|       |    (void)inst;
   72|       |    out = __secure_getenv(name);
   73|       |#else
   74|       |    out = loader_getenv(name, inst);
   75|       |#if !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
   76|       |    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Loader is using non-secure environment variable lookup for %s", name);
   77|       |#endif
   78|       |#endif
   79|   126k|    return out;
   80|   126k|#endif
   81|   126k|}
loader_free_getenv:
   83|  96.4k|void loader_free_getenv(const char *val, const struct loader_instance *inst) {
   84|       |    // No freeing of memory necessary for Linux, but we should at least touch
   85|       |    // the val and inst pointers to get rid of compiler warnings.
   86|  96.4k|    (void)val;
   87|  96.4k|    (void)inst;
   88|  96.4k|}
determine_filter_type:
  193|  6.85k|                           size_t *new_length) {
  194|  6.85k|    size_t filter_length = strlen(filter_string);
  195|  6.85k|    bool star_begin = false;
  196|  6.85k|    bool star_end = false;
  197|  6.85k|    if ('~' == filter_string[0]) {
  ------------------
  |  Branch (197:9): [True: 0, False: 6.85k]
  ------------------
  198|       |        // One of the special identifiers like: ~all~, ~implicit~, or ~explicit~
  199|      0|        *filter_type = FILTER_STRING_SPECIAL;
  200|      0|        *new_start = filter_string;
  201|      0|        *new_length = filter_length;
  202|  6.85k|    } else {
  203|  6.85k|        if ('*' == filter_string[0]) {
  ------------------
  |  Branch (203:13): [True: 0, False: 6.85k]
  ------------------
  204|       |            // Only the * means everything
  205|      0|            if (filter_length == 1) {
  ------------------
  |  Branch (205:17): [True: 0, False: 0]
  ------------------
  206|      0|                *filter_type = FILTER_STRING_SPECIAL;
  207|      0|                *new_start = filter_string;
  208|      0|                *new_length = filter_length;
  209|      0|                return;
  210|      0|            }
  211|      0|            star_begin = true;
  212|      0|        }
  213|  6.85k|        if ('*' == filter_string[filter_length - 1]) {
  ------------------
  |  Branch (213:13): [True: 0, False: 6.85k]
  ------------------
  214|       |            // Not really valid, but just catch this case so if someone accidentally types "**" it will also mean everything
  215|      0|            if (star_begin && filter_length == 2) {
  ------------------
  |  Branch (215:17): [True: 0, False: 0]
  |  Branch (215:31): [True: 0, False: 0]
  ------------------
  216|      0|                *filter_type = FILTER_STRING_SPECIAL;
  217|      0|                *new_start = filter_string;
  218|      0|                *new_length = filter_length;
  219|      0|                return;
  220|      0|            }
  221|      0|            star_end = true;
  222|      0|        }
  223|  6.85k|        if (star_begin && star_end) {
  ------------------
  |  Branch (223:13): [True: 0, False: 6.85k]
  |  Branch (223:27): [True: 0, False: 0]
  ------------------
  224|      0|            *filter_type = FILTER_STRING_SUBSTRING;
  225|      0|            *new_start = &filter_string[1];
  226|      0|            *new_length = filter_length - 2;
  227|  6.85k|        } else if (star_begin) {
  ------------------
  |  Branch (227:20): [True: 0, False: 6.85k]
  ------------------
  228|      0|            *new_start = &filter_string[1];
  229|      0|            *new_length = filter_length - 1;
  230|      0|            *filter_type = FILTER_STRING_SUFFIX;
  231|  6.85k|        } else if (star_end) {
  ------------------
  |  Branch (231:20): [True: 0, False: 6.85k]
  ------------------
  232|      0|            *filter_type = FILTER_STRING_PREFIX;
  233|      0|            *new_start = filter_string;
  234|      0|            *new_length = filter_length - 1;
  235|  6.85k|        } else {
  236|  6.85k|            *filter_type = FILTER_STRING_FULLNAME;
  237|  6.85k|            *new_start = filter_string;
  238|  6.85k|            *new_length = filter_length;
  239|  6.85k|        }
  240|  6.85k|    }
  241|  6.85k|}
parse_generic_filter_environment_var:
  246|  13.7k|                                              struct loader_envvar_filter *filter_struct) {
  247|  13.7k|    VkResult result = VK_SUCCESS;
  248|  13.7k|    memset(filter_struct, 0, sizeof(struct loader_envvar_filter));
  249|  13.7k|    char *parsing_string = NULL;
  250|  13.7k|    char *env_var_value = loader_secure_getenv(env_var_name, inst);
  251|  13.7k|    if (NULL == env_var_value) {
  ------------------
  |  Branch (251:9): [True: 6.86k, False: 6.85k]
  ------------------
  252|  6.86k|        return result;
  253|  6.86k|    }
  254|  6.85k|    const size_t env_var_len = strlen(env_var_value);
  255|  6.85k|    if (env_var_len == 0) {
  ------------------
  |  Branch (255:9): [True: 0, False: 6.85k]
  ------------------
  256|      0|        goto out;
  257|      0|    }
  258|       |    // Allocate a separate string since scan_for_next_comma modifies the original string
  259|  6.85k|    parsing_string = loader_instance_heap_calloc(inst, env_var_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  260|  6.85k|    if (NULL == parsing_string) {
  ------------------
  |  Branch (260:9): [True: 0, False: 6.85k]
  ------------------
  261|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
  262|      0|                   "parse_generic_filter_environment_var: Failed to allocate space for parsing env var \'%s\'", env_var_name);
  263|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
  264|      0|        goto out;
  265|      0|    }
  266|       |
  267|  27.4k|    for (uint32_t iii = 0; iii < env_var_len; ++iii) {
  ------------------
  |  Branch (267:28): [True: 20.5k, False: 6.85k]
  ------------------
  268|  20.5k|        parsing_string[iii] = (char)tolower((unsigned char)env_var_value[iii]);
  ------------------
  |  Branch (268:37): [True: 0, False: 0]
  |  Branch (268:37): [True: 0, False: 0]
  |  Branch (268:37): [Folded, False: 20.5k]
  ------------------
  269|  20.5k|    }
  270|  6.85k|    parsing_string[env_var_len] = '\0';
  271|       |
  272|  6.85k|    char *context = NULL;
  273|  6.85k|    char *token = thread_safe_strtok(parsing_string, ",", &context);
  274|  13.7k|    while (NULL != token) {
  ------------------
  |  Branch (274:12): [True: 6.85k, False: 6.85k]
  ------------------
  275|  6.85k|        enum loader_filter_string_type cur_filter_type;
  276|  6.85k|        const char *actual_start;
  277|  6.85k|        size_t actual_len;
  278|  6.85k|        determine_filter_type(token, &cur_filter_type, &actual_start, &actual_len);
  279|       |        // value holds at most VK_MAX_EXTENSION_NAME_SIZE - 1 chars plus the null terminator. Keep the stored length in sync
  280|       |        // with what actually fits so the matcher never walks past the buffer, and make sure it stays null terminated.
  281|  6.85k|        size_t stored_len = actual_len < VK_MAX_EXTENSION_NAME_SIZE - 1 ? actual_len : VK_MAX_EXTENSION_NAME_SIZE - 1;
  ------------------
  |  Branch (281:29): [True: 6.85k, False: 0]
  ------------------
  282|  6.85k|        loader_strncpy(filter_struct->filters[filter_struct->count].value, VK_MAX_EXTENSION_NAME_SIZE, actual_start, stored_len);
  283|  6.85k|        filter_struct->filters[filter_struct->count].value[stored_len] = '\0';
  284|  6.85k|        filter_struct->filters[filter_struct->count].length = stored_len;
  285|  6.85k|        filter_struct->filters[filter_struct->count++].type = cur_filter_type;
  286|  6.85k|        if (filter_struct->count >= MAX_ADDITIONAL_FILTERS) {
  ------------------
  |  |  531|  6.85k|#define MAX_ADDITIONAL_FILTERS 16
  ------------------
  |  Branch (286:13): [True: 0, False: 6.85k]
  ------------------
  287|      0|            break;
  288|      0|        }
  289|  6.85k|        token = thread_safe_strtok(NULL, ",", &context);
  290|  6.85k|    }
  291|       |
  292|  6.85k|out:
  293|       |
  294|  6.85k|    loader_instance_heap_free(inst, parsing_string);
  295|  6.85k|    loader_free_getenv(env_var_value, inst);
  296|  6.85k|    return result;
  297|  6.85k|}
parse_layers_disable_filter_environment_var:
  303|  6.85k|                                                     struct loader_envvar_disable_layers_filter *disable_struct) {
  304|  6.85k|    VkResult result = VK_SUCCESS;
  305|  6.85k|    memset(disable_struct, 0, sizeof(struct loader_envvar_disable_layers_filter));
  306|  6.85k|    char *parsing_string = NULL;
  307|  6.85k|    char *env_var_value = loader_secure_getenv(VK_LAYERS_DISABLE_ENV_VAR, inst);
  ------------------
  |  |  120|  6.85k|#define VK_LAYERS_DISABLE_ENV_VAR "VK_LOADER_LAYERS_DISABLE"
  ------------------
  308|  6.85k|    if (NULL == env_var_value) {
  ------------------
  |  Branch (308:9): [True: 6.85k, False: 0]
  ------------------
  309|  6.85k|        goto out;
  310|  6.85k|    }
  311|      0|    const size_t env_var_len = strlen(env_var_value);
  312|      0|    if (env_var_len == 0) {
  ------------------
  |  Branch (312:9): [True: 0, False: 0]
  ------------------
  313|      0|        goto out;
  314|      0|    }
  315|       |    // Allocate a separate string since scan_for_next_comma modifies the original string
  316|      0|    parsing_string = loader_instance_heap_calloc(inst, env_var_len + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  317|      0|    if (NULL == parsing_string) {
  ------------------
  |  Branch (317:9): [True: 0, False: 0]
  ------------------
  318|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0,
  319|      0|                   "parse_layers_disable_filter_environment_var: Failed to allocate space for parsing env var "
  320|      0|                   "\'VK_LAYERS_DISABLE_ENV_VAR\'");
  321|      0|        result = VK_ERROR_OUT_OF_HOST_MEMORY;
  322|      0|        goto out;
  323|      0|    }
  324|       |
  325|      0|    for (uint32_t iii = 0; iii < env_var_len; ++iii) {
  ------------------
  |  Branch (325:28): [True: 0, False: 0]
  ------------------
  326|      0|        parsing_string[iii] = (char)tolower((unsigned char)env_var_value[iii]);
  ------------------
  |  Branch (326:37): [True: 0, False: 0]
  |  Branch (326:37): [True: 0, False: 0]
  |  Branch (326:37): [Folded, False: 0]
  ------------------
  327|      0|    }
  328|      0|    parsing_string[env_var_len] = '\0';
  329|       |
  330|      0|    char *context = NULL;
  331|      0|    char *token = thread_safe_strtok(parsing_string, ",", &context);
  332|      0|    while (NULL != token) {
  ------------------
  |  Branch (332:12): [True: 0, False: 0]
  ------------------
  333|      0|        uint32_t cur_count = disable_struct->additional_filters.count;
  334|      0|        enum loader_filter_string_type cur_filter_type;
  335|      0|        const char *actual_start;
  336|      0|        size_t actual_len;
  337|      0|        determine_filter_type(token, &cur_filter_type, &actual_start, &actual_len);
  338|      0|        if (cur_filter_type == FILTER_STRING_SPECIAL) {
  ------------------
  |  Branch (338:13): [True: 0, False: 0]
  ------------------
  339|      0|            if (!strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_1, token) || !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_2, token) ||
  ------------------
  |  |  124|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_1 "~all~"
  ------------------
                          if (!strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_1, token) || !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_2, token) ||
  ------------------
  |  |  125|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_2 "*"
  ------------------
  |  Branch (339:17): [True: 0, False: 0]
  |  Branch (339:71): [True: 0, False: 0]
  ------------------
  340|      0|                !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_3, token)) {
  ------------------
  |  |  126|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_3 "**"
  ------------------
  |  Branch (340:17): [True: 0, False: 0]
  ------------------
  341|      0|                disable_struct->disable_all = true;
  342|      0|            } else if (!strcmp(VK_LOADER_DISABLE_IMPLICIT_LAYERS_VAR, token)) {
  ------------------
  |  |  127|      0|#define VK_LOADER_DISABLE_IMPLICIT_LAYERS_VAR "~implicit~"
  ------------------
  |  Branch (342:24): [True: 0, False: 0]
  ------------------
  343|      0|                disable_struct->disable_all_implicit = true;
  344|      0|            } else if (!strcmp(VK_LOADER_DISABLE_EXPLICIT_LAYERS_VAR, token)) {
  ------------------
  |  |  128|      0|#define VK_LOADER_DISABLE_EXPLICIT_LAYERS_VAR "~explicit~"
  ------------------
  |  Branch (344:24): [True: 0, False: 0]
  ------------------
  345|      0|                disable_struct->disable_all_explicit = true;
  346|      0|            }
  347|      0|        } else {
  348|       |            // Keep the stored length in sync with what actually fits (value is VK_MAX_EXTENSION_NAME_SIZE bytes including
  349|       |            // the null terminator) so the matcher never reads past the buffer.
  350|      0|            size_t stored_len = actual_len < VK_MAX_EXTENSION_NAME_SIZE - 1 ? actual_len : VK_MAX_EXTENSION_NAME_SIZE - 1;
  ------------------
  |  Branch (350:33): [True: 0, False: 0]
  ------------------
  351|      0|            loader_strncpy(disable_struct->additional_filters.filters[cur_count].value, VK_MAX_EXTENSION_NAME_SIZE, actual_start,
  352|      0|                           stored_len);
  353|      0|            disable_struct->additional_filters.filters[cur_count].value[stored_len] = '\0';
  354|      0|            disable_struct->additional_filters.filters[cur_count].length = stored_len;
  355|      0|            disable_struct->additional_filters.filters[cur_count].type = cur_filter_type;
  356|      0|            disable_struct->additional_filters.count++;
  357|      0|            if (disable_struct->additional_filters.count >= MAX_ADDITIONAL_FILTERS) {
  ------------------
  |  |  531|      0|#define MAX_ADDITIONAL_FILTERS 16
  ------------------
  |  Branch (357:17): [True: 0, False: 0]
  ------------------
  358|      0|                break;
  359|      0|            }
  360|      0|        }
  361|      0|        token = thread_safe_strtok(NULL, ",", &context);
  362|      0|    }
  363|  6.85k|out:
  364|  6.85k|    loader_instance_heap_free(inst, parsing_string);
  365|  6.85k|    loader_free_getenv(env_var_value, inst);
  366|  6.85k|    return result;
  367|      0|}
parse_layer_environment_var_filters:
  370|  6.85k|VkResult parse_layer_environment_var_filters(const struct loader_instance *inst, struct loader_envvar_all_filters *layer_filters) {
  371|  6.85k|    VkResult res = parse_generic_filter_environment_var(inst, VK_LAYERS_ENABLE_ENV_VAR, &layer_filters->enable_filter);
  ------------------
  |  |  119|  6.85k|#define VK_LAYERS_ENABLE_ENV_VAR "VK_LOADER_LAYERS_ENABLE"
  ------------------
  372|  6.85k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (372:9): [True: 0, False: 6.85k]
  ------------------
  373|      0|        return res;
  374|      0|    }
  375|  6.85k|    res = parse_layers_disable_filter_environment_var(inst, &layer_filters->disable_filter);
  376|  6.85k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (376:9): [True: 0, False: 6.85k]
  ------------------
  377|      0|        return res;
  378|      0|    }
  379|  6.85k|    res = parse_generic_filter_environment_var(inst, VK_LAYERS_ALLOW_ENV_VAR, &layer_filters->allow_filter);
  ------------------
  |  |  121|  6.85k|#define VK_LAYERS_ALLOW_ENV_VAR "VK_LOADER_LAYERS_ALLOW"
  ------------------
  380|  6.85k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (380:9): [True: 0, False: 6.85k]
  ------------------
  381|      0|        return res;
  382|      0|    }
  383|  6.85k|    return res;
  384|  6.85k|}
check_name_matches_filter_environment_var:
  405|  38.0k|bool check_name_matches_filter_environment_var(const char *name, const struct loader_envvar_filter *filter_struct) {
  406|  38.0k|    bool ret_value = false;
  407|  38.0k|    size_t name_len = strlen(name);
  408|       |    // Compare each filter against `name` directly. name_segment_matches_filter_value does a case-insensitive compare
  409|       |    // (filter values are already lowercased at parse time), so there's no need to make a lowercased copy of name first
  410|       |    // and no limit on how long name can be.
  411|  56.9k|    for (uint32_t filt = 0; filt < filter_struct->count; ++filt) {
  ------------------
  |  Branch (411:29): [True: 19.0k, False: 37.9k]
  ------------------
  412|  19.0k|        const struct loader_envvar_filter_value *filter = &filter_struct->filters[filt];
  413|       |        // The filter (with its wildcards stripped) is longer than the name, so it can't possibly match.
  414|  19.0k|        if (filter->length > name_len) {
  ------------------
  |  Branch (414:13): [True: 6.51k, False: 12.5k]
  ------------------
  415|  6.51k|            continue;
  416|  6.51k|        }
  417|  12.5k|        switch (filter->type) {
  ------------------
  |  Branch (417:17): [True: 12.5k, False: 0]
  ------------------
  418|      0|            case FILTER_STRING_SPECIAL:
  ------------------
  |  Branch (418:13): [True: 0, False: 12.5k]
  ------------------
  419|      0|                if (!strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_1, filter->value) ||
  ------------------
  |  |  124|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_1 "~all~"
  ------------------
  |  Branch (419:21): [True: 0, False: 0]
  ------------------
  420|      0|                    !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_2, filter->value) ||
  ------------------
  |  |  125|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_2 "*"
  ------------------
  |  Branch (420:21): [True: 0, False: 0]
  ------------------
  421|      0|                    !strcmp(VK_LOADER_DISABLE_ALL_LAYERS_VAR_3, filter->value)) {
  ------------------
  |  |  126|      0|#define VK_LOADER_DISABLE_ALL_LAYERS_VAR_3 "**"
  ------------------
  |  Branch (421:21): [True: 0, False: 0]
  ------------------
  422|      0|                    ret_value = true;
  423|      0|                }
  424|      0|                break;
  425|       |
  426|      0|            case FILTER_STRING_SUBSTRING:
  ------------------
  |  Branch (426:13): [True: 0, False: 12.5k]
  ------------------
  427|       |                // Slide the filter along the name looking for a match, stopping as soon as one is found.
  428|      0|                for (size_t start = 0; start + filter->length <= name_len; ++start) {
  ------------------
  |  Branch (428:40): [True: 0, False: 0]
  ------------------
  429|      0|                    if (name_segment_matches_filter_value(name + start, filter->value, filter->length)) {
  ------------------
  |  Branch (429:25): [True: 0, False: 0]
  ------------------
  430|      0|                        ret_value = true;
  431|      0|                        break;
  432|      0|                    }
  433|      0|                }
  434|      0|                break;
  435|       |
  436|      0|            case FILTER_STRING_SUFFIX:
  ------------------
  |  Branch (436:13): [True: 0, False: 12.5k]
  ------------------
  437|      0|                ret_value = name_segment_matches_filter_value(name + name_len - filter->length, filter->value, filter->length);
  438|      0|                break;
  439|       |
  440|      0|            case FILTER_STRING_PREFIX:
  ------------------
  |  Branch (440:13): [True: 0, False: 12.5k]
  ------------------
  441|      0|                ret_value = name_segment_matches_filter_value(name, filter->value, filter->length);
  442|      0|                break;
  443|       |
  444|  12.5k|            case FILTER_STRING_FULLNAME:
  ------------------
  |  Branch (444:13): [True: 12.5k, False: 0]
  ------------------
  445|  12.5k|                ret_value = (name_len == filter->length) && name_segment_matches_filter_value(name, filter->value, filter->length);
  ------------------
  |  Branch (445:29): [True: 903, False: 11.6k]
  |  Branch (445:61): [True: 151, False: 752]
  ------------------
  446|  12.5k|                break;
  447|  12.5k|        }
  448|  12.5k|        if (ret_value) {
  ------------------
  |  Branch (448:13): [True: 151, False: 12.3k]
  ------------------
  449|    151|            break;
  450|    151|        }
  451|  12.5k|    }
  452|  38.0k|    return ret_value;
  453|  38.0k|}
loader_environment.c:name_segment_matches_filter_value:
  390|    903|static bool name_segment_matches_filter_value(const char *name_segment, const char *lowercase_filter_value, size_t count) {
  391|  1.38k|    for (size_t iii = 0; iii < count; ++iii) {
  ------------------
  |  Branch (391:26): [True: 1.23k, False: 151]
  ------------------
  392|  1.23k|        if ((char)tolower((unsigned char)name_segment[iii]) != lowercase_filter_value[iii]) {
  ------------------
  |  Branch (392:13): [True: 752, False: 483]
  |  Branch (392:19): [True: 0, False: 0]
  |  Branch (392:19): [True: 0, False: 0]
  |  Branch (392:19): [Folded, False: 1.23k]
  ------------------
  393|    752|            return false;
  394|    752|        }
  395|  1.23k|    }
  396|    151|    return true;
  397|    903|}

loader_get_json:
  164|  24.1k|TEST_FUNCTION_EXPORT VkResult loader_get_json(const struct loader_instance *inst, const char *filename, cJSON **json) {
  165|  24.1k|    char *json_buf = NULL;
  166|  24.1k|    VkResult res = VK_SUCCESS;
  167|       |
  168|  24.1k|    assert(json != NULL);
  169|       |
  170|  24.1k|    size_t json_len = 0;
  171|  24.1k|    *json = NULL;
  172|  24.1k|    res = loader_read_entire_file(inst, filename, &json_len, &json_buf);
  173|  24.1k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (173:9): [True: 592, False: 23.5k]
  ------------------
  174|    592|        goto out;
  175|    592|    }
  176|  24.1k|    bool out_of_memory = false;
  177|       |    // Parse text from file
  178|  23.5k|    *json = loader_cJSON_ParseWithLength(inst ? &inst->alloc_callbacks : NULL, json_buf, json_len, &out_of_memory);
  ------------------
  |  Branch (178:42): [True: 23.5k, False: 0]
  ------------------
  179|  23.5k|    if (out_of_memory) {
  ------------------
  |  Branch (179:9): [True: 0, False: 23.5k]
  ------------------
  180|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Out of Memory error occurred while parsing JSON file %s.",
  181|      0|                   filename);
  182|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  183|      0|        goto out;
  184|  23.5k|    } else if (*json == NULL) {
  ------------------
  |  Branch (184:16): [True: 9.04k, False: 14.5k]
  ------------------
  185|  9.04k|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Invalid JSON file %s.", filename);
  186|  9.04k|        goto out;
  187|  9.04k|    }
  188|       |
  189|  24.1k|out:
  190|  24.1k|    loader_instance_heap_free(inst, json_buf);
  191|  24.1k|    if (res != VK_SUCCESS && *json != NULL) {
  ------------------
  |  Branch (191:9): [True: 592, False: 23.5k]
  |  Branch (191:30): [True: 0, False: 592]
  ------------------
  192|      0|        loader_cJSON_Delete(*json);
  193|      0|        *json = NULL;
  194|      0|    }
  195|       |
  196|  24.1k|    return res;
  197|  23.5k|}
loader_parse_json_string_to_existing_str:
  199|   502k|VkResult loader_parse_json_string_to_existing_str(cJSON *object, const char *key, size_t out_str_len, char *out_string) {
  200|   502k|    if (NULL == key) {
  ------------------
  |  Branch (200:9): [True: 0, False: 502k]
  ------------------
  201|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  202|      0|    }
  203|   502k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  204|   502k|    if (NULL == item) {
  ------------------
  |  Branch (204:9): [True: 80.8k, False: 421k]
  ------------------
  205|  80.8k|        return VK_ERROR_INITIALIZATION_FAILED;
  206|  80.8k|    }
  207|       |
  208|   421k|    if (item->type != cJSON_String || item->valuestring == NULL) {
  ------------------
  |  |  101|   843k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (208:9): [True: 7.46k, False: 414k]
  |  Branch (208:39): [True: 0, False: 414k]
  ------------------
  209|  7.46k|        return VK_ERROR_INITIALIZATION_FAILED;
  210|  7.46k|    }
  211|   421k|    bool out_of_memory = false;
  212|   414k|    bool success = loader_cJSON_PrintPreallocated(item, out_string, (int)out_str_len, cJSON_False);
  ------------------
  |  |   97|   414k|#define cJSON_False (1 << 0)
  ------------------
  213|   414k|    if (out_of_memory) {
  ------------------
  |  Branch (213:9): [True: 0, False: 414k]
  ------------------
  214|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  215|      0|    }
  216|   414k|    if (!success) {
  ------------------
  |  Branch (216:9): [True: 555, False: 413k]
  ------------------
  217|    555|        return VK_ERROR_INITIALIZATION_FAILED;
  218|    555|    }
  219|   413k|    return VK_SUCCESS;
  220|   414k|}
loader_parse_json_string:
  222|   252k|VkResult loader_parse_json_string(cJSON *object, const char *key, char **out_string) {
  223|   252k|    if (NULL == key) {
  ------------------
  |  Branch (223:9): [True: 0, False: 252k]
  ------------------
  224|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  225|      0|    }
  226|       |
  227|   252k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  228|   252k|    if (NULL == item || NULL == item->valuestring) {
  ------------------
  |  Branch (228:9): [True: 111k, False: 140k]
  |  Branch (228:25): [True: 396, False: 139k]
  ------------------
  229|   112k|        return VK_ERROR_INITIALIZATION_FAILED;
  230|   112k|    }
  231|       |
  232|   252k|    bool out_of_memory = false;
  233|   139k|    char *str = loader_cJSON_Print(item, &out_of_memory);
  234|   139k|    if (out_of_memory || NULL == str) {
  ------------------
  |  Branch (234:9): [True: 0, False: 139k]
  |  Branch (234:26): [True: 0, False: 139k]
  ------------------
  235|      0|        return VK_ERROR_OUT_OF_HOST_MEMORY;
  236|      0|    }
  237|   139k|    if (NULL != out_string) {
  ------------------
  |  Branch (237:9): [True: 139k, False: 0]
  ------------------
  238|   139k|        *out_string = str;
  239|   139k|    }
  240|   139k|    return VK_SUCCESS;
  241|   139k|}
loader_parse_json_array_of_strings:
  243|   209k|                                            struct loader_string_list *string_list) {
  244|   209k|    if (NULL == key) {
  ------------------
  |  Branch (244:9): [True: 0, False: 209k]
  ------------------
  245|      0|        return VK_ERROR_INITIALIZATION_FAILED;
  246|      0|    }
  247|   209k|    cJSON *item = loader_cJSON_GetObjectItem(object, key);
  248|   209k|    if (NULL == item) {
  ------------------
  |  Branch (248:9): [True: 139k, False: 69.5k]
  ------------------
  249|   139k|        return VK_ERROR_INITIALIZATION_FAILED;
  250|   139k|    }
  251|       |
  252|  69.5k|    uint32_t count = loader_cJSON_GetArraySize(item);
  253|  69.5k|    if (count == 0) {
  ------------------
  |  Branch (253:9): [True: 15.6k, False: 53.8k]
  ------------------
  254|  15.6k|        return VK_SUCCESS;
  255|  15.6k|    }
  256|       |
  257|  53.8k|    VkResult res = create_string_list(inst, count, string_list);
  258|  53.8k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (258:9): [True: 0, False: 53.8k]
  ------------------
  259|      0|        goto out;
  260|      0|    }
  261|  53.8k|    cJSON *element = NULL;
  262|   124k|    cJSON_ArrayForEach(element, item) {
  ------------------
  |  |  213|   176k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 53.8k, False: 0]
  |  |  |  Branch (213:61): [True: 124k, False: 52.5k]
  |  |  ------------------
  ------------------
  263|   124k|        if (element->type != cJSON_String) {
  ------------------
  |  |  101|   124k|#define cJSON_String (1 << 4)
  ------------------
  |  Branch (263:13): [True: 1.34k, False: 122k]
  ------------------
  264|  1.34k|            return VK_ERROR_INITIALIZATION_FAILED;
  265|  1.34k|        }
  266|   124k|        bool out_of_memory = false;
  267|   122k|        char *out_data = loader_cJSON_Print(element, &out_of_memory);
  268|   122k|        if (out_of_memory) {
  ------------------
  |  Branch (268:13): [True: 0, False: 122k]
  ------------------
  269|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  270|      0|            goto out;
  271|      0|        }
  272|   122k|        res = append_str_to_string_list(inst, string_list, out_data);
  273|   122k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (273:13): [True: 0, False: 122k]
  ------------------
  274|      0|            goto out;
  275|      0|        }
  276|   122k|    }
  277|  52.5k|out:
  278|  52.5k|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY && NULL != string_list->list) {
  ------------------
  |  Branch (278:9): [True: 0, False: 52.5k]
  |  Branch (278:47): [True: 0, False: 0]
  ------------------
  279|      0|        free_string_list(inst, string_list);
  280|      0|    }
  281|       |
  282|  52.5k|    return res;
  283|  53.8k|}
loader_json.c:loader_read_entire_file:
  110|  24.1k|                                        char **out_buff) {
  111|  24.1k|    FILE *file = NULL;
  112|  24.1k|    struct stat stats = {0};
  113|  24.1k|    VkResult res = VK_SUCCESS;
  114|       |
  115|       |    // fprintf(stderr, "loader_get_json: Reading JSON file %s\n", filename);
  116|  24.1k|    file = fopen(filename, "rb");
  117|  24.1k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  118|  24.1k|    if (file == NULL) {
  ------------------
  |  Branch (118:9): [True: 5.27k, False: 18.9k]
  ------------------
  119|  5.27k|        create_callback_file(filename);
  120|  5.27k|        file = fopen(filename, "rb");
  121|  5.27k|    }
  122|  24.1k|#endif
  123|  24.1k|    if (NULL == file) {
  ------------------
  |  Branch (123:9): [True: 518, False: 23.6k]
  ------------------
  124|    518|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to open JSON file %s", filename);
  125|    518|        res = VK_ERROR_INITIALIZATION_FAILED;
  126|    518|        goto out;
  127|    518|    }
  128|  23.6k|    if (-1 == fstat(fileno(file), &stats)) {
  ------------------
  |  Branch (128:9): [True: 0, False: 23.6k]
  ------------------
  129|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to read file size of JSON file %s", filename);
  130|      0|        res = VK_ERROR_INITIALIZATION_FAILED;
  131|      0|        goto out;
  132|      0|    }
  133|  23.6k|    *out_buff = (char *)loader_instance_heap_calloc(inst, stats.st_size + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  134|  23.6k|    if (NULL == *out_buff) {
  ------------------
  |  Branch (134:9): [True: 0, False: 23.6k]
  ------------------
  135|      0|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to allocate memory to read JSON file %s", filename);
  136|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  137|      0|        goto out;
  138|      0|    }
  139|  23.6k|    if (stats.st_size != (long int)fread(*out_buff, sizeof(char), stats.st_size, file)) {
  ------------------
  |  Branch (139:9): [True: 74, False: 23.5k]
  ------------------
  140|     74|        loader_log(inst, VULKAN_LOADER_ERROR_BIT, 0, "loader_get_json: Failed to read entire JSON file %s", filename);
  141|     74|        res = VK_ERROR_INITIALIZATION_FAILED;
  142|     74|        goto out;
  143|     74|    }
  144|  23.5k|    *out_len = stats.st_size + 1;
  145|       |    // out_buff was allocated with stats.st_size + 1 bytes above, and the fread check already verified the file's
  146|       |    // contents did not change size out from under us; this is the last valid byte.
  147|       |    // NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
  148|  23.5k|    (*out_buff)[stats.st_size] = '\0';
  149|       |
  150|  24.1k|out:
  151|  24.1k|    if (NULL != file) {
  ------------------
  |  Branch (151:9): [True: 23.6k, False: 518]
  ------------------
  152|       |        // NOLINTNEXTLINE(cert-err33-c) - file was only opened for reading, nothing to flush; res already reflects any read failure
  153|  23.6k|        fclose(file);
  154|  23.6k|    }
  155|  24.1k|    return res;
  156|  23.5k|}

loader_init_global_debug_level:
   42|      2|void loader_init_global_debug_level(void) {
   43|      2|    char *env;
   44|      2|    char *orig;
   45|       |
   46|      2|    if (g_loader_debug > 0) return;
  ------------------
  |  Branch (46:9): [True: 0, False: 2]
  ------------------
   47|       |
   48|      2|    g_loader_debug = 0;
   49|       |
   50|       |    // Parse comma-separated debug options
   51|      2|    orig = env = loader_getenv("VK_LOADER_DEBUG", NULL);
   52|      2|    while (env) {
  ------------------
  |  Branch (52:12): [True: 0, False: 2]
  ------------------
   53|      0|        char *p = strchr(env, ',');
   54|      0|        size_t len;
   55|       |
   56|      0|        if (p) {
  ------------------
  |  Branch (56:13): [True: 0, False: 0]
  ------------------
   57|      0|            len = p - env;
   58|      0|        } else {
   59|      0|            len = strlen(env);
   60|      0|        }
   61|       |
   62|      0|        if (len > 0) {
  ------------------
  |  Branch (62:13): [True: 0, False: 0]
  ------------------
   63|      0|            if (strncmp(env, "all", len) == 0) {
  ------------------
  |  Branch (63:17): [True: 0, False: 0]
  ------------------
   64|      0|                g_loader_debug = ~0u;
   65|      0|            } else if (strncmp(env, "warn", len) == 0) {
  ------------------
  |  Branch (65:24): [True: 0, False: 0]
  ------------------
   66|      0|                g_loader_debug |= VULKAN_LOADER_WARN_BIT;
   67|      0|            } else if (strncmp(env, "info", len) == 0) {
  ------------------
  |  Branch (67:24): [True: 0, False: 0]
  ------------------
   68|      0|                g_loader_debug |= VULKAN_LOADER_INFO_BIT;
   69|      0|            } else if (strncmp(env, "perf", len) == 0) {
  ------------------
  |  Branch (69:24): [True: 0, False: 0]
  ------------------
   70|      0|                g_loader_debug |= VULKAN_LOADER_PERF_BIT;
   71|      0|            } else if (strncmp(env, "error", len) == 0) {
  ------------------
  |  Branch (71:24): [True: 0, False: 0]
  ------------------
   72|      0|                g_loader_debug |= VULKAN_LOADER_ERROR_BIT;
   73|      0|            } else if (strncmp(env, "debug", len) == 0) {
  ------------------
  |  Branch (73:24): [True: 0, False: 0]
  ------------------
   74|      0|                g_loader_debug |= VULKAN_LOADER_DEBUG_BIT;
   75|      0|            } else if (strncmp(env, "layer", len) == 0) {
  ------------------
  |  Branch (75:24): [True: 0, False: 0]
  ------------------
   76|      0|                g_loader_debug |= VULKAN_LOADER_LAYER_BIT;
   77|      0|            } else if (strncmp(env, "driver", len) == 0 || strncmp(env, "implem", len) == 0 || strncmp(env, "icd", len) == 0) {
  ------------------
  |  Branch (77:24): [True: 0, False: 0]
  |  Branch (77:60): [True: 0, False: 0]
  |  Branch (77:96): [True: 0, False: 0]
  ------------------
   78|      0|                g_loader_debug |= VULKAN_LOADER_DRIVER_BIT;
   79|      0|            }
   80|      0|        }
   81|       |
   82|      0|        if (!p) break;
  ------------------
  |  Branch (82:13): [True: 0, False: 0]
  ------------------
   83|       |
   84|      0|        env = p + 1;
   85|      0|    }
   86|       |
   87|       |    loader_free_getenv(orig, NULL);
   88|      2|}
generate_debug_flag_str:
   93|  2.45k|void generate_debug_flag_str(VkFlags msg_type, size_t cmd_line_size, char *cmd_line_msg) {
   94|  2.45k|    cmd_line_msg[0] = '\0';
   95|       |
   96|  2.45k|    if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (96:9): [True: 101, False: 2.35k]
  ------------------
   97|    101|        loader_strncat(cmd_line_msg, cmd_line_size, "ERROR", sizeof("ERROR"));
   98|    101|    }
   99|  2.45k|    if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (99:9): [True: 114, False: 2.34k]
  ------------------
  100|    114|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (100:13): [True: 97, False: 17]
  ------------------
  101|     97|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  102|     97|        }
  103|    114|        loader_strncat(cmd_line_msg, cmd_line_size, "WARNING", sizeof("WARNING"));
  104|    114|    }
  105|  2.45k|    if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (105:9): [True: 109, False: 2.34k]
  ------------------
  106|    109|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (106:13): [True: 94, False: 15]
  ------------------
  107|     94|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  108|     94|        }
  109|    109|        loader_strncat(cmd_line_msg, cmd_line_size, "INFO", sizeof("INFO"));
  110|    109|    }
  111|  2.45k|    if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (111:9): [True: 112, False: 2.34k]
  ------------------
  112|    112|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (112:13): [True: 102, False: 10]
  ------------------
  113|    102|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  114|    102|        }
  115|    112|        loader_strncat(cmd_line_msg, cmd_line_size, "DEBUG", sizeof("DEBUG"));
  116|    112|    }
  117|  2.45k|    if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (117:9): [True: 111, False: 2.34k]
  ------------------
  118|    111|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (118:13): [True: 100, False: 11]
  ------------------
  119|    100|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  120|    100|        }
  121|    111|        loader_strncat(cmd_line_msg, cmd_line_size, "PERF", sizeof("PERF"));
  122|    111|    }
  123|  2.45k|    if ((msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (123:9): [True: 104, False: 2.35k]
  ------------------
  124|    104|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (124:13): [True: 101, False: 3]
  ------------------
  125|    101|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  126|    101|        }
  127|    104|        loader_strncat(cmd_line_msg, cmd_line_size, "DRIVER", sizeof("DRIVER"));
  128|    104|    }
  129|  2.45k|    if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0) {
  ------------------
  |  Branch (129:9): [True: 112, False: 2.34k]
  ------------------
  130|    112|        if (strlen(cmd_line_msg) > 0) {
  ------------------
  |  Branch (130:13): [True: 104, False: 8]
  ------------------
  131|    104|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  132|    104|        }
  133|    112|        loader_strncat(cmd_line_msg, cmd_line_size, "LAYER", sizeof("LAYER"));
  134|    112|    }
  135|       |
  136|  2.45k|#undef STRNCAT_TO_BUFFER
  137|  2.45k|}
loader_log:
  141|   859k|    loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...) {
  142|   859k|    (void)msg_code;
  143|   859k|    char msg[512] = {0};
  144|       |
  145|   859k|    va_list ap;
  146|   859k|    va_start(ap, format);
  147|   859k|    int ret = vsnprintf(msg, sizeof(msg), format, ap);
  148|   859k|    if ((ret >= (int)sizeof(msg)) || ret < 0) {
  ------------------
  |  Branch (148:9): [True: 1.57k, False: 857k]
  |  Branch (148:38): [True: 0, False: 857k]
  ------------------
  149|  1.57k|        msg[sizeof(msg) - 1] = '\0';
  150|  1.57k|    }
  151|   859k|    va_end(ap);
  152|       |
  153|   859k|    if (inst) {
  ------------------
  |  Branch (153:9): [True: 859k, False: 2]
  ------------------
  154|       |        // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) - external Vulkan enum, has no zero value we can add
  155|   859k|        VkDebugUtilsMessageSeverityFlagBitsEXT severity = 0;
  156|   859k|        VkDebugUtilsMessageTypeFlagsEXT type = 0;
  157|   859k|        VkDebugUtilsMessengerCallbackDataEXT callback_data = {0};
  158|   859k|        VkDebugUtilsObjectNameInfoEXT object_name = {0};
  159|       |
  160|       |        // NOLINTNEXTLINE(bugprone-branch-clone) - duplicated so combined bit calls (e.g. WARN_BIT|LAYER_BIT) match first branch
  161|   859k|        if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (161:13): [True: 134k, False: 724k]
  ------------------
  162|   134k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
  163|   724k|        } else if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (163:20): [True: 449k, False: 274k]
  ------------------
  164|   449k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
  165|   449k|        } else if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (165:20): [True: 16.8k, False: 258k]
  ------------------
  166|  16.8k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
  167|   258k|        } else if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (167:20): [True: 144k, False: 113k]
  ------------------
  168|   144k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
  169|   144k|        } else if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0 || (msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (169:20): [True: 113k, False: 51]
  |  Branch (169:65): [True: 51, False: 0]
  ------------------
  170|       |            // Just driver or just layer bit should be treated as an info message in debug utils.
  171|   113k|            severity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
  172|   113k|        }
  173|       |
  174|   859k|        if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (174:13): [True: 0, False: 859k]
  ------------------
  175|      0|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
  176|   859k|        } else if ((msg_type & VULKAN_LOADER_VALIDATION_BIT) != 0) {
  ------------------
  |  Branch (176:20): [True: 0, False: 859k]
  ------------------
  177|       |            // For loader logging, if it's a validation message, we still want to also keep the general flag as well
  178|       |            // so messages of type validation can still be triggered for general message callbacks.
  179|      0|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
  180|   859k|        } else {
  181|   859k|            type = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT;
  182|   859k|        }
  183|       |
  184|   859k|        callback_data.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT;
  185|   859k|        callback_data.pMessageIdName = "Loader Message";
  186|   859k|        callback_data.pMessage = msg;
  187|   859k|        callback_data.objectCount = 1;
  188|   859k|        callback_data.pObjects = &object_name;
  189|   859k|        object_name.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
  190|   859k|        object_name.objectType = VK_OBJECT_TYPE_INSTANCE;
  191|   859k|        object_name.objectHandle = (uint64_t)(uintptr_t)inst;
  192|       |
  193|   859k|        util_SubmitDebugUtilsMessageEXT(inst, severity, type, &callback_data);
  194|   859k|    }
  195|       |
  196|       |    // Always log to stderr if this is a fatal error
  197|   859k|    if (0 == (msg_type & VULKAN_LOADER_FATAL_ERROR_BIT)) {
  ------------------
  |  Branch (197:9): [True: 859k, False: 0]
  ------------------
  198|   859k|        if (inst && inst->settings.settings_active && inst->settings.debug_level > 0) {
  ------------------
  |  Branch (198:13): [True: 859k, False: 2]
  |  Branch (198:21): [True: 647k, False: 211k]
  |  Branch (198:55): [True: 23.2k, False: 624k]
  ------------------
  199|       |            // Exit early if the current instance settings have some debugging options but do match the current msg_type
  200|  23.2k|            if (0 == (msg_type & inst->settings.debug_level)) {
  ------------------
  |  Branch (200:17): [True: 4.47k, False: 18.7k]
  ------------------
  201|  4.47k|                return;
  202|  4.47k|            }
  203|       |            // Check the global settings and if that doesn't say to skip, check the environment variable
  204|   836k|        } else if (0 == (msg_type & g_loader_debug)) {
  ------------------
  |  Branch (204:20): [True: 836k, False: 0]
  ------------------
  205|   836k|            return;
  206|   836k|        }
  207|   859k|    }
  208|       |
  209|       |#if defined(DEBUG)
  210|       |    int debug_flag_mask =
  211|       |        (int)(msg_type & (VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_DEBUG_BIT));
  212|       |    assert((debug_flag_mask == 0 || debug_flag_mask == VULKAN_LOADER_ERROR_BIT || debug_flag_mask == VULKAN_LOADER_WARN_BIT ||
  213|       |            debug_flag_mask == VULKAN_LOADER_INFO_BIT || debug_flag_mask == VULKAN_LOADER_DEBUG_BIT) &&
  214|       |           "This log has more than one exclusive debug flags (error, warn, info, debug) set");
  215|       |#endif
  216|       |
  217|       |    // Only need enough space to create the filter description header for log messages
  218|       |    // Also use the same header for all output
  219|  18.7k|    char cmd_line_msg[64] = {0};
  220|  18.7k|    size_t cmd_line_size = sizeof(cmd_line_msg);
  221|       |
  222|  18.7k|    loader_strncat(cmd_line_msg, cmd_line_size, "[Vulkan Loader] ", sizeof("[Vulkan Loader] "));
  223|       |
  224|  18.7k|    bool need_separator = false;
  225|  18.7k|    if ((msg_type & VULKAN_LOADER_ERROR_BIT) != 0) {
  ------------------
  |  Branch (225:9): [True: 1.10k, False: 17.6k]
  ------------------
  226|  1.10k|        loader_strncat(cmd_line_msg, cmd_line_size, "ERROR", sizeof("ERROR"));
  227|  1.10k|        need_separator = true;
  228|  17.6k|    } else if ((msg_type & VULKAN_LOADER_WARN_BIT) != 0) {
  ------------------
  |  Branch (228:16): [True: 4.51k, False: 13.1k]
  ------------------
  229|  4.51k|        loader_strncat(cmd_line_msg, cmd_line_size, "WARNING", sizeof("WARNING"));
  230|  4.51k|        need_separator = true;
  231|  13.1k|    } else if ((msg_type & VULKAN_LOADER_INFO_BIT) != 0) {
  ------------------
  |  Branch (231:16): [True: 1.16k, False: 11.9k]
  ------------------
  232|  1.16k|        loader_strncat(cmd_line_msg, cmd_line_size, "INFO", sizeof("INFO"));
  233|  1.16k|        need_separator = true;
  234|  11.9k|    } else if ((msg_type & VULKAN_LOADER_DEBUG_BIT) != 0) {
  ------------------
  |  Branch (234:16): [True: 10.9k, False: 1.02k]
  ------------------
  235|  10.9k|        loader_strncat(cmd_line_msg, cmd_line_size, "DEBUG", sizeof("DEBUG"));
  236|  10.9k|        need_separator = true;
  237|  10.9k|    }
  238|       |
  239|  18.7k|    if ((msg_type & VULKAN_LOADER_PERF_BIT) != 0) {
  ------------------
  |  Branch (239:9): [True: 0, False: 18.7k]
  ------------------
  240|      0|        if (need_separator) {
  ------------------
  |  Branch (240:13): [True: 0, False: 0]
  ------------------
  241|      0|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  242|      0|        }
  243|      0|        loader_strncat(cmd_line_msg, cmd_line_size, "PERF", sizeof("PERF"));
  244|  18.7k|    } else if ((msg_type & VULKAN_LOADER_DRIVER_BIT) != 0) {
  ------------------
  |  Branch (244:16): [True: 12, False: 18.7k]
  ------------------
  245|     12|        if (need_separator) {
  ------------------
  |  Branch (245:13): [True: 1, False: 11]
  ------------------
  246|      1|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  247|      1|        }
  248|     12|        loader_strncat(cmd_line_msg, cmd_line_size, "DRIVER", sizeof("DRIVER"));
  249|  18.7k|    } else if ((msg_type & VULKAN_LOADER_LAYER_BIT) != 0) {
  ------------------
  |  Branch (249:16): [True: 2.05k, False: 16.7k]
  ------------------
  250|  2.05k|        if (need_separator) {
  ------------------
  |  Branch (250:13): [True: 1.04k, False: 1.00k]
  ------------------
  251|  1.04k|            loader_strncat(cmd_line_msg, cmd_line_size, " | ", sizeof(" | "));
  252|  1.04k|        }
  253|  2.05k|        loader_strncat(cmd_line_msg, cmd_line_size, "LAYER", sizeof("LAYER"));
  254|  2.05k|    }
  255|       |
  256|  18.7k|    loader_strncat(cmd_line_msg, cmd_line_size, ": ", sizeof(": "));
  257|  18.7k|    size_t num_used = strlen(cmd_line_msg);
  258|       |
  259|       |    // Justifies the output to at least 29 spaces
  260|  18.7k|    if (num_used < 32) {
  ------------------
  |  Branch (260:9): [True: 18.4k, False: 372]
  ------------------
  261|  18.4k|        const char space_buffer[] = "                                ";
  262|       |        // Only write (32 - num_used) spaces
  263|  18.4k|        loader_strncat(cmd_line_msg, cmd_line_size, space_buffer, sizeof(space_buffer) - 1 - num_used);
  264|  18.4k|    }
  265|       |    // Assert that we didn't write more than what is available in cmd_line_msg
  266|  18.7k|    assert(cmd_line_size > num_used);
  267|       |
  268|       |    // NOLINTBEGIN(cert-err33-c) - this is the logger itself; no sane recovery from a failed stderr write
  269|       |    //fputs(cmd_line_msg, stderr);
  270|       |    //fputs(msg, stderr);
  271|       |    //fputc('\n', stderr);
  272|       |    // NOLINTEND(cert-err33-c)
  273|       |#if defined(WIN32)
  274|       |    OutputDebugString(cmd_line_msg);
  275|       |    OutputDebugString(msg);
  276|       |    OutputDebugString("\n");
  277|       |#endif
  278|  18.7k|}

free_layer_configuration:
   41|  29.5k|void free_layer_configuration(const struct loader_instance* inst, loader_settings_layer_configuration* layer_configuration) {
   42|  29.5k|    loader_instance_heap_free(inst, layer_configuration->name);
   43|  29.5k|    loader_instance_heap_free(inst, layer_configuration->path);
   44|  29.5k|    memset(layer_configuration, 0, sizeof(loader_settings_layer_configuration));
   45|  29.5k|}
free_loader_settings:
   57|  6.85k|void free_loader_settings(const struct loader_instance* inst, loader_settings* settings) {
   58|  6.85k|    if (NULL != settings->layer_configurations) {
  ------------------
  |  Branch (58:9): [True: 2.36k, False: 4.49k]
  ------------------
   59|  28.7k|        for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (59:30): [True: 26.3k, False: 2.36k]
  ------------------
   60|  26.3k|            free_layer_configuration(inst, &settings->layer_configurations[i]);
   61|  26.3k|        }
   62|  2.36k|        loader_instance_heap_free(inst, settings->layer_configurations);
   63|  2.36k|    }
   64|  6.85k|    if (NULL != settings->additional_drivers) {
  ------------------
  |  Branch (64:9): [True: 0, False: 6.85k]
  ------------------
   65|      0|        for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (65:30): [True: 0, False: 0]
  ------------------
   66|      0|            free_driver_configuration(inst, &settings->additional_drivers[i]);
   67|      0|        }
   68|      0|        loader_instance_heap_free(inst, settings->additional_drivers);
   69|      0|    }
   70|  6.85k|    if (NULL != settings->device_configurations) {
  ------------------
  |  Branch (70:9): [True: 0, False: 6.85k]
  ------------------
   71|      0|        for (uint32_t i = 0; i < settings->device_configuration_count; i++) {
  ------------------
  |  Branch (71:30): [True: 0, False: 0]
  ------------------
   72|      0|            free_device_configuration(inst, &settings->device_configurations[i]);
   73|      0|        }
   74|      0|        loader_instance_heap_free(inst, settings->device_configurations);
   75|      0|    }
   76|  6.85k|    loader_instance_heap_free(inst, settings->settings_file_path);
   77|  6.85k|    memset(settings, 0, sizeof(loader_settings));
   78|  6.85k|}
parse_control_string:
   80|  26.6k|loader_settings_layer_control parse_control_string(char* control_string) {
   81|  26.6k|    loader_settings_layer_control layer_control = LOADER_SETTINGS_LAYER_CONTROL_DEFAULT;
   82|  26.6k|    if (strcmp(control_string, "auto") == 0)
  ------------------
  |  Branch (82:9): [True: 3.67k, False: 23.0k]
  ------------------
   83|  3.67k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_DEFAULT;
   84|  23.0k|    else if (strcmp(control_string, "on") == 0)
  ------------------
  |  Branch (84:14): [True: 8.79k, False: 14.2k]
  ------------------
   85|  8.79k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_ON;
   86|  14.2k|    else if (strcmp(control_string, "off") == 0)
  ------------------
  |  Branch (86:14): [True: 2.53k, False: 11.6k]
  ------------------
   87|  2.53k|        layer_control = LOADER_SETTINGS_LAYER_CONTROL_OFF;
   88|  11.6k|    else if (strcmp(control_string, "unordered_layer_location") == 0)
  ------------------
  |  Branch (88:14): [True: 1.21k, False: 10.4k]
  ------------------
   89|  1.21k|        layer_control = LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION;
   90|  26.6k|    return layer_control;
   91|  26.6k|}
loader_settings_layer_control_to_string:
   93|  26.3k|const char* loader_settings_layer_control_to_string(loader_settings_layer_control control) {
   94|  26.3k|    switch (control) {
   95|  13.8k|        case LOADER_SETTINGS_LAYER_CONTROL_DEFAULT:
  ------------------
  |  Branch (95:9): [True: 13.8k, False: 12.5k]
  ------------------
   96|  13.8k|            return "auto";
   97|  8.76k|        case LOADER_SETTINGS_LAYER_CONTROL_ON:
  ------------------
  |  Branch (97:9): [True: 8.76k, False: 17.6k]
  ------------------
   98|  8.76k|            return "on";
   99|  2.52k|        case LOADER_SETTINGS_LAYER_CONTROL_OFF:
  ------------------
  |  Branch (99:9): [True: 2.52k, False: 23.8k]
  ------------------
  100|  2.52k|            return "off";
  101|  1.20k|        case LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION:
  ------------------
  |  Branch (101:9): [True: 1.20k, False: 25.1k]
  ------------------
  102|  1.20k|            return "unordered_layer_location";
  103|      0|        default:
  ------------------
  |  Branch (103:9): [True: 0, False: 26.3k]
  ------------------
  104|      0|            return "UNKNOWN_LAYER_CONTROl";
  105|  26.3k|    }
  106|  26.3k|}
parse_log_filters_from_strings:
  108|    353|uint32_t parse_log_filters_from_strings(struct loader_string_list* log_filters) {
  109|    353|    uint32_t filters = 0;
  110|  15.7k|    for (uint32_t i = 0; i < log_filters->count; i++) {
  ------------------
  |  Branch (110:26): [True: 15.4k, False: 353]
  ------------------
  111|  15.4k|        if (strcmp(log_filters->list[i], "all") == 0)
  ------------------
  |  Branch (111:13): [True: 325, False: 15.0k]
  ------------------
  112|    325|            filters |= VULKAN_LOADER_INFO_BIT | VULKAN_LOADER_WARN_BIT | VULKAN_LOADER_PERF_BIT | VULKAN_LOADER_ERROR_BIT |
  113|    325|                       VULKAN_LOADER_DEBUG_BIT | VULKAN_LOADER_LAYER_BIT | VULKAN_LOADER_DRIVER_BIT | VULKAN_LOADER_VALIDATION_BIT;
  114|  15.0k|        else if (strcmp(log_filters->list[i], "info") == 0)
  ------------------
  |  Branch (114:18): [True: 266, False: 14.8k]
  ------------------
  115|    266|            filters |= VULKAN_LOADER_INFO_BIT;
  116|  14.8k|        else if (strcmp(log_filters->list[i], "warn") == 0)
  ------------------
  |  Branch (116:18): [True: 950, False: 13.8k]
  ------------------
  117|    950|            filters |= VULKAN_LOADER_WARN_BIT;
  118|  13.8k|        else if (strcmp(log_filters->list[i], "perf") == 0)
  ------------------
  |  Branch (118:18): [True: 686, False: 13.1k]
  ------------------
  119|    686|            filters |= VULKAN_LOADER_PERF_BIT;
  120|  13.1k|        else if (strcmp(log_filters->list[i], "error") == 0)
  ------------------
  |  Branch (120:18): [True: 206, False: 12.9k]
  ------------------
  121|    206|            filters |= VULKAN_LOADER_ERROR_BIT;
  122|  12.9k|        else if (strcmp(log_filters->list[i], "debug") == 0)
  ------------------
  |  Branch (122:18): [True: 1.67k, False: 11.2k]
  ------------------
  123|  1.67k|            filters |= VULKAN_LOADER_DEBUG_BIT;
  124|  11.2k|        else if (strcmp(log_filters->list[i], "layer") == 0)
  ------------------
  |  Branch (124:18): [True: 367, False: 10.9k]
  ------------------
  125|    367|            filters |= VULKAN_LOADER_LAYER_BIT;
  126|  10.9k|        else if (strcmp(log_filters->list[i], "driver") == 0)
  ------------------
  |  Branch (126:18): [True: 144, False: 10.7k]
  ------------------
  127|    144|            filters |= VULKAN_LOADER_DRIVER_BIT;
  128|  10.7k|        else if (strcmp(log_filters->list[i], "validation") == 0)
  ------------------
  |  Branch (128:18): [True: 79, False: 10.7k]
  ------------------
  129|     79|            filters |= VULKAN_LOADER_VALIDATION_BIT;
  130|  15.4k|    }
  131|    353|    return filters;
  132|    353|}
parse_layer_configuration:
  147|  26.6k|                                   loader_settings_layer_configuration* layer_configuration) {
  148|  26.6k|    char* control_string = NULL;
  149|  26.6k|    VkResult res = loader_parse_json_string(layer_configuration_json, "control", &control_string);
  150|  26.6k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (150:9): [True: 12, False: 26.6k]
  ------------------
  151|     12|        goto out;
  152|     12|    }
  153|  26.6k|    layer_configuration->control = parse_control_string(control_string);
  154|  26.6k|    loader_instance_heap_free(inst, control_string);
  155|       |
  156|       |    // If that is the only value - do no further parsing
  157|  26.6k|    if (layer_configuration->control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (157:9): [True: 1.21k, False: 25.4k]
  ------------------
  158|  1.21k|        goto out;
  159|  1.21k|    }
  160|       |
  161|  25.4k|    res = loader_parse_json_string(layer_configuration_json, "name", &(layer_configuration->name));
  162|  25.4k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (162:9): [True: 137, False: 25.3k]
  ------------------
  163|    137|        goto out;
  164|    137|    }
  165|       |
  166|  25.3k|    res = loader_parse_json_string(layer_configuration_json, "path", &(layer_configuration->path));
  167|  25.3k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (167:9): [True: 7, False: 25.3k]
  ------------------
  168|      7|        goto out;
  169|      7|    }
  170|       |
  171|  25.3k|    cJSON* treat_as_implicit_manifest = loader_cJSON_GetObjectItem(layer_configuration_json, "treat_as_implicit_manifest");
  172|  25.3k|    if (treat_as_implicit_manifest && treat_as_implicit_manifest->type == cJSON_True) {
  ------------------
  |  |   98|    365|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (172:9): [True: 365, False: 24.9k]
  |  Branch (172:39): [True: 252, False: 113]
  ------------------
  173|    252|        layer_configuration->treat_as_implicit_manifest = true;
  174|    252|    }
  175|  26.6k|out:
  176|  26.6k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (176:9): [True: 156, False: 26.5k]
  ------------------
  177|    156|        free_layer_configuration(inst, layer_configuration);
  178|    156|    }
  179|  26.6k|    return res;
  180|  25.3k|}
parse_layer_configurations:
  182|  2.82k|VkResult parse_layer_configurations(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  183|  2.82k|    VkResult res = VK_SUCCESS;
  184|       |
  185|  2.82k|    cJSON* layer_configurations = loader_cJSON_GetObjectItem(settings_object, "layers");
  186|       |    // If the layers object isn't present, return early with success to allow the settings file to still apply
  187|  2.82k|    if (NULL == layer_configurations) {
  ------------------
  |  Branch (187:9): [True: 281, False: 2.54k]
  ------------------
  188|    281|        return VK_SUCCESS;
  189|    281|    }
  190|       |
  191|  2.54k|    uint32_t layer_configurations_count = loader_cJSON_GetArraySize(layer_configurations);
  192|  2.54k|    if (layer_configurations_count == 0) {
  ------------------
  |  Branch (192:9): [True: 9, False: 2.53k]
  ------------------
  193|      9|        loader_settings->layer_configurations_active = true;
  194|      9|        return VK_SUCCESS;
  195|      9|    }
  196|       |
  197|  2.53k|    loader_settings->layer_configuration_count = layer_configurations_count;
  198|       |
  199|  2.53k|    loader_settings->layer_configurations = loader_instance_heap_calloc(
  200|  2.53k|        inst, sizeof(loader_settings_layer_configuration) * layer_configurations_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  201|  2.53k|    if (NULL == loader_settings->layer_configurations) {
  ------------------
  |  Branch (201:9): [True: 0, False: 2.53k]
  ------------------
  202|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  203|      0|        goto out;
  204|      0|    }
  205|       |
  206|  2.53k|    cJSON* layer = NULL;
  207|  2.53k|    size_t i = 0;
  208|  26.7k|    cJSON_ArrayForEach(layer, layer_configurations) {
  ------------------
  |  |  213|  29.0k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 2.53k, False: 0]
  |  |  |  Branch (213:61): [True: 26.7k, False: 2.36k]
  |  |  ------------------
  ------------------
  209|  26.7k|        if (layer->type != cJSON_Object) {
  ------------------
  |  |  103|  26.7k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (209:13): [True: 12, False: 26.6k]
  ------------------
  210|     12|            res = VK_ERROR_INITIALIZATION_FAILED;
  211|     12|            goto out;
  212|     12|        }
  213|  26.6k|        res = parse_layer_configuration(inst, layer, &(loader_settings->layer_configurations[i++]));
  214|  26.6k|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (214:13): [True: 156, False: 26.5k]
  ------------------
  215|    156|            goto out;
  216|    156|        }
  217|  26.6k|    }
  218|  2.36k|    loader_settings->layer_configurations_active = true;
  219|  2.53k|out:
  220|  2.53k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (220:9): [True: 168, False: 2.36k]
  ------------------
  221|    168|        if (loader_settings->layer_configurations) {
  ------------------
  |  Branch (221:13): [True: 168, False: 0]
  ------------------
  222|  3.15k|            for (size_t index = 0; index < loader_settings->layer_configuration_count; index++) {
  ------------------
  |  Branch (222:36): [True: 2.98k, False: 168]
  ------------------
  223|  2.98k|                free_layer_configuration(inst, &(loader_settings->layer_configurations[index]));
  224|  2.98k|            }
  225|    168|            loader_settings->layer_configuration_count = 0;
  226|    168|            loader_instance_heap_free(inst, loader_settings->layer_configurations);
  227|    168|            loader_settings->layer_configurations = NULL;
  228|    168|        }
  229|    168|    }
  230|       |
  231|  2.53k|    return res;
  232|  2.36k|}
parse_additional_drivers:
  248|  2.82k|VkResult parse_additional_drivers(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  249|  2.82k|    VkResult res = VK_SUCCESS;
  250|       |
  251|  2.82k|    cJSON* additional_drivers_use_exclusively_json =
  252|  2.82k|        loader_cJSON_GetObjectItem(settings_object, "additional_drivers_use_exclusively");
  253|  2.82k|    if (additional_drivers_use_exclusively_json && additional_drivers_use_exclusively_json->type == cJSON_True) {
  ------------------
  |  |   98|      0|#define cJSON_True (1 << 1)
  ------------------
  |  Branch (253:9): [True: 0, False: 2.82k]
  |  Branch (253:52): [True: 0, False: 0]
  ------------------
  254|      0|        loader_settings->additional_drivers_use_exclusively = true;
  255|      0|    }
  256|       |
  257|  2.82k|    cJSON* additional_drivers_json = loader_cJSON_GetObjectItem(settings_object, "additional_drivers");
  258|  2.82k|    if (NULL == additional_drivers_json) {
  ------------------
  |  Branch (258:9): [True: 2.82k, False: 0]
  ------------------
  259|  2.82k|        return VK_SUCCESS;
  260|  2.82k|    }
  261|       |
  262|      0|    uint32_t additional_driver_count = loader_cJSON_GetArraySize(additional_drivers_json);
  263|      0|    if (additional_driver_count == 0) {
  ------------------
  |  Branch (263:9): [True: 0, False: 0]
  ------------------
  264|      0|        return VK_SUCCESS;
  265|      0|    }
  266|       |
  267|      0|    loader_settings->additional_driver_count = additional_driver_count;
  268|       |
  269|      0|    loader_settings->additional_drivers = loader_instance_heap_calloc(
  270|      0|        inst, sizeof(loader_settings_driver_configuration) * additional_driver_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  271|      0|    if (NULL == loader_settings->additional_drivers) {
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  273|      0|        goto out;
  274|      0|    }
  275|       |
  276|      0|    cJSON* driver = NULL;
  277|      0|    size_t i = 0;
  278|      0|    cJSON_ArrayForEach(driver, additional_drivers_json) {
  ------------------
  |  |  213|      0|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 0, False: 0]
  |  |  |  Branch (213:61): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  279|      0|        if (driver->type != cJSON_Object) {
  ------------------
  |  |  103|      0|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (279:13): [True: 0, False: 0]
  ------------------
  280|      0|            res = VK_ERROR_INITIALIZATION_FAILED;
  281|      0|            goto out;
  282|      0|        }
  283|      0|        res = parse_additional_driver(inst, driver, &(loader_settings->additional_drivers[i++]));
  284|      0|        if (VK_SUCCESS != res) {
  ------------------
  |  Branch (284:13): [True: 0, False: 0]
  ------------------
  285|      0|            goto out;
  286|      0|        }
  287|      0|    }
  288|      0|out:
  289|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      0|        if (loader_settings->additional_drivers) {
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  ------------------
  291|      0|            for (size_t index = 0; index < loader_settings->additional_driver_count; index++) {
  ------------------
  |  Branch (291:36): [True: 0, False: 0]
  ------------------
  292|      0|                free_driver_configuration(inst, &(loader_settings->additional_drivers[index]));
  293|      0|            }
  294|      0|            loader_settings->additional_driver_count = 0;
  295|      0|            loader_instance_heap_free(inst, loader_settings->additional_drivers);
  296|       |            loader_settings->additional_drivers = NULL;
  297|      0|        }
  298|      0|    }
  299|      0|    return res;
  300|      0|}
parse_device_configurations:
  375|  2.82k|VkResult parse_device_configurations(const struct loader_instance* inst, cJSON* settings_object, loader_settings* loader_settings) {
  376|  2.82k|    VkResult res = VK_SUCCESS;
  377|       |
  378|  2.82k|    cJSON* device_configurations = loader_cJSON_GetObjectItem(settings_object, "device_configurations");
  379|  2.82k|    if (NULL == device_configurations) {
  ------------------
  |  Branch (379:9): [True: 2.82k, False: 0]
  ------------------
  380|  2.82k|        return VK_SUCCESS;
  381|  2.82k|    }
  382|       |
  383|      0|    uint32_t device_configuration_count = loader_cJSON_GetArraySize(device_configurations);
  384|      0|    if (device_configuration_count == 0) {
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|        loader_settings->device_configurations_active = true;
  386|      0|        return VK_SUCCESS;
  387|      0|    }
  388|       |
  389|      0|    loader_settings->device_configuration_count = device_configuration_count;
  390|       |
  391|      0|    loader_settings->device_configurations = loader_instance_heap_calloc(
  392|      0|        inst, sizeof(loader_settings_device_configuration) * device_configuration_count, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  393|      0|    if (NULL == loader_settings->device_configurations) {
  ------------------
  |  Branch (393:9): [True: 0, False: 0]
  ------------------
  394|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  395|      0|        goto out;
  396|      0|    }
  397|       |
  398|      0|    cJSON* device = NULL;
  399|      0|    size_t i = 0;
  400|      0|    cJSON_ArrayForEach(device, device_configurations) {
  ------------------
  |  |  213|      0|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 0, False: 0]
  |  |  |  Branch (213:61): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  401|      0|        if (device->type != cJSON_Object) {
  ------------------
  |  |  103|      0|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (401:13): [True: 0, False: 0]
  ------------------
  402|      0|            res = VK_ERROR_INITIALIZATION_FAILED;
  403|      0|            goto out;
  404|      0|        }
  405|      0|        res = parse_device_configuration(inst, device, &(loader_settings->device_configurations[i]));
  406|      0|        if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (406:13): [True: 0, False: 0]
  ------------------
  407|      0|            goto out;
  408|      0|        } else if (res != VK_SUCCESS) {
  ------------------
  |  Branch (408:20): [True: 0, False: 0]
  ------------------
  409|       |            // Skip a malformed entry rather than discarding every device configuration in the file
  410|      0|            res = VK_SUCCESS;
  411|      0|            continue;
  412|      0|        }
  413|      0|        i++;
  414|      0|    }
  415|       |    // Only the first i entries were successfully parsed; the trailing entries are unpopulated
  416|      0|    loader_settings->device_configuration_count = (uint32_t)i;
  417|      0|    loader_settings->device_configurations_active = true;
  418|      0|out:
  419|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (419:9): [True: 0, False: 0]
  ------------------
  420|      0|        if (loader_settings->device_configurations) {
  ------------------
  |  Branch (420:13): [True: 0, False: 0]
  ------------------
  421|      0|            for (size_t index = 0; index < loader_settings->device_configuration_count; index++) {
  ------------------
  |  Branch (421:36): [True: 0, False: 0]
  ------------------
  422|      0|                free_device_configuration(inst, &(loader_settings->device_configurations[index]));
  423|      0|            }
  424|      0|            loader_settings->device_configuration_count = 0;
  425|      0|            loader_instance_heap_free(inst, loader_settings->device_configurations);
  426|       |            loader_settings->device_configurations = NULL;
  427|      0|        }
  428|      0|    }
  429|      0|    return res;
  430|      0|}
check_if_settings_path_exists:
  437|  30.1k|                                       char** settings_file_path) {
  438|  30.1k|    if (NULL == base || NULL == suffix) {
  ------------------
  |  Branch (438:9): [True: 13.7k, False: 16.4k]
  |  Branch (438:25): [True: 0, False: 16.4k]
  ------------------
  439|  13.7k|        return VK_ERROR_INITIALIZATION_FAILED;
  440|  13.7k|    }
  441|       |
  442|  16.4k|    size_t base_len = strlen(base);
  443|  16.4k|    size_t suffix_len = strlen(suffix);
  444|       |
  445|  16.4k|    uint32_t start = 0;
  446|  16.4k|    uint32_t stop = 0;
  447|  27.3k|    while (base[start] != '\0' && start < base_len && stop < base_len) {
  ------------------
  |  Branch (447:12): [True: 27.3k, False: 0]
  |  Branch (447:35): [True: 27.3k, False: 0]
  |  Branch (447:55): [True: 17.1k, False: 10.2k]
  ------------------
  448|  17.1k|        start = stop;
  449|  17.1k|        stop = start + 1;
  450|  90.7k|        while (base[stop] != PATH_SEPARATOR && base[stop] != '\0' && stop < base_len) {
  ------------------
  |  |  154|   181k|#define PATH_SEPARATOR ':'
  ------------------
  |  Branch (450:16): [True: 90.0k, False: 678]
  |  Branch (450:48): [True: 73.6k, False: 16.4k]
  |  Branch (450:70): [True: 73.6k, False: 0]
  ------------------
  451|  73.6k|            stop++;
  452|  73.6k|        }
  453|       |
  454|  17.1k|        size_t segment_len = (stop - start);
  455|  17.1k|        if (segment_len <= 1) {
  ------------------
  |  Branch (455:13): [True: 0, False: 17.1k]
  ------------------
  456|       |            // segment is *just* a PATH_SEPARATOR, skip it
  457|      0|            continue;
  458|      0|        }
  459|  17.1k|        size_t path_len = segment_len + suffix_len + 1;
  460|  17.1k|        *settings_file_path = loader_instance_heap_calloc(inst, path_len, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
  461|  17.1k|        if (NULL == *settings_file_path) {
  ------------------
  |  Branch (461:13): [True: 0, False: 17.1k]
  ------------------
  462|      0|            return VK_ERROR_OUT_OF_HOST_MEMORY;
  463|      0|        }
  464|  17.1k|        loader_strncpy(*settings_file_path, path_len, base + start, segment_len);
  465|  17.1k|        loader_strncat(*settings_file_path, path_len, suffix, suffix_len);
  466|       |
  467|  17.1k|        if (loader_platform_file_exists(*settings_file_path)) {
  ------------------
  |  Branch (467:13): [True: 6.17k, False: 10.9k]
  ------------------
  468|  6.17k|            return VK_SUCCESS;
  469|  6.17k|        }
  470|  10.9k|        loader_instance_heap_free(inst, *settings_file_path);
  471|  10.9k|        *settings_file_path = NULL;
  472|  10.9k|    }
  473|       |
  474|  10.2k|    return VK_ERROR_INITIALIZATION_FAILED;
  475|  16.4k|}
get_unix_settings_path:
  478|  6.85k|VkResult get_unix_settings_path(const struct loader_instance* inst, char** settings_file_path) {
  479|       |    // First, get XDG env-vars we use. Don't need to worry about free'ing because on linux getenv is non-allocating
  480|  6.85k|    char* xdg_config_home = loader_secure_getenv("XDG_CONFIG_HOME", inst);
  481|  6.85k|    char* xdg_config_dirs = loader_secure_getenv("XDG_CONFIG_DIRS", inst);
  482|  6.85k|    char* xdg_data_home = loader_secure_getenv("XDG_DATA_HOME", inst);
  483|  6.85k|    char* xdg_data_dirs = loader_secure_getenv("XDG_DATA_DIRS", inst);
  484|       |
  485|       |    // Use fallback directories for xdg_config_dirs and xdg_data_dirs if they are NULL.
  486|  6.85k|#if !defined(__Fuchsia__) && !defined(__QNX__)
  487|  6.85k|    if (NULL == xdg_config_dirs || '\0' == xdg_config_dirs[0]) {
  ------------------
  |  Branch (487:9): [True: 6.85k, False: 0]
  |  Branch (487:36): [True: 0, False: 0]
  ------------------
  488|  6.85k|        xdg_config_dirs = FALLBACK_CONFIG_DIRS;
  489|  6.85k|    }
  490|  6.85k|#endif
  491|       |
  492|  6.85k|#if !defined(__Fuchsia__) && !defined(__QNX__)
  493|  6.85k|    if (NULL == xdg_data_dirs || '\0' == xdg_data_dirs[0]) {
  ------------------
  |  Branch (493:9): [True: 6.85k, False: 0]
  |  Branch (493:34): [True: 0, False: 0]
  ------------------
  494|  6.85k|        xdg_data_dirs = FALLBACK_DATA_DIRS;
  495|  6.85k|    }
  496|  6.85k|#endif
  497|       |
  498|  6.85k|    VkResult res = check_if_settings_path_exists(
  499|  6.85k|        inst, xdg_config_home, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  145|  6.85k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  500|  6.85k|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (500:9): [True: 0, False: 6.85k]
  ------------------
  501|      0|        return res;
  502|      0|    }
  503|       |
  504|  6.85k|    res = check_if_settings_path_exists(inst, xdg_data_home, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|  6.85k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  505|  6.85k|                                        settings_file_path);
  506|  6.85k|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (506:9): [True: 0, False: 6.85k]
  ------------------
  507|      0|        return res;
  508|      0|    }
  509|       |
  510|       |    // Check home if either xdg_config_home or xdg_data_home wasn't set
  511|  6.85k|    char* home = loader_secure_getenv("HOME", inst);
  512|  6.85k|    if (home != NULL) {
  ------------------
  |  Branch (512:9): [True: 6.85k, False: 0]
  ------------------
  513|  6.85k|        if (NULL == xdg_config_home || '\0' == xdg_config_home[0]) {
  ------------------
  |  Branch (513:13): [True: 6.85k, False: 0]
  |  Branch (513:40): [True: 0, False: 0]
  ------------------
  514|  6.85k|            res = check_if_settings_path_exists(
  515|  6.85k|                inst, home, "/.config/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  145|  6.85k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  516|  6.85k|            if (res == VK_SUCCESS) {
  ------------------
  |  Branch (516:17): [True: 0, False: 6.85k]
  ------------------
  517|      0|                return res;
  518|      0|            }
  519|  6.85k|        }
  520|  6.85k|        if (NULL == xdg_data_home || '\0' == xdg_data_home[0]) {
  ------------------
  |  Branch (520:13): [True: 6.85k, False: 0]
  |  Branch (520:38): [True: 0, False: 0]
  ------------------
  521|  6.85k|            res = check_if_settings_path_exists(
  522|  6.85k|                inst, home, "/.local/share/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME, settings_file_path);
  ------------------
  |  |  145|  6.85k|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  523|  6.85k|            if (res == VK_SUCCESS) {
  ------------------
  |  Branch (523:17): [True: 6.17k, False: 678]
  ------------------
  524|  6.17k|                return res;
  525|  6.17k|            }
  526|  6.85k|        }
  527|  6.85k|    }
  528|       |
  529|    678|    res = check_if_settings_path_exists(inst, xdg_config_dirs, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    678|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  530|    678|                                        settings_file_path);
  531|    678|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (531:9): [True: 0, False: 678]
  ------------------
  532|      0|        return res;
  533|      0|    }
  534|       |
  535|    678|    res = check_if_settings_path_exists(inst, SYSCONFDIR, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    678|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  536|    678|                                        settings_file_path);
  537|    678|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (537:9): [True: 0, False: 678]
  ------------------
  538|      0|        return res;
  539|      0|    }
  540|    678|#if defined(EXTRASYSCONFDIR)
  541|       |
  542|    678|    res = check_if_settings_path_exists(inst, EXTRASYSCONFDIR, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    678|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  543|    678|                                        settings_file_path);
  544|    678|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (544:9): [True: 0, False: 678]
  ------------------
  545|      0|        return res;
  546|      0|    }
  547|    678|#endif
  548|    678|    res = check_if_settings_path_exists(inst, xdg_data_dirs, "/" VULKAN_DIR "/loader_settings.d/" VK_LOADER_SETTINGS_FILENAME,
  ------------------
  |  |  145|    678|#define VK_LOADER_SETTINGS_FILENAME "vk_loader_settings.json"
  ------------------
  549|    678|                                        settings_file_path);
  550|    678|    if (res == VK_SUCCESS) {
  ------------------
  |  Branch (550:9): [True: 0, False: 678]
  ------------------
  551|      0|        return res;
  552|      0|    }
  553|       |
  554|    678|    return VK_ERROR_INITIALIZATION_FAILED;
  555|    678|}
log_settings:
  614|  2.45k|void log_settings(const struct loader_instance* inst, loader_settings* settings) {
  615|  2.45k|    if (settings == NULL) {
  ------------------
  |  Branch (615:9): [True: 0, False: 2.45k]
  ------------------
  616|      0|        return;
  617|      0|    }
  618|  2.45k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "Using layer configurations found in loader settings from %s",
  619|  2.45k|               settings->settings_file_path);
  620|       |
  621|  2.45k|    char cmd_line_msg[64] = {0};
  622|  2.45k|    size_t cmd_line_size = sizeof(cmd_line_msg);
  623|       |
  624|  2.45k|    cmd_line_msg[0] = '\0';
  625|       |
  626|  2.45k|    generate_debug_flag_str(settings->debug_level, cmd_line_size, cmd_line_msg);
  627|  2.45k|    if (strlen(cmd_line_msg)) {
  ------------------
  |  Branch (627:9): [True: 165, False: 2.28k]
  ------------------
  628|    165|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Loader Settings Filters for Logging to Standard Error: %s", cmd_line_msg);
  629|    165|    }
  630|  2.45k|    if (settings->layer_configurations_active) {
  ------------------
  |  Branch (630:9): [True: 2.37k, False: 78]
  ------------------
  631|  2.37k|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Layer Configurations count = %d", settings->layer_configuration_count);
  632|  28.7k|        for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (632:30): [True: 26.3k, False: 2.37k]
  ------------------
  633|  26.3k|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Layer Configuration [%d] ----", i);
  634|  26.3k|            if (settings->layer_configurations[i].control != LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (634:17): [True: 25.1k, False: 1.20k]
  ------------------
  635|  25.1k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Name: %s", settings->layer_configurations[i].name);
  636|  25.1k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Path: %s", settings->layer_configurations[i].path);
  637|  25.1k|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Layer Type: %s",
  638|  25.1k|                           settings->layer_configurations[i].treat_as_implicit_manifest ? "Implicit" : "Explicit");
  ------------------
  |  Branch (638:28): [True: 192, False: 24.9k]
  ------------------
  639|  25.1k|            }
  640|  26.3k|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Control: %s",
  641|  26.3k|                       loader_settings_layer_control_to_string(settings->layer_configurations[i].control));
  642|  26.3k|        }
  643|  2.37k|    }
  644|  2.45k|    if (settings->additional_driver_count > 0) {
  ------------------
  |  Branch (644:9): [True: 0, False: 2.45k]
  ------------------
  645|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "----");
  646|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Use Additional Drivers Exclusively = %s",
  647|      0|                   settings->additional_drivers_use_exclusively ? "true" : "false");
  ------------------
  |  Branch (647:20): [True: 0, False: 0]
  ------------------
  648|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Additional Driver Configurations count = %d",
  649|      0|                   settings->additional_driver_count);
  650|      0|        for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (650:30): [True: 0, False: 0]
  ------------------
  651|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Driver Configuration [%d] ----", i);
  652|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Path: %s", settings->additional_drivers[i].path);
  653|      0|        }
  654|      0|    }
  655|  2.45k|    if (settings->device_configurations_active) {
  ------------------
  |  Branch (655:9): [True: 0, False: 2.45k]
  ------------------
  656|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "----");
  657|      0|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "Device Configurations count = %d", settings->device_configuration_count);
  658|      0|        for (uint32_t i = 0; i < settings->device_configuration_count; i++) {
  ------------------
  |  Branch (658:30): [True: 0, False: 0]
  ------------------
  659|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---- Device Configuration [%d] ----", i);
  660|      0|            char device_uuid_str[UUID_STR_LEN] = {0};
  661|      0|            loader_log_generate_uuid_string(settings->device_configurations[i].deviceUUID, device_uuid_str);
  662|      0|            char driver_uuid_str[UUID_STR_LEN] = {0};
  663|      0|            loader_log_generate_uuid_string(settings->device_configurations[i].driverUUID, driver_uuid_str);
  664|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "deviceUUID: %s", device_uuid_str);
  665|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "driverUUID: %s", driver_uuid_str);
  666|      0|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "driverVersion: %d", settings->device_configurations[i].driverVersion);
  667|      0|            if ('\0' != settings->device_configurations[i].deviceName[0]) {
  ------------------
  |  Branch (667:17): [True: 0, False: 0]
  ------------------
  668|      0|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "deviceName: %s", settings->device_configurations[i].deviceName);
  669|      0|            }
  670|      0|            if ('\0' != settings->device_configurations[i].driverName[0]) {
  ------------------
  |  Branch (670:17): [True: 0, False: 0]
  ------------------
  671|      0|                loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "driverName: %s", settings->device_configurations[i].driverName);
  672|      0|            }
  673|      0|        }
  674|      0|    }
  675|  2.45k|    loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0, "---------------------------------");
  676|  2.45k|}
get_loader_settings:
  681|  6.85k|VkResult get_loader_settings(const struct loader_instance* inst, loader_settings* loader_settings) {
  682|  6.85k|    VkResult res = VK_SUCCESS;
  683|  6.85k|    cJSON* json = NULL;
  684|  6.85k|    char* file_format_version_string = NULL;
  685|  6.85k|    char* settings_file_path = NULL;
  686|       |#if defined(WIN32)
  687|       |    res = windows_get_loader_settings_file_path(inst, &settings_file_path);
  688|       |    if (res != VK_SUCCESS) {
  689|       |        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  690|       |                   "No valid vk_loader_settings.json file found, no loader settings will be active");
  691|       |        goto out;
  692|       |    }
  693|       |
  694|       |#elif COMMON_UNIX_PLATFORMS
  695|       |    res = get_unix_settings_path(inst, &settings_file_path);
  696|  6.85k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (696:9): [True: 678, False: 6.17k]
  ------------------
  697|    678|        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  698|    678|                   "No valid vk_loader_settings.json file found, no loader settings will be active");
  699|    678|        goto out;
  700|    678|    }
  701|       |#else
  702|       |#warning "Unsupported platform - must specify platform specific location for vk_loader_settings.json"
  703|       |#endif
  704|       |
  705|  6.17k|    res = loader_get_json(inst, settings_file_path, &json);
  706|       |    // Make sure sure the top level json value is an object
  707|  6.17k|    if (res != VK_SUCCESS || NULL == json || json->type != cJSON_Object) {
  ------------------
  |  |  103|  3.48k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (707:9): [True: 57, False: 6.12k]
  |  Branch (707:30): [True: 2.63k, False: 3.48k]
  |  Branch (707:46): [True: 204, False: 3.28k]
  ------------------
  708|  2.89k|        goto out;
  709|  2.89k|    }
  710|       |
  711|  3.28k|    res = loader_parse_json_string(json, "file_format_version", &file_format_version_string);
  712|  3.28k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (712:9): [True: 16, False: 3.26k]
  ------------------
  713|     16|        if (res != VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (713:13): [True: 16, False: 0]
  ------------------
  714|     16|            loader_log(
  715|     16|                inst, VULKAN_LOADER_DEBUG_BIT, 0,
  716|     16|                "Loader settings file from %s missing required field file_format_version - no loader settings will be active",
  717|     16|                settings_file_path);
  718|     16|        }
  719|     16|        goto out;
  720|     16|    }
  721|       |
  722|       |    // Because the file may contain either a "settings_array" or a single "settings" object, we need to create a cJSON so that we
  723|       |    // can iterate on both cases with common code
  724|  3.26k|    cJSON settings_iter_parent = {0};
  725|       |
  726|  3.26k|    cJSON* settings_array = loader_cJSON_GetObjectItem(json, "settings_array");
  727|  3.26k|    cJSON* single_settings_object = loader_cJSON_GetObjectItem(json, "settings");
  728|  3.26k|    if (NULL != settings_array) {
  ------------------
  |  Branch (728:9): [True: 2.89k, False: 377]
  ------------------
  729|  2.89k|        memcpy(&settings_iter_parent, settings_array, sizeof(cJSON));
  730|  2.89k|    } else if (NULL != single_settings_object) {
  ------------------
  |  Branch (730:16): [True: 29, False: 348]
  ------------------
  731|     29|        settings_iter_parent.child = single_settings_object;
  732|    348|    } else {
  733|    348|        loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  734|    348|                   "Loader settings file from %s missing required settings objects: Either one of the \"settings\" or "
  735|    348|                   "\"settings_array\" objects must be present - no loader settings will be active",
  736|    348|                   settings_file_path);
  737|    348|        res = VK_ERROR_INITIALIZATION_FAILED;
  738|    348|        goto out;
  739|    348|    }
  740|       |
  741|       |    // Corresponds to the settings object that has no app keys
  742|  2.91k|    cJSON* global_settings = NULL;
  743|       |    // Corresponds to the settings object which has a matching app key
  744|  2.91k|    cJSON* settings_to_use = NULL;
  745|       |
  746|  2.91k|    char current_process_path[1024];
  747|  2.91k|    bool valid_exe_path = NULL != loader_platform_executable_path(current_process_path, 1024);
  748|       |
  749|  2.91k|    cJSON* settings_object_iter = NULL;
  750|  3.89k|    cJSON_ArrayForEach(settings_object_iter, &settings_iter_parent) {
  ------------------
  |  |  213|  6.57k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 2.91k, Folded]
  |  |  |  Branch (213:61): [True: 3.89k, False: 2.68k]
  |  |  ------------------
  ------------------
  751|  3.89k|        if (settings_object_iter->type != cJSON_Object) {
  ------------------
  |  |  103|  3.89k|#define cJSON_Object (1 << 6)
  ------------------
  |  Branch (751:13): [True: 238, False: 3.65k]
  ------------------
  752|    238|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  753|    238|                       "Loader settings file from %s has a settings element that is not an object", settings_file_path);
  754|    238|            break;
  755|    238|        }
  756|       |
  757|  3.65k|        cJSON* app_keys = loader_cJSON_GetObjectItem(settings_object_iter, "app_keys");
  758|  3.65k|        if (NULL == app_keys) {
  ------------------
  |  Branch (758:13): [True: 3.31k, False: 341]
  ------------------
  759|       |            // use the first 'global' settings that has no app keys as the global one
  760|  3.31k|            if (global_settings == NULL) {
  ------------------
  |  Branch (760:17): [True: 2.82k, False: 490]
  ------------------
  761|  2.82k|                global_settings = settings_object_iter;
  762|  2.82k|            }
  763|  3.31k|            continue;
  764|  3.31k|        }
  765|       |        // No sense iterating if we couldn't get the executable path
  766|    341|        if (!valid_exe_path) {
  ------------------
  |  Branch (766:13): [True: 0, False: 341]
  ------------------
  767|      0|            break;
  768|      0|        }
  769|    341|        cJSON* app_key = NULL;
  770|    759|        cJSON_ArrayForEach(app_key, app_keys) {
  ------------------
  |  |  213|  1.10k|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 341, False: 0]
  |  |  |  Branch (213:61): [True: 759, False: 341]
  |  |  ------------------
  ------------------
  771|    759|            char* app_key_str = loader_cJSON_GetStringValue(app_key);
  772|    759|            if (app_key_str && strcmp(current_process_path, app_key_str) == 0) {
  ------------------
  |  Branch (772:17): [True: 328, False: 431]
  |  Branch (772:32): [True: 0, False: 328]
  ------------------
  773|      0|                settings_to_use = settings_object_iter;
  774|      0|                break;
  775|      0|            }
  776|    759|        }
  777|       |
  778|       |        // Break if we have found a matching current_process_path
  779|    341|        if (NULL != settings_to_use) {
  ------------------
  |  Branch (779:13): [True: 0, False: 341]
  ------------------
  780|      0|            break;
  781|      0|        }
  782|    341|    }
  783|       |
  784|       |    // No app specific settings match - either use global settings or exit
  785|  2.91k|    if (settings_to_use == NULL) {
  ------------------
  |  Branch (785:9): [True: 2.91k, False: 0]
  ------------------
  786|  2.91k|        if (global_settings == NULL) {
  ------------------
  |  Branch (786:13): [True: 94, False: 2.82k]
  ------------------
  787|     94|            loader_log(inst, VULKAN_LOADER_DEBUG_BIT, 0,
  788|     94|                       "Loader settings file from %s missing global settings and none of the app specific settings matched the "
  789|     94|                       "current application - no loader settings will be active",
  790|     94|                       settings_file_path);
  791|     94|            goto out;  // No global settings were found - exit
  792|  2.82k|        } else {
  793|  2.82k|            settings_to_use = global_settings;  // Global settings are present - use it
  794|  2.82k|        }
  795|  2.91k|    }
  796|       |
  797|       |    // optional
  798|  2.82k|    cJSON* stderr_filter = loader_cJSON_GetObjectItem(settings_to_use, "stderr_log");
  799|  2.82k|    if (NULL != stderr_filter) {
  ------------------
  |  Branch (799:9): [True: 353, False: 2.47k]
  ------------------
  800|    353|        struct loader_string_list stderr_log = {0};
  801|    353|        VkResult stderr_log_result = VK_SUCCESS;
  802|    353|        stderr_log_result = loader_parse_json_array_of_strings(inst, settings_to_use, "stderr_log", &stderr_log);
  803|    353|        if (VK_ERROR_OUT_OF_HOST_MEMORY == stderr_log_result) {
  ------------------
  |  Branch (803:13): [True: 0, False: 353]
  ------------------
  804|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  805|      0|            goto out;
  806|      0|        }
  807|       |        // NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) - 0xFF is a valid bitwise-OR of all flags (the "all" filter)
  808|    353|        loader_settings->debug_level = parse_log_filters_from_strings(&stderr_log);
  809|    353|        free_string_list(inst, &stderr_log);
  810|    353|    }
  811|       |
  812|       |    // optional
  813|  2.82k|    cJSON* logs_to_use = loader_cJSON_GetObjectItem(settings_to_use, "log_locations");
  814|  2.82k|    if (NULL != logs_to_use) {
  ------------------
  |  Branch (814:9): [True: 69, False: 2.75k]
  ------------------
  815|     69|        cJSON* log_element = NULL;
  816|    598|        cJSON_ArrayForEach(log_element, logs_to_use) {
  ------------------
  |  |  213|    667|    for (element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
  |  |  ------------------
  |  |  |  Branch (213:20): [True: 69, False: 0]
  |  |  |  Branch (213:61): [True: 598, False: 69]
  |  |  ------------------
  ------------------
  817|       |            // bool is_valid = true;
  818|    598|            struct loader_string_list log_destinations = {0};
  819|    598|            VkResult parse_dest_res = loader_parse_json_array_of_strings(inst, log_element, "destinations", &log_destinations);
  820|    598|            if (parse_dest_res != VK_SUCCESS) {
  ------------------
  |  Branch (820:17): [True: 594, False: 4]
  ------------------
  821|       |                // is_valid = false;
  822|    594|            }
  823|    598|            free_string_list(inst, &log_destinations);
  824|    598|            struct loader_string_list log_filters = {0};
  825|    598|            VkResult parse_filters_res = loader_parse_json_array_of_strings(inst, log_element, "filters", &log_filters);
  826|    598|            if (parse_filters_res != VK_SUCCESS) {
  ------------------
  |  Branch (826:17): [True: 461, False: 137]
  ------------------
  827|       |                // is_valid = false;
  828|    461|            }
  829|    598|            free_string_list(inst, &log_filters);
  830|    598|        }
  831|     69|    }
  832|       |
  833|  2.82k|    VkResult layer_configurations_res = parse_layer_configurations(inst, settings_to_use, loader_settings);
  834|  2.82k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == layer_configurations_res) {
  ------------------
  |  Branch (834:9): [True: 0, False: 2.82k]
  ------------------
  835|      0|        res = layer_configurations_res;
  836|      0|        goto out;
  837|      0|    }
  838|       |
  839|       |    // Determine if there exists a layer configuration indicating where to put layers not contained in the settings file
  840|       |    // LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION
  841|  19.1k|    for (uint32_t i = 0; i < loader_settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (841:26): [True: 16.9k, False: 2.20k]
  ------------------
  842|  16.9k|        if (loader_settings->layer_configurations[i].control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (842:13): [True: 625, False: 16.2k]
  ------------------
  843|    625|            loader_settings->has_unordered_layer_location = true;
  844|    625|            break;
  845|    625|        }
  846|  16.9k|    }
  847|       |
  848|  2.82k|    VkResult additional_drivers_res = parse_additional_drivers(inst, settings_to_use, loader_settings);
  849|  2.82k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == additional_drivers_res) {
  ------------------
  |  Branch (849:9): [True: 0, False: 2.82k]
  ------------------
  850|      0|        res = additional_drivers_res;
  851|      0|        goto out;
  852|      0|    }
  853|       |
  854|  2.82k|    VkResult device_configurations_res = parse_device_configurations(inst, settings_to_use, loader_settings);
  855|  2.82k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == device_configurations_res) {
  ------------------
  |  Branch (855:9): [True: 0, False: 2.82k]
  ------------------
  856|      0|        res = device_configurations_res;
  857|      0|        goto out;
  858|      0|    }
  859|       |
  860|       |    // Only consider the settings active if there is at least one "setting" active.
  861|       |    // Those are either logging, layers, additional_drivers, or device_configurations.
  862|  2.82k|    if (loader_settings->debug_level != 0 || loader_settings->layer_configurations_active ||
  ------------------
  |  Branch (862:9): [True: 166, False: 2.65k]
  |  Branch (862:46): [True: 2.28k, False: 371]
  ------------------
  863|  2.45k|        loader_settings->additional_driver_count != 0 || loader_settings->device_configurations_active) {
  ------------------
  |  Branch (863:9): [True: 0, False: 371]
  |  Branch (863:58): [True: 0, False: 371]
  ------------------
  864|  2.45k|        loader_settings->settings_file_path = settings_file_path;
  865|  2.45k|        settings_file_path = NULL;
  866|  2.45k|        loader_settings->settings_active = true;
  867|  2.45k|    } else {
  868|    371|        loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  869|    371|                   "vk_loader_settings.json file found at \"%s\" but did not contain any valid settings.", settings_file_path);
  870|    371|    }
  871|  6.85k|out:
  872|  6.85k|    if (NULL != json) {
  ------------------
  |  Branch (872:9): [True: 3.48k, False: 3.36k]
  ------------------
  873|  3.48k|        loader_cJSON_Delete(json);
  874|  3.48k|    }
  875|       |
  876|  6.85k|    loader_instance_heap_free(inst, settings_file_path);
  877|       |
  878|  6.85k|    loader_instance_heap_free(inst, file_format_version_string);
  879|  6.85k|    return res;
  880|  2.82k|}
init_global_loader_settings:
  901|      2|void init_global_loader_settings(void) {
  902|      2|    loader_platform_thread_create_mutex(&global_loader_settings_lock);
  903|       |    // Free out the global settings in case the process was loaded & unloaded
  904|       |    free_loader_settings(NULL, &global_loader_settings);
  905|      2|}
get_current_settings_and_lock:
  921|  6.87k|const loader_settings* get_current_settings_and_lock(const struct loader_instance* inst) {
  922|  6.87k|    if (inst) {
  ------------------
  |  Branch (922:9): [True: 6.87k, False: 0]
  ------------------
  923|  6.87k|        return &inst->settings;
  924|  6.87k|    }
  925|      0|    loader_platform_thread_lock_mutex(&global_loader_settings_lock);
  926|      0|    return &global_loader_settings;
  927|  6.87k|}
release_current_settings_lock:
  929|  6.87k|void release_current_settings_lock(const struct loader_instance* inst) {
  930|  6.87k|    if (inst == NULL) {
  ------------------
  |  Branch (930:9): [True: 0, False: 6.87k]
  ------------------
  931|      0|        loader_platform_thread_unlock_mutex(&global_loader_settings_lock);
  932|      0|    }
  933|  6.87k|}
get_settings_layers:
  936|  6.85k|                                                  bool* should_search_for_other_layers) {
  937|  6.85k|    VkResult res = VK_SUCCESS;
  938|  6.85k|    *should_search_for_other_layers = true;  // default to true
  939|       |
  940|  6.85k|    const loader_settings* settings = get_current_settings_and_lock(inst);
  941|       |
  942|  6.85k|    if (NULL == settings || !settings->settings_active || !settings->layer_configurations_active) {
  ------------------
  |  Branch (942:9): [True: 0, False: 6.85k]
  |  Branch (942:29): [True: 4.40k, False: 2.45k]
  |  Branch (942:59): [True: 78, False: 2.37k]
  ------------------
  943|  4.47k|        goto out;
  944|  4.47k|    }
  945|       |
  946|       |    // Assume the list doesn't contain LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION at first
  947|  2.37k|    *should_search_for_other_layers = false;
  948|       |
  949|  28.7k|    for (uint32_t i = 0; i < settings->layer_configuration_count; i++) {
  ------------------
  |  Branch (949:26): [True: 26.3k, False: 2.37k]
  ------------------
  950|  26.3k|        loader_settings_layer_configuration* layer_config = &settings->layer_configurations[i];
  951|       |
  952|       |        // If we encountered a layer that should be forced off, we add it to the settings_layers list but only
  953|       |        // with the data required to compare it with layers not in the settings file (aka name and manifest path)
  954|  26.3k|        if (layer_config->control == LOADER_SETTINGS_LAYER_CONTROL_OFF) {
  ------------------
  |  Branch (954:13): [True: 2.52k, False: 23.8k]
  ------------------
  955|  2.52k|            struct loader_layer_properties props = {0};
  956|  2.52k|            props.settings_control_value = LOADER_SETTINGS_LAYER_CONTROL_OFF;
  957|  2.52k|            loader_strncpy(props.info.layerName, VK_MAX_EXTENSION_NAME_SIZE, layer_config->name, VK_MAX_EXTENSION_NAME_SIZE);
  958|  2.52k|            props.info.layerName[VK_MAX_EXTENSION_NAME_SIZE - 1] = '\0';
  959|  2.52k|            res = loader_copy_to_new_str(inst, layer_config->path, &props.manifest_file_name);
  960|  2.52k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (960:17): [True: 0, False: 2.52k]
  ------------------
  961|      0|                goto out;
  962|      0|            }
  963|  2.52k|            res = loader_append_layer_property(inst, settings_layers, &props);
  964|  2.52k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (964:17): [True: 0, False: 2.52k]
  ------------------
  965|      0|                loader_free_layer_properties(inst, &props);
  966|      0|                goto out;
  967|      0|            }
  968|  2.52k|            continue;
  969|  2.52k|        }
  970|       |
  971|       |        // The special layer location that indicates where unordered layers should go only should have the
  972|       |        // settings_control_value set - everything else should be NULL
  973|  23.8k|        if (layer_config->control == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (973:13): [True: 1.20k, False: 22.6k]
  ------------------
  974|  1.20k|            struct loader_layer_properties props = {0};
  975|  1.20k|            props.settings_control_value = LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION;
  976|  1.20k|            res = loader_append_layer_property(inst, settings_layers, &props);
  977|  1.20k|            if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (977:17): [True: 0, False: 1.20k]
  ------------------
  978|      0|                loader_free_layer_properties(inst, &props);
  979|      0|                goto out;
  980|      0|            }
  981|  1.20k|            *should_search_for_other_layers = true;
  982|  1.20k|            continue;
  983|  1.20k|        }
  984|       |
  985|  22.6k|        if (layer_config->path == NULL) {
  ------------------
  |  Branch (985:13): [True: 0, False: 22.6k]
  ------------------
  986|      0|            continue;
  987|      0|        }
  988|       |
  989|  22.6k|        if (!is_json(layer_config->path, strlen(layer_config->path))) {
  ------------------
  |  Branch (989:13): [True: 12.4k, False: 10.2k]
  ------------------
  990|  12.4k|            continue;
  991|  12.4k|        }
  992|       |
  993|  10.2k|        cJSON* json = NULL;
  994|  10.2k|        VkResult local_res = loader_get_json(inst, layer_config->path, &json);
  995|  10.2k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (995:13): [True: 0, False: 10.2k]
  ------------------
  996|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
  997|      0|            goto out;
  998|  10.2k|        } else if (VK_SUCCESS != local_res || NULL == json) {
  ------------------
  |  Branch (998:20): [True: 413, False: 9.79k]
  |  Branch (998:47): [True: 3.62k, False: 6.17k]
  ------------------
  999|  4.03k|            continue;
 1000|  4.03k|        }
 1001|       |
 1002|       |        // Makes it possible to know if a new layer was added or not, since the only return value is VkResult
 1003|  6.17k|        uint32_t count_before_adding = settings_layers->count;
 1004|       |
 1005|  6.17k|        local_res =
 1006|  6.17k|            loader_add_layer_properties(inst, settings_layers, json, layer_config->treat_as_implicit_manifest, layer_config->path);
 1007|  6.17k|        loader_cJSON_Delete(json);
 1008|       |
 1009|       |        // If the error is anything other than out of memory we still want to try to load the other layers
 1010|  6.17k|        if (VK_ERROR_OUT_OF_HOST_MEMORY == local_res) {
  ------------------
  |  Branch (1010:13): [True: 0, False: 6.17k]
  ------------------
 1011|      0|            res = VK_ERROR_OUT_OF_HOST_MEMORY;
 1012|      0|            goto out;
 1013|  6.17k|        } else if (local_res != VK_SUCCESS || count_before_adding == settings_layers->count) {
  ------------------
  |  Branch (1013:20): [True: 3.66k, False: 2.50k]
  |  Branch (1013:47): [True: 0, False: 2.50k]
  ------------------
 1014|       |            // Indicates something was wrong with the layer, can't add it to the list
 1015|  3.66k|            continue;
 1016|  3.66k|        }
 1017|       |
 1018|  35.8k|        for (uint32_t j = count_before_adding; j < settings_layers->count; j++) {
  ------------------
  |  Branch (1018:48): [True: 33.3k, False: 2.50k]
  ------------------
 1019|  33.3k|            struct loader_layer_properties* newly_added_layer = &settings_layers->list[j];
 1020|  33.3k|            newly_added_layer->settings_control_value = layer_config->control;
 1021|       |            // If the manifest file found has a name that differs from the one in the settings, remove this layer from
 1022|       |            // consideration
 1023|  33.3k|            if (strncmp(newly_added_layer->info.layerName, layer_config->name, VK_MAX_EXTENSION_NAME_SIZE) != 0) {
  ------------------
  |  Branch (1023:17): [True: 9.49k, False: 23.8k]
  ------------------
 1024|  9.49k|                loader_remove_layer_in_list(inst, settings_layers, j);
 1025|  9.49k|                j--;
 1026|  9.49k|                continue;
 1027|  9.49k|            }
 1028|  33.3k|            bool should_remove = false;
 1029|       |            // Make sure the layer isn't already in the list
 1030|  35.7M|            for (uint32_t k = 0; k < j; k++) {
  ------------------
  |  Branch (1030:34): [True: 35.7M, False: 21.5k]
  ------------------
 1031|  35.7M|                if (0 == strncmp(settings_layers->list[k].info.layerName, newly_added_layer->info.layerName,
  ------------------
  |  Branch (1031:21): [True: 35.6M, False: 53.8k]
  ------------------
 1032|  35.7M|                                 VK_MAX_EXTENSION_NAME_SIZE)) {
 1033|  35.6M|                    if (0 == (newly_added_layer->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) &&
  ------------------
  |  Branch (1033:25): [True: 77.0k, False: 35.5M]
  ------------------
 1034|  77.0k|                        settings_layers->list[k].lib_name != NULL && newly_added_layer->lib_name != NULL &&
  ------------------
  |  Branch (1034:25): [True: 35.7k, False: 41.2k]
  |  Branch (1034:70): [True: 35.7k, False: 0]
  ------------------
 1035|  35.7k|                        strcmp(settings_layers->list[k].lib_name, newly_added_layer->lib_name) == 0) {
  ------------------
  |  Branch (1035:25): [True: 2.30k, False: 33.4k]
  ------------------
 1036|  2.30k|                        should_remove = true;
 1037|  2.30k|                        break;
 1038|  2.30k|                    }
 1039|  35.6M|                }
 1040|  35.7M|            }
 1041|  23.8k|            if (should_remove) {
  ------------------
  |  Branch (1041:17): [True: 2.30k, False: 21.5k]
  ------------------
 1042|  2.30k|                loader_remove_layer_in_list(inst, settings_layers, j);
 1043|  2.30k|                j--;
 1044|  2.30k|            }
 1045|  23.8k|        }
 1046|  2.50k|    }
 1047|       |
 1048|  6.85k|out:
 1049|  6.85k|    release_current_settings_lock(inst);
 1050|  6.85k|    return res;
 1051|  2.37k|}
check_if_layer_is_in_list:
 1062|  34.7k|                               bool consider_lib_path) {
 1063|       |    // If the layer is a meta layer, just check against the name
 1064|  2.37M|    for (uint32_t i = 0; i < layer_list->count; i++) {
  ------------------
  |  Branch (1064:26): [True: 2.37M, False: 4.35k]
  ------------------
 1065|  2.37M|        if (0 == strncmp(layer_list->list[i].info.layerName, layer_property->info.layerName, VK_MAX_EXTENSION_NAME_SIZE)) {
  ------------------
  |  Branch (1065:13): [True: 56.1k, False: 2.31M]
  ------------------
 1066|  56.1k|            if (layer_list->list[i].settings_control_value == LOADER_SETTINGS_LAYER_CONTROL_OFF) {
  ------------------
  |  Branch (1066:17): [True: 721, False: 55.4k]
  ------------------
 1067|    721|                return true;
 1068|    721|            }
 1069|  55.4k|            if (VK_LAYER_TYPE_FLAG_META_LAYER == (layer_property->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) {
  ------------------
  |  Branch (1069:17): [True: 9.04k, False: 46.4k]
  ------------------
 1070|  9.04k|                return true;
 1071|  9.04k|            }
 1072|  46.4k|            if (!consider_lib_path) {
  ------------------
  |  Branch (1072:17): [True: 461, False: 45.9k]
  ------------------
 1073|    461|                return true;
 1074|    461|            }
 1075|  45.9k|            if (layer_list->list[i].lib_name && layer_property->lib_name) {
  ------------------
  |  Branch (1075:17): [True: 43.9k, False: 1.97k]
  |  Branch (1075:49): [True: 20.1k, False: 23.8k]
  ------------------
 1076|  20.1k|                return strcmp(layer_list->list[i].lib_name, layer_property->lib_name) == 0;
 1077|  20.1k|            }
 1078|  45.9k|        }
 1079|  2.37M|    }
 1080|  4.35k|    return false;
 1081|  34.7k|}
combine_settings_layers_with_regular_layers:
 1085|  5.10k|                                                     struct loader_layer_list* output_layers) {
 1086|  5.10k|    VkResult res = VK_SUCCESS;
 1087|  5.10k|    bool has_unordered_layer_location = false;
 1088|  5.10k|    uint32_t unordered_layer_location_index = 0;
 1089|       |    // Location to put layers that aren't known to the settings file
 1090|       |    // Find it here so we dont have to pass in a loader_settings struct
 1091|  61.7k|    for (uint32_t i = 0; i < settings_layers->count; i++) {
  ------------------
  |  Branch (1091:26): [True: 57.2k, False: 4.47k]
  ------------------
 1092|  57.2k|        if (settings_layers->list[i].settings_control_value == LOADER_SETTINGS_LAYER_UNORDERED_LAYER_LOCATION) {
  ------------------
  |  Branch (1092:13): [True: 625, False: 56.6k]
  ------------------
 1093|    625|            has_unordered_layer_location = true;
 1094|    625|            unordered_layer_location_index = i;
 1095|    625|            break;
 1096|    625|        }
 1097|  57.2k|    }
 1098|       |
 1099|  5.10k|    if (settings_layers->count == 0 && regular_layers->count == 0) {
  ------------------
  |  Branch (1099:9): [True: 4.47k, False: 625]
  |  Branch (1099:40): [True: 3.55k, False: 924]
  ------------------
 1100|       |        // No layers to combine
 1101|  3.55k|        goto out;
 1102|  3.55k|    } else if (settings_layers->count == 0) {
  ------------------
  |  Branch (1102:16): [True: 924, False: 625]
  ------------------
 1103|       |        // No settings layers - just copy regular to output_layers - memset regular layers to prevent double frees
 1104|    924|        *output_layers = *regular_layers;
 1105|    924|        memset(regular_layers, 0, sizeof(struct loader_layer_list));
 1106|    924|        goto out;
 1107|    924|    } else if (regular_layers->count == 0 || !has_unordered_layer_location) {
  ------------------
  |  Branch (1107:16): [True: 194, False: 431]
  |  Branch (1107:46): [True: 0, False: 431]
  ------------------
 1108|       |        // No regular layers or has_unordered_layer_location is false - just copy settings to output_layers -
 1109|       |        // memset settings layers to prevent double frees
 1110|    194|        *output_layers = *settings_layers;
 1111|    194|        memset(settings_layers, 0, sizeof(struct loader_layer_list));
 1112|    194|        goto out;
 1113|    194|    }
 1114|       |
 1115|    431|    res = loader_init_generic_list(inst, (struct loader_generic_list*)output_layers,
 1116|    431|                                   (settings_layers->count + regular_layers->count) * sizeof(struct loader_layer_properties));
 1117|    431|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1117:9): [True: 0, False: 431]
  ------------------
 1118|      0|        goto out;
 1119|      0|    }
 1120|       |
 1121|       |    // Insert the settings layers into output_layers up to unordered_layer_index
 1122|  18.7k|    for (uint32_t i = 0; i < unordered_layer_location_index; i++) {
  ------------------
  |  Branch (1122:26): [True: 18.2k, False: 431]
  ------------------
 1123|  18.2k|        if (!check_if_layer_is_in_list(output_layers, &settings_layers->list[i], true)) {
  ------------------
  |  Branch (1123:13): [True: 12.3k, False: 5.89k]
  ------------------
 1124|  12.3k|            res = loader_append_layer_property(inst, output_layers, &settings_layers->list[i]);
 1125|  12.3k|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1125:17): [True: 0, False: 12.3k]
  ------------------
 1126|      0|                goto out;
 1127|      0|            }
 1128|  12.3k|        }
 1129|  18.2k|    }
 1130|       |
 1131|  6.57k|    for (uint32_t i = 0; i < regular_layers->count; i++) {
  ------------------
  |  Branch (1131:26): [True: 6.14k, False: 431]
  ------------------
 1132|       |        // Check if its already been put in the output_layers list as well as the remaining settings_layers
 1133|  6.14k|        bool regular_layer_is_ordered = check_if_layer_is_in_list(output_layers, &regular_layers->list[i], false) ||
  ------------------
  |  Branch (1133:41): [True: 4.38k, False: 1.75k]
  ------------------
 1134|  1.75k|                                        check_if_layer_is_in_list(settings_layers, &regular_layers->list[i], false);
  ------------------
  |  Branch (1134:41): [True: 990, False: 768]
  ------------------
 1135|       |        // If it isn't found, add it
 1136|  6.14k|        if (!regular_layer_is_ordered) {
  ------------------
  |  Branch (1136:13): [True: 768, False: 5.37k]
  ------------------
 1137|    768|            res = loader_append_layer_property(inst, output_layers, &regular_layers->list[i]);
 1138|    768|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1138:17): [True: 0, False: 768]
  ------------------
 1139|      0|                goto out;
 1140|      0|            }
 1141|  5.37k|        } else {
 1142|       |            // layer is already ordered and can be safely freed
 1143|  5.37k|            loader_free_layer_properties(inst, &regular_layers->list[i]);
 1144|  5.37k|        }
 1145|  6.14k|    }
 1146|       |
 1147|       |    // Insert the rest of the settings layers into combined_layers from  unordered_layer_index to the end
 1148|       |    // start at one after the unordered_layer_index
 1149|  9.01k|    for (uint32_t i = unordered_layer_location_index + 1; i < settings_layers->count; i++) {
  ------------------
  |  Branch (1149:59): [True: 8.58k, False: 431]
  ------------------
 1150|  8.58k|        if (!check_if_layer_is_in_list(output_layers, &settings_layers->list[i], true)) {
  ------------------
  |  Branch (1150:13): [True: 5.59k, False: 2.99k]
  ------------------
 1151|  5.59k|            res = loader_append_layer_property(inst, output_layers, &settings_layers->list[i]);
 1152|  5.59k|            if (VK_SUCCESS != res) {
  ------------------
  |  Branch (1152:17): [True: 0, False: 5.59k]
  ------------------
 1153|      0|                goto out;
 1154|      0|            }
 1155|  5.59k|        }
 1156|  8.58k|    }
 1157|       |
 1158|  5.10k|out:
 1159|  5.10k|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (1159:9): [True: 0, False: 5.10k]
  ------------------
 1160|      0|        loader_delete_layer_list_and_properties(inst, output_layers);
 1161|      0|    }
 1162|       |
 1163|  5.10k|    return res;
 1164|    431|}
loader_settings_get_additional_driver_files:
 1284|      5|VkResult loader_settings_get_additional_driver_files(const struct loader_instance* inst, struct loader_string_list* out_files) {
 1285|      5|    VkResult res = VK_SUCCESS;
 1286|       |
 1287|      5|    const loader_settings* settings = get_current_settings_and_lock(inst);
 1288|       |
 1289|      5|    if (NULL == settings || !settings->settings_active) {
  ------------------
  |  Branch (1289:9): [True: 0, False: 5]
  |  Branch (1289:29): [True: 1, False: 4]
  ------------------
 1290|      1|        goto out;
 1291|      1|    }
 1292|       |
 1293|      4|    if (settings->additional_drivers_use_exclusively) {
  ------------------
  |  Branch (1293:9): [True: 0, False: 4]
  ------------------
 1294|      0|        free_string_list(inst, out_files);
 1295|      0|    }
 1296|       |
 1297|      4|    for (uint32_t i = 0; i < settings->additional_driver_count; i++) {
  ------------------
  |  Branch (1297:26): [True: 0, False: 4]
  ------------------
 1298|      0|        res = prepend_if_manifest_file(inst, settings->additional_drivers[i].path, out_files);
 1299|      0|    }
 1300|       |
 1301|      5|out:
 1302|      5|    release_current_settings_lock(inst);
 1303|      5|    return res;
 1304|      4|}
loader_settings_should_use_driver_environment_variables:
 1306|     10|bool loader_settings_should_use_driver_environment_variables(const struct loader_instance* inst) {
 1307|     10|    bool should_use = true;
 1308|     10|    const loader_settings* settings = get_current_settings_and_lock(inst);
 1309|     10|    if (NULL == settings || !settings->settings_active) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 10]
  |  Branch (1309:29): [True: 2, False: 8]
  ------------------
 1310|      2|        goto out;
 1311|      2|    }
 1312|      8|    if (settings->device_configurations_active) {
  ------------------
  |  Branch (1312:9): [True: 0, False: 8]
  ------------------
 1313|      0|        should_use = false;
 1314|      0|    }
 1315|     10|out:
 1316|     10|    release_current_settings_lock(inst);
 1317|     10|    return should_use;
 1318|      8|}

vkCreateInstance:
  522|  6.85k|                                                              const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) {
  523|  6.85k|    struct loader_instance *ptr_instance = NULL;
  524|  6.85k|    VkInstance created_instance = VK_NULL_HANDLE;
  525|  6.85k|    VkResult res = VK_ERROR_INITIALIZATION_FAILED;
  526|  6.85k|    VkInstanceCreateInfo ici = {0};
  527|  6.85k|    bool portability_enumeration_flag_bit_set = false;
  528|  6.85k|    bool portability_enumeration_extension_enabled = false;
  529|  6.85k|    struct loader_envvar_all_filters layer_filters = {0};
  530|       |
  531|  6.85k|    LOADER_PLATFORM_THREAD_ONCE(&once_init, loader_initialize);
  532|       |
  533|  6.85k|    if (pCreateInfo == NULL) {
  ------------------
  |  Branch (533:9): [True: 0, False: 6.85k]
  ------------------
  534|      0|        loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
  535|      0|                   "vkCreateInstance: \'pCreateInfo\' is NULL (VUID-vkCreateInstance-pCreateInfo-parameter)");
  536|      0|        goto out;
  537|      0|    }
  538|  6.85k|    ici = *pCreateInfo;
  539|       |
  540|  6.85k|    if (pInstance == NULL) {
  ------------------
  |  Branch (540:9): [True: 0, False: 6.85k]
  ------------------
  541|      0|        loader_log(NULL, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_VALIDATION_BIT, 0,
  542|      0|                   "vkCreateInstance \'pInstance\' not valid (VUID-vkCreateInstance-pInstance-parameter)");
  543|      0|        goto out;
  544|      0|    }
  545|       |
  546|  6.85k|    ptr_instance =
  547|  6.85k|        (struct loader_instance *)loader_calloc(pAllocator, sizeof(struct loader_instance), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  548|       |
  549|  6.85k|    if (ptr_instance == NULL) {
  ------------------
  |  Branch (549:9): [True: 0, False: 6.85k]
  ------------------
  550|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  551|      0|        goto out;
  552|      0|    }
  553|       |
  554|  6.85k|    loader_platform_thread_lock_mutex(&loader_lock);
  555|  6.85k|    if (pAllocator) {
  ------------------
  |  Branch (555:9): [True: 0, False: 6.85k]
  ------------------
  556|      0|        ptr_instance->alloc_callbacks = *pAllocator;
  557|      0|    }
  558|  6.85k|    ptr_instance->magic = LOADER_MAGIC_NUMBER;
  ------------------
  |  |  327|  6.85k|#define LOADER_MAGIC_NUMBER 0x10ADED010110ADEDUL
  ------------------
  559|       |
  560|       |    // Save the application version
  561|  6.85k|    if (NULL == pCreateInfo->pApplicationInfo || 0 == pCreateInfo->pApplicationInfo->apiVersion) {
  ------------------
  |  Branch (561:9): [True: 0, False: 6.85k]
  |  Branch (561:50): [True: 0, False: 6.85k]
  ------------------
  562|      0|        ptr_instance->app_api_version = LOADER_VERSION_1_0_0;
  ------------------
  |  |  267|      0|#define LOADER_VERSION_1_0_0 loader_combine_version(1, 0, 0)
  ------------------
  563|  6.85k|    } else {
  564|  6.85k|        ptr_instance->app_api_version = loader_make_version(pCreateInfo->pApplicationInfo->apiVersion);
  565|  6.85k|    }
  566|       |
  567|       |    // Look for one or more VK_EXT_debug_report or VK_EXT_debug_utils create info structures
  568|       |    // and setup a callback(s) for each one found.
  569|       |
  570|       |    // Handle cases of VK_EXT_debug_utils
  571|       |    // Setup the temporary messenger(s) here to catch early issues:
  572|  6.85k|    res = util_CreateDebugUtilsMessengers(ptr_instance, pCreateInfo->pNext, pAllocator);
  573|  6.85k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (573:9): [True: 0, False: 6.85k]
  ------------------
  574|       |        // Failure of setting up one or more of the messenger.
  575|      0|        goto out;
  576|      0|    }
  577|       |
  578|       |    // Handle cases of VK_EXT_debug_report
  579|       |    // Setup the temporary callback(s) here to catch early issues:
  580|  6.85k|    res = util_CreateDebugReportCallbacks(ptr_instance, pCreateInfo->pNext, pAllocator);
  581|  6.85k|    if (VK_ERROR_OUT_OF_HOST_MEMORY == res) {
  ------------------
  |  Branch (581:9): [True: 0, False: 6.85k]
  ------------------
  582|       |        // Failure of setting up one or more of the callback.
  583|      0|        goto out;
  584|      0|    }
  585|       |
  586|  6.85k|    loader_log_instance_create_info(ptr_instance, pCreateInfo);
  587|       |
  588|  6.85k|    VkResult settings_file_res = get_loader_settings(ptr_instance, &ptr_instance->settings);
  589|  6.85k|    if (settings_file_res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (589:9): [True: 0, False: 6.85k]
  ------------------
  590|      0|        res = settings_file_res;
  591|      0|        goto out;
  592|      0|    }
  593|  6.85k|    if (ptr_instance->settings.settings_active) {
  ------------------
  |  Branch (593:9): [True: 2.45k, False: 4.40k]
  ------------------
  594|  2.45k|        log_settings(ptr_instance, &ptr_instance->settings);
  595|  2.45k|    }
  596|       |
  597|       |    // Providing an apiVersion less than VK_API_VERSION_1_0 but greater than zero prevents the validation layers from starting
  598|  6.85k|    if (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion != 0u &&
  ------------------
  |  Branch (598:9): [True: 6.85k, False: 0]
  |  Branch (598:42): [True: 6.85k, False: 0]
  ------------------
  599|  6.85k|        pCreateInfo->pApplicationInfo->apiVersion < VK_API_VERSION_1_0) {
  ------------------
  |  Branch (599:9): [True: 0, False: 6.85k]
  ------------------
  600|      0|        loader_log(ptr_instance, VULKAN_LOADER_FATAL_ERROR_BIT | VULKAN_LOADER_ERROR_BIT, 0,
  601|      0|                   "VkInstanceCreateInfo::pApplicationInfo::apiVersion has value of %u which is not permitted. If apiVersion is "
  602|      0|                   "not 0, then it must be "
  603|      0|                   "greater than or equal to the value of VK_API_VERSION_1_0 [VUID-VkApplicationInfo-apiVersion]",
  604|      0|                   pCreateInfo->pApplicationInfo->apiVersion);
  605|      0|    }
  606|       |
  607|       |    // Check the VkInstanceCreateInfoFlags wether to allow the portability enumeration flag
  608|  6.85k|    if ((pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR) == 1) {
  ------------------
  |  Branch (608:9): [True: 0, False: 6.85k]
  ------------------
  609|      0|        portability_enumeration_flag_bit_set = true;
  610|      0|    }
  611|       |    // Make sure the portability extension extension has been enabled before enabling portability driver enumeration
  612|  6.85k|    if (pCreateInfo->ppEnabledExtensionNames) {
  ------------------
  |  Branch (612:9): [True: 0, False: 6.85k]
  ------------------
  613|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
  ------------------
  |  Branch (613:30): [True: 0, False: 0]
  ------------------
  614|      0|            if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0) {
  ------------------
  |  Branch (614:17): [True: 0, False: 0]
  ------------------
  615|      0|                portability_enumeration_extension_enabled = true;
  616|      0|                if (portability_enumeration_flag_bit_set) {
  ------------------
  |  Branch (616:21): [True: 0, False: 0]
  ------------------
  617|      0|                    ptr_instance->portability_enumeration_enabled = true;
  618|      0|                    loader_log(ptr_instance, VULKAN_LOADER_INFO_BIT, 0,
  619|      0|                               "Portability enumeration bit was set, enumerating portability drivers.");
  620|      0|                }
  621|      0|                break;
  622|      0|            }
  623|      0|        }
  624|      0|    }
  625|       |
  626|       |    // Make sure the application provided API version has the correct variant
  627|  6.85k|    if (NULL != pCreateInfo->pApplicationInfo) {
  ------------------
  |  Branch (627:9): [True: 6.85k, False: 0]
  ------------------
  628|  6.85k|        uint32_t variant_version = VK_API_VERSION_VARIANT(pCreateInfo->pApplicationInfo->apiVersion);
  629|  6.85k|        const uint32_t expected_variant = 0;
  630|  6.85k|        if (expected_variant != variant_version) {
  ------------------
  |  Branch (630:13): [True: 0, False: 6.85k]
  ------------------
  631|      0|            loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
  632|      0|                       "vkCreateInstance: The API Variant specified in pCreateInfo->pApplicationInfo.apiVersion is %d instead of "
  633|      0|                       "the expected value of %d.",
  634|      0|                       variant_version, expected_variant);
  635|      0|        }
  636|  6.85k|    }
  637|       |
  638|  6.85k|    res = parse_layer_environment_var_filters(ptr_instance, &layer_filters);
  639|  6.85k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (639:9): [True: 0, False: 6.85k]
  ------------------
  640|      0|        goto out;
  641|      0|    }
  642|       |
  643|       |    // Due to implicit layers need to get layer list even if
  644|       |    // enabledLayerCount == 0 and VK_INSTANCE_LAYERS is unset. For now always
  645|       |    // get layer list via loader_scan_for_layers().
  646|  6.85k|    memset(&ptr_instance->instance_layer_list, 0, sizeof(ptr_instance->instance_layer_list));
  647|  6.85k|    res = loader_scan_for_layers(ptr_instance, &ptr_instance->instance_layer_list, &layer_filters);
  648|  6.85k|    if (VK_SUCCESS != res) {
  ------------------
  |  Branch (648:9): [True: 0, False: 6.85k]
  ------------------
  649|      0|        goto out;
  650|      0|    }
  651|       |
  652|       |    // Validate the app requested layers to be enabled
  653|  6.85k|    if (pCreateInfo->enabledLayerCount > 0) {
  ------------------
  |  Branch (653:9): [True: 6.85k, False: 0]
  ------------------
  654|  6.85k|        res = loader_validate_layers(ptr_instance, pCreateInfo->enabledLayerCount, pCreateInfo->ppEnabledLayerNames,
  655|  6.85k|                                     &ptr_instance->instance_layer_list);
  656|  6.85k|        if (res != VK_SUCCESS) {
  ------------------
  |  Branch (656:13): [True: 6.85k, False: 5]
  ------------------
  657|  6.85k|            goto out;
  658|  6.85k|        }
  659|  6.85k|    }
  660|       |
  661|       |    // Scan/discover all System and Environment Variable ICD libraries
  662|  6.85k|    bool skipped_portability_drivers = false;
  663|      5|    res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list, pCreateInfo, &skipped_portability_drivers);
  664|      5|    if (res == VK_ERROR_OUT_OF_HOST_MEMORY) {
  ------------------
  |  Branch (664:9): [True: 0, False: 5]
  ------------------
  665|      0|        goto out;
  666|      0|    }
  667|       |
  668|      5|    if (ptr_instance->icd_tramp_list.count == 0) {
  ------------------
  |  Branch (668:9): [True: 5, False: 0]
  ------------------
  669|       |        // No drivers found
  670|      5|        if (skipped_portability_drivers) {
  ------------------
  |  Branch (670:13): [True: 0, False: 5]
  ------------------
  671|      0|            if (portability_enumeration_extension_enabled && !portability_enumeration_flag_bit_set) {
  ------------------
  |  Branch (671:17): [True: 0, False: 0]
  |  Branch (671:62): [True: 0, False: 0]
  ------------------
  672|      0|                loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
  673|      0|                           "vkCreateInstance: Found drivers that contain devices which support the portability subset, but "
  674|      0|                           "the instance does not enumerate portability drivers! Applications that wish to enumerate portability "
  675|      0|                           "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo "
  676|      0|                           "flags.");
  677|      0|            } else if (portability_enumeration_flag_bit_set && !portability_enumeration_extension_enabled) {
  ------------------
  |  Branch (677:24): [True: 0, False: 0]
  |  Branch (677:64): [True: 0, False: 0]
  ------------------
  678|      0|                loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
  679|      0|                           "VkInstanceCreateInfo: If flags has the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit set, the "
  680|      0|                           "list of enabled extensions in ppEnabledExtensionNames must contain VK_KHR_portability_enumeration "
  681|      0|                           "[VUID-VkInstanceCreateInfo-flags-06559 ]"
  682|      0|                           "Applications that wish to enumerate portability drivers must enable the VK_KHR_portability_enumeration "
  683|      0|                           "instance extension.");
  684|      0|            } else {
  685|      0|                loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0,
  686|      0|                           "vkCreateInstance: Found drivers that contain devices which support the portability subset, but "
  687|      0|                           "the instance does not enumerate portability drivers! Applications that wish to enumerate portability "
  688|      0|                           "drivers must set the VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR bit in the VkInstanceCreateInfo "
  689|      0|                           "flags and enable the VK_KHR_portability_enumeration instance extension.");
  690|      0|            }
  691|      0|        }
  692|      5|        loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT | VULKAN_LOADER_DRIVER_BIT, 0, "vkCreateInstance: Found no drivers!");
  693|      5|        res = VK_ERROR_INCOMPATIBLE_DRIVER;
  694|      5|        goto out;
  695|      5|    }
  696|       |
  697|       |    // Get extensions from all ICD's, merge so no duplicates, then validate
  698|      0|    res = loader_get_icd_loader_instance_extensions(ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list);
  699|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (699:9): [True: 0, False: 0]
  ------------------
  700|      0|        goto out;
  701|      0|    }
  702|      0|    res = loader_validate_instance_extensions(ptr_instance, &ptr_instance->ext_list, &ptr_instance->instance_layer_list,
  703|      0|                                              &layer_filters, &ici);
  704|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (704:9): [True: 0, False: 0]
  ------------------
  705|      0|        goto out;
  706|      0|    }
  707|       |
  708|      0|    ptr_instance->disp = loader_instance_heap_alloc(ptr_instance, sizeof(struct loader_instance_dispatch_table),
  709|      0|                                                    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
  710|      0|    if (ptr_instance->disp == NULL) {
  ------------------
  |  Branch (710:9): [True: 0, False: 0]
  ------------------
  711|      0|        loader_log(ptr_instance, VULKAN_LOADER_ERROR_BIT, 0,
  712|      0|                   "vkCreateInstance:  Failed to allocate Loader's full Instance dispatch table.");
  713|      0|        res = VK_ERROR_OUT_OF_HOST_MEMORY;
  714|      0|        goto out;
  715|      0|    }
  716|      0|    memcpy(&ptr_instance->disp->layer_inst_disp, &instance_disp, sizeof(instance_disp));
  717|       |
  718|      0|    ptr_instance->next = loader.instances;
  719|      0|    loader.instances = ptr_instance;
  720|       |
  721|       |    // Activate any layers on instance chain
  722|      0|    res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list, &layer_filters);
  723|      0|    if (res != VK_SUCCESS) {
  ------------------
  |  Branch (723:9): [True: 0, False: 0]
  ------------------
  724|      0|        goto out;
  725|      0|    }
  726|       |
  727|      0|    created_instance = (VkInstance)ptr_instance;
  728|      0|    res = loader_create_instance_chain(&ici, pAllocator, ptr_instance, &created_instance);
  729|       |
  730|      0|    if (VK_SUCCESS == res) {
  ------------------
  |  Branch (730:9): [True: 0, False: 0]
  ------------------
  731|       |        // Check for enabled extensions here to setup the loader structures so the loader knows what extensions
  732|       |        // it needs to worry about.
  733|       |        // We do it in the terminator and again above the layers here since we may think different extensions
  734|       |        // are enabled than what's down in the terminator.
  735|       |        // This is why we don't clear inside of these function calls.
  736|       |        // The clearing should actually be handled by the overall memset of the pInstance structure above.
  737|      0|        fill_out_enabled_instance_extensions(ici.enabledExtensionCount, ici.ppEnabledExtensionNames,
  738|      0|                                             &ptr_instance->enabled_extensions);
  739|       |
  740|      0|        *pInstance = (VkInstance)ptr_instance;
  741|       |
  742|       |        // Finally have the layers in place and everyone has seen
  743|       |        // the CreateInstance command go by. This allows the layer's
  744|       |        // GetInstanceProcAddr functions to return valid extension functions
  745|       |        // if enabled.
  746|      0|        loader_activate_instance_layer_extensions(ptr_instance, created_instance);
  747|      0|        ptr_instance->instance_finished_creation = true;
  748|      0|    } else if (VK_ERROR_EXTENSION_NOT_PRESENT == res && !ptr_instance->create_terminator_invalid_extension) {
  ------------------
  |  Branch (748:16): [True: 0, False: 0]
  |  Branch (748:57): [True: 0, False: 0]
  ------------------
  749|      0|        loader_log(ptr_instance, VULKAN_LOADER_WARN_BIT, 0,
  750|      0|                   "vkCreateInstance: Layer returning invalid extension error not triggered by ICD/Loader (Policy #LLP_LAYER_17).");
  751|      0|    }
  752|       |
  753|  6.85k|out:
  754|       |
  755|  6.85k|    if (NULL != ptr_instance) {
  ------------------
  |  Branch (755:9): [True: 6.85k, False: 0]
  ------------------
  756|  6.85k|        if (res != VK_SUCCESS) {
  ------------------
  |  Branch (756:13): [True: 6.85k, False: 0]
  ------------------
  757|       |            // error path, should clean everything up
  758|  6.85k|            if (loader.instances == ptr_instance) {
  ------------------
  |  Branch (758:17): [True: 0, False: 6.85k]
  ------------------
  759|      0|                loader.instances = ptr_instance->next;
  760|      0|            }
  761|       |
  762|  6.85k|            free_loader_settings(ptr_instance, &ptr_instance->settings);
  763|       |
  764|  6.85k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->surfaces_list);
  765|  6.85k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->debug_utils_messengers_list);
  766|  6.85k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->debug_report_callbacks_list);
  767|       |
  768|  6.85k|            loader_instance_heap_free(ptr_instance, ptr_instance->disp);
  769|       |            // Remove any created VK_EXT_debug_report or VK_EXT_debug_utils items
  770|  6.85k|            destroy_debug_callbacks_chain(ptr_instance, pAllocator);
  771|       |
  772|  6.85k|            loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->expanded_activated_layer_list);
  773|  6.85k|            loader_destroy_pointer_layer_list(ptr_instance, &ptr_instance->app_activated_layer_list);
  774|       |
  775|  6.85k|            loader_delete_layer_list_and_properties(ptr_instance, &ptr_instance->instance_layer_list);
  776|  6.85k|            loader_destroy_generic_list(ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list);
  777|       |
  778|       |            // Free any icd_terms that were created.
  779|       |            // If an OOM occurs from a layer, terminator_CreateInstance won't be reached where this kind of
  780|       |            // cleanup normally occurs
  781|  6.85k|            struct loader_icd_term *icd_term = NULL;
  782|  6.85k|            while (NULL != ptr_instance->icd_terms) {
  ------------------
  |  Branch (782:20): [True: 0, False: 6.85k]
  ------------------
  783|      0|                icd_term = ptr_instance->icd_terms;
  784|       |                // Call destroy Instance on each driver in case we successfully called down the chain but failed on
  785|       |                // our way back out of it.
  786|      0|                if (icd_term->instance) {
  ------------------
  |  Branch (786:21): [True: 0, False: 0]
  ------------------
  787|      0|                    loader_icd_close_objects(ptr_instance, icd_term);
  788|      0|                    icd_term->dispatch.DestroyInstance(icd_term->instance, pAllocator);
  789|      0|                }
  790|      0|                icd_term->instance = VK_NULL_HANDLE;
  791|      0|                ptr_instance->icd_terms = icd_term->next;
  792|      0|                loader_icd_destroy(ptr_instance, icd_term, pAllocator);
  793|      0|            }
  794|       |
  795|  6.85k|            loader_clear_scanned_icd_list(ptr_instance, &ptr_instance->icd_tramp_list);
  796|  6.85k|            free_string_list(ptr_instance, &ptr_instance->enabled_layer_names);
  797|       |
  798|  6.85k|            loader_instance_heap_free(ptr_instance, ptr_instance);
  799|  6.85k|        } else {
  800|       |            // success path, swap out created debug callbacks out so they aren't used until instance destruction
  801|      0|            loader_remove_instance_only_debug_funcs(ptr_instance);
  802|      0|        }
  803|       |        // Only unlock when ptr_instance isn't NULL, as if it is, the above code didn't make it to when loader_lock was locked.
  804|  6.85k|        loader_platform_thread_unlock_mutex(&loader_lock);
  805|  6.85k|    }
  806|       |
  807|  6.85k|    return res;
  808|      0|}
trampoline.c:loader_log_instance_create_info:
  480|  6.85k|static void loader_log_instance_create_info(const struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo) {
  481|  6.85k|    const VkApplicationInfo *app_info = pCreateInfo->pApplicationInfo;
  482|  6.85k|    const char *app_name = (app_info && app_info->pApplicationName) ? app_info->pApplicationName : "";
  ------------------
  |  Branch (482:29): [True: 6.85k, False: 0]
  |  Branch (482:41): [True: 6.85k, False: 0]
  ------------------
  483|  6.85k|    const char *engine_name = (app_info && app_info->pEngineName) ? app_info->pEngineName : "";
  ------------------
  |  Branch (483:32): [True: 6.85k, False: 0]
  |  Branch (483:44): [True: 6.85k, False: 0]
  ------------------
  484|  6.85k|    uint32_t app_version = app_info ? app_info->applicationVersion : 0;
  ------------------
  |  Branch (484:28): [True: 6.85k, False: 0]
  ------------------
  485|  6.85k|    uint32_t engine_version = app_info ? app_info->engineVersion : 0;
  ------------------
  |  Branch (485:31): [True: 6.85k, False: 0]
  ------------------
  486|  6.85k|    uint32_t api_version = app_info ? app_info->apiVersion : 0;
  ------------------
  |  Branch (486:28): [True: 6.85k, False: 0]
  ------------------
  487|       |
  488|  6.85k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  489|  6.85k|               "vkCreateInstance: applicationName: \"%s\", applicationVersion: %u, engineName: \"%s\", engineVersion: %u, "
  490|  6.85k|               "apiVersion: %u.%u.%u",
  491|  6.85k|               app_name, app_version, engine_name, engine_version, VK_API_VERSION_MAJOR(api_version),
  492|  6.85k|               VK_API_VERSION_MINOR(api_version), VK_API_VERSION_PATCH(api_version));
  493|       |
  494|       |    // Guard the name arrays: this runs before the loader validates pCreateInfo, so the count may be non-zero with a null
  495|       |    // array (see the null-pointer tests).
  496|  6.85k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  497|  6.85k|               "vkCreateInstance: Requested %u instance layer(s):", pCreateInfo->enabledLayerCount);
  498|  6.85k|    if (pCreateInfo->ppEnabledLayerNames) {
  ------------------
  |  Branch (498:9): [True: 6.85k, False: 0]
  ------------------
  499|  13.7k|        for (uint32_t i = 0; i < pCreateInfo->enabledLayerCount; ++i) {
  ------------------
  |  Branch (499:30): [True: 6.85k, False: 6.85k]
  ------------------
  500|  6.85k|            if (pCreateInfo->ppEnabledLayerNames[i]) {
  ------------------
  |  Branch (500:17): [True: 6.85k, False: 0]
  ------------------
  501|  6.85k|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   %s", pCreateInfo->ppEnabledLayerNames[i]);
  502|  6.85k|            } else {
  503|      0|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   <NULL>");
  504|      0|            }
  505|  6.85k|        }
  506|  6.85k|    }
  507|       |
  508|  6.85k|    loader_log(inst, VULKAN_LOADER_INFO_BIT, 0,
  509|  6.85k|               "vkCreateInstance: Requested %u instance extension(s):", pCreateInfo->enabledExtensionCount);
  510|  6.85k|    if (pCreateInfo->ppEnabledExtensionNames) {
  ------------------
  |  Branch (510:9): [True: 0, False: 6.85k]
  ------------------
  511|      0|        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i) {
  ------------------
  |  Branch (511:30): [True: 0, False: 0]
  ------------------
  512|      0|            if (pCreateInfo->ppEnabledExtensionNames[i]) {
  ------------------
  |  Branch (512:17): [True: 0, False: 0]
  ------------------
  513|      0|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   %s", pCreateInfo->ppEnabledExtensionNames[i]);
  514|      0|            } else {
  515|      0|                loader_log(inst, VULKAN_LOADER_INFO_BIT, 0, "   <NULL>");
  516|      0|            }
  517|      0|        }
  518|      0|    }
  519|  6.85k|}

trampoline.c:loader_platform_thread_lock_mutex:
  456|  6.85k|static inline void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_lock(pMutex); }
trampoline.c:loader_platform_thread_unlock_mutex:
  457|  6.85k|static inline void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_unlock(pMutex); }
loader.c:loader_strncpy:
  467|   406k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  468|   406k|    (void)dest_sz;
  469|   406k|    return strncpy(dest, src, count);
  470|   406k|}
loader.c:thread_safe_strtok:
  460|   397k|static inline void *thread_safe_strtok(char *str, const char *delim, char **saveptr) { return strtok_r(str, delim, saveptr); }
loader.c:loader_platform_thread_create_mutex:
  450|      4|static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) {
  451|      4|    pthread_mutexattr_t attr;
  452|      4|    pthread_mutexattr_init(&attr);
  453|      4|    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  454|      4|    pthread_mutex_init(pMutex, &attr);
  455|      4|}
loader.c:loader_platform_is_path_absolute:
  296|  57.9k|static inline bool loader_platform_is_path_absolute(const char *path) {
  297|  57.9k|    if (path[0] == '/') return true;
  ------------------
  |  Branch (297:9): [True: 493, False: 57.4k]
  ------------------
  298|  57.4k|    return false;
  299|  57.9k|}
loader.c:loader_platform_is_path:
  252|  20.5k|static inline bool loader_platform_is_path(const char *path) { return strchr(path, DIRECTORY_SYMBOL) != NULL; }
  ------------------
  |  |  155|  20.5k|#define DIRECTORY_SYMBOL '/'
  ------------------
loader.c:loader_platform_file_exists:
  289|  20.5k|static inline bool loader_platform_file_exists(const char *path) {
  290|  20.5k|    if (access(path, F_OK)) return false;
  ------------------
  |  Branch (290:9): [True: 575, False: 19.9k]
  ------------------
  291|  19.9k|    return true;
  292|  20.5k|}
loader.c:loader_platform_executable_path:
  307|  5.10k|static inline char *loader_platform_executable_path(char *buffer, size_t size) {
  308|  5.10k|    ssize_t count = readlink("/proc/self/exe", buffer, size);
  309|  5.10k|    if (count == -1) return NULL;
  ------------------
  |  Branch (309:9): [True: 0, False: 5.10k]
  ------------------
  310|  5.10k|    if (count == 0) return NULL;
  ------------------
  |  Branch (310:9): [True: 0, False: 5.10k]
  ------------------
  311|       |    // readlink does not append a null terminator and returns up to size bytes, so a target of size or more
  312|       |    // would leave no room for the terminator and buffer[count] would write past the end.
  313|  5.10k|    if ((size_t)count >= size) return NULL;
  ------------------
  |  Branch (313:9): [True: 0, False: 5.10k]
  ------------------
  314|  5.10k|    buffer[count] = '\0';
  315|  5.10k|    return buffer;
  316|  5.10k|}
loader_environment.c:thread_safe_strtok:
  460|  13.7k|static inline void *thread_safe_strtok(char *str, const char *delim, char **saveptr) { return strtok_r(str, delim, saveptr); }
loader_environment.c:loader_strncpy:
  467|  6.85k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  468|  6.85k|    (void)dest_sz;
  469|  6.85k|    return strncpy(dest, src, count);
  470|  6.85k|}
log.c:loader_strncat:
  463|  78.1k|static inline char *loader_strncat(char *dest, size_t dest_sz, const char *src, size_t count) {
  464|  78.1k|    (void)dest_sz;
  465|  78.1k|    return strncat(dest, src, count);
  466|  78.1k|}
settings.c:loader_strncpy:
  467|  19.6k|static inline char *loader_strncpy(char *dest, size_t dest_sz, const char *src, size_t count) {
  468|  19.6k|    (void)dest_sz;
  469|  19.6k|    return strncpy(dest, src, count);
  470|  19.6k|}
settings.c:loader_strncat:
  463|  17.1k|static inline char *loader_strncat(char *dest, size_t dest_sz, const char *src, size_t count) {
  464|  17.1k|    (void)dest_sz;
  465|  17.1k|    return strncat(dest, src, count);
  466|  17.1k|}
settings.c:loader_platform_file_exists:
  289|  17.1k|static inline bool loader_platform_file_exists(const char *path) {
  290|  17.1k|    if (access(path, F_OK)) return false;
  ------------------
  |  Branch (290:9): [True: 10.9k, False: 6.17k]
  ------------------
  291|  6.17k|    return true;
  292|  17.1k|}
settings.c:loader_platform_executable_path:
  307|  2.91k|static inline char *loader_platform_executable_path(char *buffer, size_t size) {
  308|  2.91k|    ssize_t count = readlink("/proc/self/exe", buffer, size);
  309|  2.91k|    if (count == -1) return NULL;
  ------------------
  |  Branch (309:9): [True: 0, False: 2.91k]
  ------------------
  310|  2.91k|    if (count == 0) return NULL;
  ------------------
  |  Branch (310:9): [True: 0, False: 2.91k]
  ------------------
  311|       |    // readlink does not append a null terminator and returns up to size bytes, so a target of size or more
  312|       |    // would leave no room for the terminator and buffer[count] would write past the end.
  313|  2.91k|    if ((size_t)count >= size) return NULL;
  ------------------
  |  Branch (313:9): [True: 0, False: 2.91k]
  ------------------
  314|  2.91k|    buffer[count] = '\0';
  315|  2.91k|    return buffer;
  316|  2.91k|}
settings.c:loader_platform_thread_create_mutex:
  450|      2|static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) {
  451|      2|    pthread_mutexattr_t attr;
  452|      2|    pthread_mutexattr_init(&attr);
  453|      2|    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  454|      2|    pthread_mutex_init(pMutex, &attr);
  455|      2|}

wsi_unsupported_instance_extension:
  280|  19.3k|bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
  281|       |#if !defined(VK_USE_PLATFORM_WAYLAND_KHR)
  282|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) return true;
  283|       |#endif  // VK_USE_PLATFORM_WAYLAND_KHR
  284|       |#if !defined(VK_USE_PLATFORM_XCB_KHR)
  285|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) return true;
  286|       |#endif  // VK_USE_PLATFORM_XCB_KHR
  287|       |#if !defined(VK_USE_PLATFORM_XLIB_KHR)
  288|       |    if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) return true;
  289|       |#endif  // VK_USE_PLATFORM_XLIB_KHR
  290|  19.3k|#if !defined(VK_USE_PLATFORM_DIRECTFB_EXT)
  291|  19.3k|    if (!strcmp(ext_prop->extensionName, "VK_EXT_directfb_surface")) return true;
  ------------------
  |  Branch (291:9): [True: 88, False: 19.2k]
  ------------------
  292|  19.2k|#endif  // VK_USE_PLATFORM_DIRECTFB_EXT
  293|  19.2k|#if !defined(VK_USE_PLATFORM_SCREEN_QNX)
  294|  19.2k|    if (!strcmp(ext_prop->extensionName, "VK_QNX_screen_surface")) return true;
  ------------------
  |  Branch (294:9): [True: 266, False: 19.0k]
  ------------------
  295|  19.0k|#endif  // VK_USE_PLATFORM_SCREEN_QNX
  296|       |
  297|  19.0k|    return false;
  298|  19.2k|}

