ck_str_hash_lookup:
  146|  7.47k|const void *ck_str_hash_lookup(const char *key, ck_hash_table_t *table) {
  147|  7.47k|    size_t keylen = strlen(key);
  148|  7.47k|    return ck_str_n_hash_lookup(key, keylen, table);
  149|  7.47k|}
ck_str_n_hash_lookup:
  152|  7.47k|{
  153|  7.47k|	if (table->count == 0)
  ------------------
  |  Branch (153:6): [True: 1.16k, False: 6.31k]
  ------------------
  154|  1.16k|		return NULL;
  155|       |    	
  156|  6.31k|	if (keylen == 0)
  ------------------
  |  Branch (156:6): [True: 675, False: 5.63k]
  ------------------
  157|    675|		return NULL;
  158|       |	
  159|  5.63k|    uint64_t hash_key = ck_hash_str(key, keylen);
  160|  5.63k|	hash_key %= table->capacity;
  161|  5.63k|    uint64_t end = hash_key;
  162|  6.05k|    do {
  163|  6.05k|        char *this_key = &table->keys[table->entries[hash_key].key_offset];
  164|  6.05k|        size_t this_keylen = table->entries[hash_key].key_length;
  165|  6.05k|        if (this_keylen == 0)
  ------------------
  |  Branch (165:13): [True: 2.32k, False: 3.73k]
  ------------------
  166|  2.32k|            return NULL;
  167|  3.73k|        if (this_keylen == keylen && memcmp(this_key, key, keylen) == 0) {
  ------------------
  |  Branch (167:13): [True: 3.52k, False: 205]
  |  Branch (167:38): [True: 3.31k, False: 215]
  ------------------
  168|  3.31k|			return table->entries[hash_key].value;
  169|  3.31k|		}
  170|    420|		hash_key++;
  171|    420|		hash_key %= table->capacity;
  172|    420|    } while (hash_key != end);
  ------------------
  |  Branch (172:14): [True: 420, False: 0]
  ------------------
  173|      0|	return NULL;
  174|  5.63k|}
ck_str_hash_insert:
  177|  8.17k|{
  178|  8.17k|    size_t keylen = strlen(key);
  179|  8.17k|    return ck_str_n_hash_insert(key, keylen, value, table);
  180|  8.17k|}
ck_str_n_hash_insert:
  210|  8.17k|{    
  211|  8.17k|	if (table->capacity == 0)
  ------------------
  |  Branch (211:6): [True: 0, False: 8.17k]
  ------------------
  212|      0|		return 0;
  213|       |    	
  214|  8.17k|	if (keylen == 0)
  ------------------
  |  Branch (214:6): [True: 3.20k, False: 4.96k]
  ------------------
  215|  3.20k|		return 0;
  216|       |    
  217|  4.96k|    if (table->count >= 0.75 * table->capacity) {
  ------------------
  |  Branch (217:9): [True: 0, False: 4.96k]
  ------------------
  218|      0|        if (ck_hash_table_grow(table) == -1) {
  ------------------
  |  Branch (218:13): [True: 0, False: 0]
  ------------------
  219|      0|            return 0;
  220|      0|        }
  221|      0|    }
  222|       |	
  223|  4.96k|    uint64_t hash_key = ck_hash_str(key, keylen);
  224|  4.96k|	hash_key %= table->capacity;
  225|  4.96k|    uint64_t end = hash_key;
  226|  5.91k|    do {
  227|  5.91k|        ck_hash_entry_t *entry = &table->entries[hash_key];
  228|  5.91k|        char *this_key = &table->keys[entry->key_offset];
  229|  5.91k|        if (entry->key_length == 0) {
  ------------------
  |  Branch (229:13): [True: 1.08k, False: 4.82k]
  ------------------
  230|  1.08k|            table->count++;
  231|  1.08k|            while (table->keys_used + keylen > table->keys_capacity) {
  ------------------
  |  Branch (231:20): [True: 0, False: 1.08k]
  ------------------
  232|      0|                table->keys_capacity *= 2;
  233|      0|                table->keys = realloc(table->keys, table->keys_capacity);
  234|      0|            }
  235|  1.08k|            memcpy(table->keys + table->keys_used, key, keylen);
  236|  1.08k|            entry->key_offset = table->keys_used;
  237|  1.08k|            entry->key_length = keylen;
  238|  1.08k|            table->keys_used += keylen;
  239|  1.08k|            entry->value = value;
  240|  1.08k|            return 1;
  241|  4.82k|        } else if (entry->key_length == keylen &&
  ------------------
  |  Branch (241:20): [True: 4.49k, False: 331]
  ------------------
  242|  4.49k|                   memcmp(this_key, key, keylen) == 0) {
  ------------------
  |  Branch (242:20): [True: 3.87k, False: 620]
  ------------------
  243|  3.87k|			table->entries[hash_key].value = value;
  244|  3.87k|			return 1;
  245|  3.87k|		}
  246|    951|		hash_key++;
  247|    951|		hash_key %= table->capacity;
  248|    951|    } while (hash_key != end);
  ------------------
  |  Branch (248:14): [True: 951, False: 0]
  ------------------
  249|      0|	return 0;
  250|  4.96k|}
ck_hash_table_init:
  253|  2.80k|{
  254|  2.80k|	ck_hash_table_t *table;
  255|  2.80k|	if ((table = malloc(sizeof(ck_hash_table_t))) == NULL)
  ------------------
  |  Branch (255:6): [True: 0, False: 2.80k]
  ------------------
  256|      0|		return NULL;
  257|       |    
  258|  2.80k|    if ((table->keys = malloc(num_entries * mean_key_length)) == NULL) {
  ------------------
  |  Branch (258:9): [True: 0, False: 2.80k]
  ------------------
  259|      0|        free(table);
  260|      0|        return NULL;
  261|      0|    }
  262|  2.80k|    table->keys_capacity = num_entries * mean_key_length;
  263|       |    
  264|  2.80k|    num_entries *= 2;
  265|       |    
  266|  2.80k|    if ((table->entries = malloc(num_entries * sizeof(ck_hash_entry_t))) == NULL) {
  ------------------
  |  Branch (266:9): [True: 0, False: 2.80k]
  ------------------
  267|      0|        free(table->keys);
  268|      0|        free(table);
  269|      0|        return NULL;
  270|      0|    }
  271|  2.80k|	table->capacity = num_entries;
  272|  2.80k|    ck_hash_table_wipe(table);
  273|  2.80k|	return table;
  274|  2.80k|}
ck_hash_table_free:
  276|  2.80k|void ck_hash_table_free(ck_hash_table_t *table) {
  277|  2.80k|    free(table->entries);
  278|  2.80k|    if (table->keys)
  ------------------
  |  Branch (278:9): [True: 2.80k, False: 0]
  ------------------
  279|  2.80k|        free(table->keys);
  280|  2.80k|    free(table);
  281|  2.80k|}
ck_hash_table_wipe:
  283|  2.80k|void ck_hash_table_wipe(ck_hash_table_t *table) {
  284|  2.80k|    table->keys_used = 0;
  285|  2.80k|    table->count = 0;
  286|  2.80k|    memset(table->entries, 0, table->capacity * sizeof(ck_hash_entry_t));
  287|  2.80k|}
CKHashTable.c:ck_hash_str:
  121|  10.5k|{
  122|  10.5k|    uint64_t hash;
  123|  10.5k|    unsigned char k[16] = { 0 };
  124|  10.5k|    siphash((unsigned char *)&hash, (const unsigned char *)str, keylen, k);
  125|  10.5k|    return hash;
  126|  10.5k|}
CKHashTable.c:siphash:
   57|  10.5k|{
   58|       |    /* "somepseudorandomlygeneratedbytes" */
   59|  10.5k|    u64 v0 = 0x736f6d6570736575ULL;
   60|  10.5k|    u64 v1 = 0x646f72616e646f6dULL;
   61|  10.5k|    u64 v2 = 0x6c7967656e657261ULL;
   62|  10.5k|    u64 v3 = 0x7465646279746573ULL;
   63|  10.5k|    u64 b;
   64|  10.5k|    u64 k0 = U8TO64_LE( k );
  ------------------
  |  |   37|  10.5k|#define U8TO64_LE(p) \
  |  |   38|  10.5k|(((u64)((p)[0])      ) | \
  |  |   39|  10.5k|((u64)((p)[1]) <<  8) | \
  |  |   40|  10.5k|((u64)((p)[2]) << 16) | \
  |  |   41|  10.5k|((u64)((p)[3]) << 24) | \
  |  |   42|  10.5k|((u64)((p)[4]) << 32) | \
  |  |   43|  10.5k|((u64)((p)[5]) << 40) | \
  |  |   44|  10.5k|((u64)((p)[6]) << 48) | \
  |  |   45|  10.5k|((u64)((p)[7]) << 56))
  ------------------
   65|  10.5k|    u64 k1 = U8TO64_LE( k + 8 );
  ------------------
  |  |   37|  10.5k|#define U8TO64_LE(p) \
  |  |   38|  10.5k|(((u64)((p)[0])      ) | \
  |  |   39|  10.5k|((u64)((p)[1]) <<  8) | \
  |  |   40|  10.5k|((u64)((p)[2]) << 16) | \
  |  |   41|  10.5k|((u64)((p)[3]) << 24) | \
  |  |   42|  10.5k|((u64)((p)[4]) << 32) | \
  |  |   43|  10.5k|((u64)((p)[5]) << 40) | \
  |  |   44|  10.5k|((u64)((p)[6]) << 48) | \
  |  |   45|  10.5k|((u64)((p)[7]) << 56))
  ------------------
   66|  10.5k|    u64 m;
   67|  10.5k|    const u8 *end = in + inlen - ( inlen % sizeof( u64 ) );
   68|  10.5k|    const int left = inlen & 7;
   69|  10.5k|    b = ( ( u64 )inlen ) << 56;
   70|  10.5k|    v3 ^= k1;
   71|  10.5k|    v2 ^= k0;
   72|  10.5k|    v1 ^= k1;
   73|  10.5k|    v0 ^= k0;
   74|       |    
   75|  43.0k|    for ( ; in != end; in += 8 )
  ------------------
  |  Branch (75:13): [True: 32.4k, False: 10.5k]
  ------------------
   76|  32.4k|    {
   77|  32.4k|        m = U8TO64_LE( in );
  ------------------
  |  |   37|  32.4k|#define U8TO64_LE(p) \
  |  |   38|  32.4k|(((u64)((p)[0])      ) | \
  |  |   39|  32.4k|((u64)((p)[1]) <<  8) | \
  |  |   40|  32.4k|((u64)((p)[2]) << 16) | \
  |  |   41|  32.4k|((u64)((p)[3]) << 24) | \
  |  |   42|  32.4k|((u64)((p)[4]) << 32) | \
  |  |   43|  32.4k|((u64)((p)[5]) << 40) | \
  |  |   44|  32.4k|((u64)((p)[6]) << 48) | \
  |  |   45|  32.4k|((u64)((p)[7]) << 56))
  ------------------
   78|       |        
   79|  32.4k|        v3 ^= m;
   80|       |        
   81|  32.4k|        SIPROUND;
  ------------------
  |  |   47|  32.4k|#define SIPROUND            \
  |  |   48|  32.4k|do {              \
  |  |   49|  32.4k|v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  32.4k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  32.4k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   50|  32.4k|v2 += v3; v3=ROTL(v3,16); v3 ^= v2;     \
  |  |  ------------------
  |  |  |  |   27|  32.4k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   51|  32.4k|v0 += v3; v3=ROTL(v3,21); v3 ^= v0;     \
  |  |  ------------------
  |  |  |  |   27|  32.4k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   52|  32.4k|v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  32.4k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  32.4k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   53|  32.4k|} while(0)
  |  |  ------------------
  |  |  |  Branch (53:9): [Folded, False: 32.4k]
  |  |  ------------------
  ------------------
   82|       |        
   83|  32.4k|        v0 ^= m;
   84|  32.4k|    }
   85|       |    
   86|  10.5k|    switch( left )
  ------------------
  |  Branch (86:13): [True: 10.5k, False: 0]
  ------------------
   87|  10.5k|    {
   88|    445|        case 7: b |= ( ( u64 )in[ 6] )  << 48;
  ------------------
  |  Branch (88:9): [True: 445, False: 10.1k]
  ------------------
   89|       |            
   90|  1.55k|        case 6: b |= ( ( u64 )in[ 5] )  << 40;
  ------------------
  |  Branch (90:9): [True: 1.10k, False: 9.49k]
  ------------------
   91|       |            
   92|  1.99k|        case 5: b |= ( ( u64 )in[ 4] )  << 32;
  ------------------
  |  Branch (92:9): [True: 444, False: 10.1k]
  ------------------
   93|       |            
   94|  4.42k|        case 4: b |= ( ( u64 )in[ 3] )  << 24;
  ------------------
  |  Branch (94:9): [True: 2.42k, False: 8.17k]
  ------------------
   95|       |            
   96|  4.83k|        case 3: b |= ( ( u64 )in[ 2] )  << 16;
  ------------------
  |  Branch (96:9): [True: 417, False: 10.1k]
  ------------------
   97|       |            
   98|  6.12k|        case 2: b |= ( ( u64 )in[ 1] )  <<  8;
  ------------------
  |  Branch (98:9): [True: 1.29k, False: 9.30k]
  ------------------
   99|       |            
  100|  6.78k|        case 1: b |= ( ( u64 )in[ 0] ); break;
  ------------------
  |  Branch (100:9): [True: 656, False: 9.94k]
  ------------------
  101|       |            
  102|  3.81k|        case 0: break;
  ------------------
  |  Branch (102:9): [True: 3.81k, False: 6.78k]
  ------------------
  103|  10.5k|    }
  104|       |
  105|  10.5k|    v3 ^= b;
  106|       |    
  107|  10.5k|    SIPROUND;
  ------------------
  |  |   47|  10.5k|#define SIPROUND            \
  |  |   48|  10.5k|do {              \
  |  |   49|  10.5k|v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   50|  10.5k|v2 += v3; v3=ROTL(v3,16); v3 ^= v2;     \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   51|  10.5k|v0 += v3; v3=ROTL(v3,21); v3 ^= v0;     \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   52|  10.5k|v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   53|  10.5k|} while(0)
  |  |  ------------------
  |  |  |  Branch (53:9): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
  108|       |    
  109|  10.5k|    v0 ^= b;
  110|  10.5k|    v2 ^= 0xff;
  111|       |    
  112|  10.5k|    SIPROUND;
  ------------------
  |  |   47|  10.5k|#define SIPROUND            \
  |  |   48|  10.5k|do {              \
  |  |   49|  10.5k|v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   50|  10.5k|v2 += v3; v3=ROTL(v3,16); v3 ^= v2;     \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   51|  10.5k|v0 += v3; v3=ROTL(v3,21); v3 ^= v0;     \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   52|  10.5k|v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   53|  10.5k|} while(0)
  |  |  ------------------
  |  |  |  Branch (53:9): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
  113|  10.5k|    SIPROUND;
  ------------------
  |  |   47|  10.5k|#define SIPROUND            \
  |  |   48|  10.5k|do {              \
  |  |   49|  10.5k|v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   50|  10.5k|v2 += v3; v3=ROTL(v3,16); v3 ^= v2;     \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   51|  10.5k|v0 += v3; v3=ROTL(v3,21); v3 ^= v0;     \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   52|  10.5k|v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |               v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \
  |  |  ------------------
  |  |  |  |   27|  10.5k|#define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
  |  |  ------------------
  |  |   53|  10.5k|} while(0)
  |  |  ------------------
  |  |  |  Branch (53:9): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
  114|       |    
  115|  10.5k|    b = v0 ^ v1 ^ v2  ^ v3;
  116|  10.5k|    U64TO8_LE( out, b );
  ------------------
  |  |   33|  10.5k|#define U64TO8_LE(p, v)         \
  |  |  ------------------
  |  |  |  |   29|  10.5k|#define U32TO8_LE(p, v)         \
  |  |  |  |   30|  10.5k|(p)[0] = (u8)((v)      ); (p)[1] = (u8)((v) >>  8); \
  |  |  |  |   31|  10.5k|(p)[2] = (u8)((v) >> 16); (p)[3] = (u8)((v) >> 24);
  |  |  ------------------
  |  |   34|  10.5k|U32TO8_LE((p),     (u32)((v)      ));   \
  |  |  ------------------
  |  |  |  |   29|  10.5k|#define U32TO8_LE(p, v)         \
  |  |  |  |   30|  10.5k|(p)[0] = (u8)((v)      ); (p)[1] = (u8)((v) >>  8); \
  |  |  |  |   31|  10.5k|(p)[2] = (u8)((v) >> 16); (p)[3] = (u8)((v) >> 24);
  |  |  ------------------
  |  |   35|  10.5k|U32TO8_LE((p) + 4, (u32)((v) >> 32));
  ------------------
  117|  10.5k|    return 0;
  118|  10.5k|}

fuzzer_parser_init:
   33|  2.80k|readstat_parser_t *fuzzer_parser_init(const uint8_t *Data, size_t Size) {
   34|  2.80k|    readstat_parser_t *parser = readstat_parser_init();
   35|  2.80k|    readstat_set_open_handler(parser, rt_open_handler);
   36|  2.80k|    readstat_set_close_handler(parser, rt_close_handler);
   37|  2.80k|    readstat_set_seek_handler(parser, rt_seek_handler);
   38|  2.80k|    readstat_set_read_handler(parser, rt_read_handler);
   39|  2.80k|    readstat_set_update_handler(parser, rt_update_handler);
   40|       |
   41|  2.80k|    readstat_set_metadata_handler(parser, &handle_metadata);
   42|  2.80k|    readstat_set_note_handler(parser, &handle_note);
   43|  2.80k|    readstat_set_variable_handler(parser, &handle_variable);
   44|  2.80k|    readstat_set_fweight_handler(parser, &handle_fweight);
   45|  2.80k|    readstat_set_value_handler(parser, &handle_value);
   46|  2.80k|    readstat_set_value_label_handler(parser, &handle_value_label);
   47|       |
   48|  2.80k|    return parser;
   49|  2.80k|}
fuzz_format.c:handle_metadata:
    8|  1.14k|static int handle_metadata(readstat_metadata_t *metadata, void *ctx) {
    9|  1.14k|    return READSTAT_HANDLER_OK;
  ------------------
  |  |   22|  1.14k|#define READSTAT_HANDLER_OK             0
  ------------------
   10|  1.14k|}
fuzz_format.c:handle_note:
   12|  1.13k|static int handle_note(int index, const char *note, void *ctx) {
   13|  1.13k|    return READSTAT_HANDLER_OK;
  ------------------
  |  |   22|  1.13k|#define READSTAT_HANDLER_OK             0
  ------------------
   14|  1.13k|}
fuzz_format.c:handle_variable:
   21|  1.70k|                           const char *val_labels, void *ctx) {
   22|  1.70k|    return READSTAT_HANDLER_OK;
  ------------------
  |  |   22|  1.70k|#define READSTAT_HANDLER_OK             0
  ------------------
   23|  1.70k|}
fuzz_format.c:handle_fweight:
   16|      3|static int handle_fweight(readstat_variable_t *variable, void *ctx) {
   17|      3|    return READSTAT_HANDLER_OK;
  ------------------
  |  |   22|      3|#define READSTAT_HANDLER_OK             0
  ------------------
   18|      3|}
fuzz_format.c:handle_value:
   25|   285k|static int handle_value(int obs_index, readstat_variable_t *variable, readstat_value_t value, void *ctx) {
   26|   285k|    return READSTAT_HANDLER_OK;
  ------------------
  |  |   22|   285k|#define READSTAT_HANDLER_OK             0
  ------------------
   27|   285k|}
fuzz_format.c:handle_value_label:
   29|  43.8k|static int handle_value_label(const char *val_labels, readstat_value_t value, const char *label, void *ctx) {
   30|  43.8k|    return READSTAT_HANDLER_OK;
  ------------------
  |  |   22|  43.8k|#define READSTAT_HANDLER_OK             0
  ------------------
   31|  43.8k|}

LLVMFuzzerTestOneInput:
   10|  2.80k|int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   11|  2.80k|    rt_buffer_t buffer = { .bytes = (char *)Data, .size = Size, .used = Size };
   12|  2.80k|    rt_buffer_ctx_t buffer_ctx = { .buffer = &buffer };
   13|       |
   14|  2.80k|    readstat_parser_t *parser = fuzzer_parser_init(Data, Size);
   15|  2.80k|    readstat_set_io_ctx(parser, &buffer_ctx);
   16|       |
   17|  2.80k|    readstat_parse_por(parser, NULL, NULL);
   18|  2.80k|    readstat_parser_free(parser);
   19|  2.80k|    return 0;
   20|  2.80k|}

readstat_convert:
   39|  53.5k|readstat_error_t readstat_convert(char *dst, size_t dst_len, const char *src, size_t src_len, iconv_t converter) {
   40|  53.5k|    return readstat_convert_impl(dst, dst_len, src, src_len, converter, 1);
   41|  53.5k|}
readstat_convert.c:readstat_convert_impl:
    8|  53.5k|        iconv_t converter, int trim_spaces) {
    9|       |    /* strip off spaces from the input because the programs use ASCII space
   10|       |     * padding even with non-ASCII encoding. */
   11|   125k|    while (src_len && ((trim_spaces && src[src_len-1] == ' ') || src[src_len-1] == '\0')) {
  ------------------
  |  Branch (11:12): [True: 116k, False: 8.58k]
  |  Branch (11:25): [True: 116k, False: 0]
  |  Branch (11:40): [True: 60.8k, False: 55.8k]
  |  Branch (11:66): [True: 10.8k, False: 44.9k]
  ------------------
   12|  71.7k|        src_len--;
   13|  71.7k|    }
   14|  53.5k|    if (dst_len == 0) {
  ------------------
  |  Branch (14:9): [True: 0, False: 53.5k]
  ------------------
   15|      0|        return READSTAT_ERROR_CONVERT_LONG_STRING;
   16|  53.5k|    } else if (converter) {
  ------------------
  |  Branch (16:16): [True: 0, False: 53.5k]
  ------------------
   17|      0|        size_t dst_left = dst_len - 1;
   18|      0|        char *dst_end = dst;
   19|      0|        size_t status = iconv(converter, (readstat_iconv_inbuf_t)&src, &src_len, &dst_end, &dst_left);
   20|      0|        if (status == (size_t)-1) {
  ------------------
  |  Branch (20:13): [True: 0, False: 0]
  ------------------
   21|      0|            if (errno == E2BIG) {
  ------------------
  |  Branch (21:17): [True: 0, False: 0]
  ------------------
   22|      0|                return READSTAT_ERROR_CONVERT_LONG_STRING;
   23|      0|            } else if (errno == EILSEQ) {
  ------------------
  |  Branch (23:24): [True: 0, False: 0]
  ------------------
   24|      0|                return READSTAT_ERROR_CONVERT_BAD_STRING;
   25|      0|            } else if (errno != EINVAL) { /* EINVAL indicates improper truncation; accept it */
  ------------------
  |  Branch (25:24): [True: 0, False: 0]
  ------------------
   26|      0|                return READSTAT_ERROR_CONVERT;
   27|      0|            }
   28|      0|        }
   29|      0|        dst[dst_len - dst_left - 1] = '\0';
   30|  53.5k|    } else if (src_len + 1 > dst_len) {
  ------------------
  |  Branch (30:16): [True: 0, False: 53.5k]
  ------------------
   31|      0|        return READSTAT_ERROR_CONVERT_LONG_STRING;
   32|  53.5k|    } else {
   33|  53.5k|        memcpy(dst, src, src_len);
   34|  53.5k|        dst[src_len] = '\0';
   35|  53.5k|    }
   36|  53.5k|    return READSTAT_OK;
   37|  53.5k|}

unistd_io_init:
  121|  2.80k|readstat_error_t unistd_io_init(readstat_parser_t *parser) {
  122|  2.80k|    readstat_error_t retval = READSTAT_OK;
  123|  2.80k|    unistd_io_ctx_t *io_ctx = NULL;
  124|       |
  125|  2.80k|    if ((retval = readstat_set_open_handler(parser, unistd_open_handler)) != READSTAT_OK)
  ------------------
  |  Branch (125:9): [True: 0, False: 2.80k]
  ------------------
  126|      0|        return retval;
  127|       |
  128|  2.80k|    if ((retval = readstat_set_close_handler(parser, unistd_close_handler)) != READSTAT_OK)
  ------------------
  |  Branch (128:9): [True: 0, False: 2.80k]
  ------------------
  129|      0|        return retval;
  130|       |
  131|  2.80k|    if ((retval = readstat_set_seek_handler(parser, unistd_seek_handler)) != READSTAT_OK)
  ------------------
  |  Branch (131:9): [True: 0, False: 2.80k]
  ------------------
  132|      0|        return retval;
  133|       |
  134|  2.80k|    if ((retval = readstat_set_read_handler(parser, unistd_read_handler)) != READSTAT_OK)
  ------------------
  |  Branch (134:9): [True: 0, False: 2.80k]
  ------------------
  135|      0|        return retval;
  136|       |
  137|  2.80k|    if ((readstat_set_update_handler(parser, unistd_update_handler)) != READSTAT_OK)
  ------------------
  |  Branch (137:9): [True: 0, False: 2.80k]
  ------------------
  138|      0|        return retval;
  139|       |
  140|  2.80k|    io_ctx = calloc(1, sizeof(unistd_io_ctx_t));
  141|  2.80k|    io_ctx->fd = -1;
  142|       |
  143|  2.80k|    retval = readstat_set_io_ctx(parser, (void*) io_ctx);
  144|  2.80k|    parser->io->io_ctx_needs_free = 1;
  145|       |
  146|  2.80k|    return retval;
  147|  2.80k|}

readstat_calloc:
   17|  2.30k|void *readstat_calloc(size_t count, size_t size) {
   18|  2.30k|    if (count > MAX_MALLOC_SIZE || size > MAX_MALLOC_SIZE || count * size > MAX_MALLOC_SIZE) {
  ------------------
  |  |    3|  4.61k|#define MAX_MALLOC_SIZE 0x1000000
  ------------------
                  if (count > MAX_MALLOC_SIZE || size > MAX_MALLOC_SIZE || count * size > MAX_MALLOC_SIZE) {
  ------------------
  |  |    3|  4.61k|#define MAX_MALLOC_SIZE 0x1000000
  ------------------
                  if (count > MAX_MALLOC_SIZE || size > MAX_MALLOC_SIZE || count * size > MAX_MALLOC_SIZE) {
  ------------------
  |  |    3|  2.30k|#define MAX_MALLOC_SIZE 0x1000000
  ------------------
  |  Branch (18:9): [True: 0, False: 2.30k]
  |  Branch (18:36): [True: 0, False: 2.30k]
  |  Branch (18:62): [True: 6, False: 2.30k]
  ------------------
   19|      6|        return NULL;
   20|      6|    }
   21|  2.30k|    if (count == 0 || size == 0) {
  ------------------
  |  Branch (21:9): [True: 4, False: 2.29k]
  |  Branch (21:23): [True: 0, False: 2.29k]
  ------------------
   22|      4|        return NULL;
   23|      4|    }
   24|  2.29k|    return calloc(count, size);
   25|  2.30k|}

readstat_parser_init:
    6|  2.80k|readstat_parser_t *readstat_parser_init(void) {
    7|  2.80k|    readstat_parser_t *parser = calloc(1, sizeof(readstat_parser_t));
    8|  2.80k|    parser->io = calloc(1, sizeof(readstat_io_t));
    9|  2.80k|    if (unistd_io_init(parser) != READSTAT_OK) {
  ------------------
  |  Branch (9:9): [True: 0, False: 2.80k]
  ------------------
   10|      0|        readstat_parser_free(parser);
   11|      0|        return NULL;
   12|      0|    }
   13|  2.80k|    parser->output_encoding = "UTF-8";
   14|  2.80k|    return parser;
   15|  2.80k|}
readstat_parser_free:
   17|  2.80k|void readstat_parser_free(readstat_parser_t *parser) {
   18|  2.80k|    if (parser) {
  ------------------
  |  Branch (18:9): [True: 2.80k, False: 0]
  ------------------
   19|  2.80k|        if (parser->io) {
  ------------------
  |  Branch (19:13): [True: 2.80k, False: 0]
  ------------------
   20|       |            readstat_set_io_ctx(parser, NULL);
   21|  2.80k|            free(parser->io);
   22|  2.80k|        }
   23|  2.80k|        free(parser);
   24|  2.80k|    }
   25|  2.80k|}
readstat_set_metadata_handler:
   27|  2.80k|readstat_error_t readstat_set_metadata_handler(readstat_parser_t *parser, readstat_metadata_handler metadata_handler) {
   28|  2.80k|    parser->handlers.metadata = metadata_handler;
   29|  2.80k|    return READSTAT_OK;
   30|  2.80k|}
readstat_set_note_handler:
   32|  2.80k|readstat_error_t readstat_set_note_handler(readstat_parser_t *parser, readstat_note_handler note_handler) {
   33|  2.80k|    parser->handlers.note = note_handler;
   34|  2.80k|    return READSTAT_OK;
   35|  2.80k|}
readstat_set_variable_handler:
   37|  2.80k|readstat_error_t readstat_set_variable_handler(readstat_parser_t *parser, readstat_variable_handler variable_handler) {
   38|  2.80k|    parser->handlers.variable = variable_handler;
   39|  2.80k|    return READSTAT_OK;
   40|  2.80k|}
readstat_set_value_handler:
   42|  2.80k|readstat_error_t readstat_set_value_handler(readstat_parser_t *parser, readstat_value_handler value_handler) {
   43|  2.80k|    parser->handlers.value = value_handler;
   44|  2.80k|    return READSTAT_OK;
   45|  2.80k|}
readstat_set_value_label_handler:
   47|  2.80k|readstat_error_t readstat_set_value_label_handler(readstat_parser_t *parser, readstat_value_label_handler label_handler) {
   48|  2.80k|    parser->handlers.value_label = label_handler;
   49|  2.80k|    return READSTAT_OK;
   50|  2.80k|}
readstat_set_fweight_handler:
   62|  2.80k|readstat_error_t readstat_set_fweight_handler(readstat_parser_t *parser, readstat_fweight_handler fweight_handler) {
   63|  2.80k|    parser->handlers.fweight = fweight_handler;
   64|  2.80k|    return READSTAT_OK;
   65|  2.80k|}
readstat_set_open_handler:
   67|  5.60k|readstat_error_t readstat_set_open_handler(readstat_parser_t *parser, readstat_open_handler open_handler) {
   68|  5.60k|    parser->io->open = open_handler;
   69|  5.60k|    return READSTAT_OK;
   70|  5.60k|}
readstat_set_close_handler:
   72|  5.60k|readstat_error_t readstat_set_close_handler(readstat_parser_t *parser, readstat_close_handler close_handler) {
   73|  5.60k|    parser->io->close = close_handler;
   74|  5.60k|    return READSTAT_OK;
   75|  5.60k|}
readstat_set_seek_handler:
   77|  5.60k|readstat_error_t readstat_set_seek_handler(readstat_parser_t *parser, readstat_seek_handler seek_handler) {
   78|  5.60k|    parser->io->seek = seek_handler;
   79|  5.60k|    return READSTAT_OK;
   80|  5.60k|}
readstat_set_read_handler:
   82|  5.60k|readstat_error_t readstat_set_read_handler(readstat_parser_t *parser, readstat_read_handler read_handler) {
   83|  5.60k|    parser->io->read = read_handler;
   84|  5.60k|    return READSTAT_OK;
   85|  5.60k|}
readstat_set_update_handler:
   87|  5.60k|readstat_error_t readstat_set_update_handler(readstat_parser_t *parser, readstat_update_handler update_handler) {
   88|  5.60k|    parser->io->update = update_handler;
   89|  5.60k|    return READSTAT_OK;
   90|  5.60k|}
readstat_set_io_ctx:
   92|  8.40k|readstat_error_t readstat_set_io_ctx(readstat_parser_t *parser, void *io_ctx) {
   93|  8.40k|    if (parser->io->io_ctx_needs_free) {
  ------------------
  |  Branch (93:9): [True: 2.80k, False: 5.60k]
  ------------------
   94|  2.80k|        free(parser->io->io_ctx);
   95|  2.80k|    }
   96|       |
   97|  8.40k|    parser->io->io_ctx = io_ctx;
   98|  8.40k|    parser->io->io_ctx_needs_free = 0;
   99|       |
  100|  8.40k|    return READSTAT_OK;
  101|  8.40k|}

por_ctx_init:
   75|  2.80k|por_ctx_t *por_ctx_init(void) {
   76|  2.80k|    por_ctx_t *ctx = calloc(1, sizeof(por_ctx_t));
   77|       |
   78|  2.80k|    ctx->space = ' ';
   79|  2.80k|    ctx->base30_precision = 20;
   80|  2.80k|    ctx->var_dict = ck_hash_table_init(1024, 8);
   81|  2.80k|    return ctx;
   82|  2.80k|}
por_ctx_free:
   84|  2.80k|void por_ctx_free(por_ctx_t *ctx) {
   85|  2.80k|    if (ctx->string_buffer)
  ------------------
  |  Branch (85:9): [True: 1.87k, False: 927]
  ------------------
   86|  1.87k|        free(ctx->string_buffer);
   87|  2.80k|    if (ctx->varinfo) {
  ------------------
  |  Branch (87:9): [True: 1.14k, False: 1.65k]
  ------------------
   88|  1.14k|        int i;
   89|  2.50M|        for (i=0; i<ctx->var_count; i++) {
  ------------------
  |  Branch (89:19): [True: 2.50M, False: 1.14k]
  ------------------
   90|  2.50M|            if (ctx->varinfo[i].label)
  ------------------
  |  Branch (90:17): [True: 767, False: 2.50M]
  ------------------
   91|    767|                free(ctx->varinfo[i].label);
   92|  2.50M|        }
   93|  1.14k|        free(ctx->varinfo);
   94|  1.14k|    }
   95|  2.80k|    if (ctx->variables) {
  ------------------
  |  Branch (95:9): [True: 1.15k, False: 1.65k]
  ------------------
   96|  1.15k|        int i;
   97|  5.88M|        for (i=0; i<ctx->var_count; i++) {
  ------------------
  |  Branch (97:19): [True: 5.88M, False: 1.15k]
  ------------------
   98|  5.88M|            if (ctx->variables[i])
  ------------------
  |  Branch (98:17): [True: 1.70k, False: 5.88M]
  ------------------
   99|  1.70k|                free(ctx->variables[i]);
  100|  5.88M|        }
  101|  1.15k|        free(ctx->variables);
  102|  1.15k|    }
  103|  2.80k|    if (ctx->var_dict)
  ------------------
  |  Branch (103:9): [True: 2.80k, False: 0]
  ------------------
  104|  2.80k|        ck_hash_table_free(ctx->var_dict);
  105|  2.80k|    if (ctx->converter)
  ------------------
  |  Branch (105:9): [True: 0, False: 2.80k]
  ------------------
  106|      0|        iconv_close(ctx->converter);
  107|  2.80k|    free(ctx);
  108|  2.80k|}
por_utf8_encode:
  168|   561k|        char *output, size_t output_len, uint16_t lookup[256]) {
  169|   561k|    size_t offset = 0;
  170|   561k|    size_t i;
  171|  5.78M|    for (i=0; i<input_len; i++) {
  ------------------
  |  Branch (171:15): [True: 5.22M, False: 556k]
  ------------------
  172|  5.22M|        uint16_t codepoint = lookup[input[i]];
  173|       |
  174|       |        /* Some software (SPSS?) uses an undefined character (zero) if a
  175|       |         * character can't be encoded. Use Unicode replacement character */
  176|  5.22M|        if (codepoint == 0) {
  ------------------
  |  Branch (176:13): [True: 52.8k, False: 5.17M]
  ------------------
  177|  52.8k|            codepoint = 0xFFFD;
  178|  52.8k|        }
  179|       |
  180|  5.22M|        if (codepoint < 0x20) {
  ------------------
  |  Branch (180:13): [True: 0, False: 5.22M]
  ------------------
  181|      0|            return -1;
  182|  5.22M|        } else if (codepoint <= 0x7F) {
  ------------------
  |  Branch (182:20): [True: 5.17M, False: 53.7k]
  ------------------
  183|  5.17M|            if (offset + 1 > output_len)
  ------------------
  |  Branch (183:17): [True: 2.70k, False: 5.17M]
  ------------------
  184|  2.70k|                return offset;
  185|       |
  186|  5.17M|            output[offset++] = codepoint;
  187|  5.17M|        } else if (codepoint <= 0x07FF) {
  ------------------
  |  Branch (187:20): [True: 875, False: 52.9k]
  ------------------
  188|    875|            if (offset + 2 > output_len)
  ------------------
  |  Branch (188:17): [True: 196, False: 679]
  ------------------
  189|    196|                return offset;
  190|       |
  191|    679|            output[offset++] = 0xC0 | (codepoint >> 6);
  192|    679|            output[offset++] = 0x80 | (codepoint & 0x3F);
  193|  52.9k|        } else {
  194|  52.9k|            if (offset + 3 > output_len)
  ------------------
  |  Branch (194:17): [True: 2.74k, False: 50.1k]
  ------------------
  195|  2.74k|                return offset;
  196|       |
  197|  50.1k|            output[offset++] = 0xE0 | (codepoint >> 12);
  198|  50.1k|            output[offset++] = 0x80 | ((codepoint >> 6) & 0x3F);
  199|  50.1k|            output[offset++] = 0x80 | (codepoint & 0x3F);
  200|  50.1k|        }
  201|  5.22M|    }
  202|   556k|    return offset;
  203|   561k|}
por_base30_to_double:
  399|   488k|double por_base30_to_double(const unsigned char *digits, size_t n_digits, long exponent) {
  400|   488k|    uint64_t mantissa = 0;
  401|   488k|    size_t mantissa_digits = 0;
  402|   488k|    long magnitude = 0;
  403|   488k|    long scale = 0;
  404|   488k|    double value = 0.0;
  405|   488k|    int iterations = 0;
  406|       |
  407|   488k|    while (n_digits > 0 && digits[0] == 0) {
  ------------------
  |  Branch (407:12): [True: 437k, False: 50.2k]
  |  Branch (407:28): [True: 0, False: 437k]
  ------------------
  408|      0|        digits++;
  409|      0|        n_digits--;
  410|      0|    }
  411|   583k|    while (n_digits > 0 && digits[n_digits-1] == 0) {
  ------------------
  |  Branch (411:12): [True: 532k, False: 50.2k]
  |  Branch (411:28): [True: 94.9k, False: 437k]
  ------------------
  412|  94.9k|        n_digits--;
  413|  94.9k|        exponent++;
  414|  94.9k|    }
  415|   488k|    if (n_digits == 0)
  ------------------
  |  Branch (415:9): [True: 50.2k, False: 437k]
  ------------------
  416|  50.2k|        return 0.0;
  417|       |
  418|       |    /* The value lies in [30^(magnitude-1), 30^magnitude) */
  419|   437k|    magnitude = (long)n_digits + exponent;
  420|   437k|    if (magnitude >= 210) /* 30^209 exceeds DBL_MAX */
  ------------------
  |  Branch (420:9): [True: 12.0k, False: 425k]
  ------------------
  421|  12.0k|        return HUGE_VAL;
  422|   425k|    if (magnitude <= -225) /* 30^-225 is below half the smallest denormal */
  ------------------
  |  Branch (422:9): [True: 1.46k, False: 424k]
  ------------------
  423|  1.46k|        return 0.0;
  424|       |
  425|       |    /* Initial approximation from the leading 13 digits (30^13 < 2^64) */
  426|  1.68M|    while (mantissa_digits < n_digits && mantissa_digits < 13) {
  ------------------
  |  Branch (426:12): [True: 1.30M, False: 382k]
  |  Branch (426:42): [True: 1.26M, False: 41.8k]
  ------------------
  427|  1.26M|        mantissa = mantissa * 30 + digits[mantissa_digits];
  428|  1.26M|        mantissa_digits++;
  429|  1.26M|    }
  430|   424k|    scale = exponent + (long)(n_digits - mantissa_digits);
  431|       |
  432|   424k|    if (mantissa <= (1ULL << 53) && scale >= -13 && scale <= 13) {
  ------------------
  |  Branch (432:9): [True: 371k, False: 53.4k]
  |  Branch (432:37): [True: 358k, False: 12.6k]
  |  Branch (432:53): [True: 357k, False: 1.34k]
  ------------------
  433|       |        /* Both operands are exact, so the single multiplication or division
  434|       |         * below is correctly rounded (30^13 = 2^13 * 15^13 and 15^13 < 2^53) */
  435|   357k|        double pow30 = 1.0;
  436|   357k|        long k = scale < 0 ? -scale : scale;
  ------------------
  |  Branch (436:18): [True: 761, False: 356k]
  ------------------
  437|   384k|        while (k-- > 0)
  ------------------
  |  Branch (437:16): [True: 27.6k, False: 357k]
  ------------------
  438|  27.6k|            pow30 *= 30.0;
  439|   357k|        return scale < 0 ? (double)mantissa / pow30 : (double)mantissa * pow30;
  ------------------
  |  Branch (439:16): [True: 761, False: 356k]
  ------------------
  440|   357k|    }
  441|       |
  442|  67.4k|    value = (double)mantissa;
  443|   108k|    while (scale > 0) {
  ------------------
  |  Branch (443:12): [True: 41.1k, False: 67.4k]
  ------------------
  444|  41.1k|        long step = scale > 200 ? 200 : scale;
  ------------------
  |  Branch (444:21): [True: 387, False: 40.7k]
  ------------------
  445|  41.1k|        value *= pow(30.0, (double)step);
  446|  41.1k|        scale -= step;
  447|  41.1k|    }
  448|  85.9k|    while (scale < 0) {
  ------------------
  |  Branch (448:12): [True: 18.5k, False: 67.4k]
  ------------------
  449|  18.5k|        long step = scale < -200 ? -200 : scale;
  ------------------
  |  Branch (449:21): [True: 2.02k, False: 16.5k]
  ------------------
  450|  18.5k|        value *= pow(30.0, (double)step);
  451|  18.5k|        scale -= step;
  452|  18.5k|    }
  453|  67.4k|    if (isinf(value))
  ------------------
  |  Branch (453:9): [True: 400, False: 67.0k]
  ------------------
  454|    400|        value = DBL_MAX;
  455|       |
  456|       |    /* Correct the approximation by comparing the exact value against the
  457|       |     * midpoints between the candidate and its neighbors, moving one ulp at a
  458|       |     * time. Ties round to even. */
  459|  86.1k|    for (iterations=0; iterations<256; iterations++) {
  ------------------
  |  Branch (459:24): [True: 86.1k, False: 0]
  ------------------
  460|  86.1k|        uint64_t m = 0;
  461|  86.1k|        long e = -1074;
  462|  86.1k|        uint64_t midpoint_mantissa = 0;
  463|  86.1k|        long midpoint_exponent = 0;
  464|  86.1k|        int cmp = 0;
  465|       |
  466|  86.1k|        if (isinf(value))
  ------------------
  |  Branch (466:13): [True: 400, False: 85.7k]
  ------------------
  467|    400|            break;
  468|       |
  469|  85.7k|        if (value != 0.0) {
  ------------------
  |  Branch (469:13): [True: 85.5k, False: 207]
  ------------------
  470|  85.5k|            int exp2 = 0;
  471|  85.5k|            double significand = frexp(value, &exp2);
  472|  85.5k|            m = (uint64_t)ldexp(significand, 53);
  473|  85.5k|            e = exp2 - 53;
  474|  85.5k|            if (e < -1074) {
  ------------------
  |  Branch (474:17): [True: 1.77k, False: 83.7k]
  ------------------
  475|       |                /* denormal: the spacing is fixed at 2^-1074 */
  476|  1.77k|                m = (uint64_t)ldexp(value, 1074);
  477|  1.77k|                e = -1074;
  478|  1.77k|            }
  479|  85.5k|        }
  480|       |
  481|       |        /* midpoint above: (2m + 1) * 2^(e - 1) */
  482|  85.7k|        midpoint_mantissa = 2 * m + 1;
  483|  85.7k|        midpoint_exponent = e - 1;
  484|  85.7k|        cmp = por_compare_with_binary(digits, n_digits, exponent, midpoint_mantissa, midpoint_exponent);
  485|  85.7k|        if (cmp == 2)
  ------------------
  |  Branch (485:13): [True: 0, False: 85.7k]
  ------------------
  486|      0|            break;
  487|  85.7k|        if (cmp > 0) {
  ------------------
  |  Branch (487:13): [True: 8.08k, False: 77.6k]
  ------------------
  488|  8.08k|            value = nextafter(value, HUGE_VAL);
  489|  8.08k|            continue;
  490|  8.08k|        }
  491|  77.6k|        if (cmp == 0) {
  ------------------
  |  Branch (491:13): [True: 459, False: 77.2k]
  ------------------
  492|    459|            if (m & 1)
  ------------------
  |  Branch (492:17): [True: 194, False: 265]
  ------------------
  493|    194|                value = nextafter(value, HUGE_VAL);
  494|    459|            break;
  495|    459|        }
  496|  77.2k|        if (m == 0)
  ------------------
  |  Branch (496:13): [True: 207, False: 77.0k]
  ------------------
  497|    207|            break;
  498|       |
  499|       |        /* midpoint below: the spacing halves just below a power of two */
  500|  77.0k|        if (m == (1ULL << 52) && e > -1074) {
  ------------------
  |  Branch (500:13): [True: 342, False: 76.6k]
  |  Branch (500:34): [True: 342, False: 0]
  ------------------
  501|    342|            midpoint_mantissa = 4 * m - 1;
  502|    342|            midpoint_exponent = e - 2;
  503|  76.6k|        } else {
  504|  76.6k|            midpoint_mantissa = 2 * m - 1;
  505|  76.6k|            midpoint_exponent = e - 1;
  506|  76.6k|        }
  507|  77.0k|        cmp = por_compare_with_binary(digits, n_digits, exponent, midpoint_mantissa, midpoint_exponent);
  508|  77.0k|        if (cmp == 2)
  ------------------
  |  Branch (508:13): [True: 0, False: 77.0k]
  ------------------
  509|      0|            break;
  510|  77.0k|        if (cmp < 0) {
  ------------------
  |  Branch (510:13): [True: 10.6k, False: 66.3k]
  ------------------
  511|  10.6k|            value = nextafter(value, 0.0);
  512|  10.6k|            continue;
  513|  10.6k|        }
  514|  66.3k|        if (cmp == 0) {
  ------------------
  |  Branch (514:13): [True: 8.22k, False: 58.1k]
  ------------------
  515|       |            /* value's mantissa is 2m in the finer grid below a power of two,
  516|       |             * which is even, so only the ordinary case can move */
  517|  8.22k|            if (midpoint_mantissa == 2 * m - 1 && (m & 1))
  ------------------
  |  Branch (517:17): [True: 8.22k, False: 1]
  |  Branch (517:51): [True: 194, False: 8.02k]
  ------------------
  518|    194|                value = nextafter(value, 0.0);
  519|  8.22k|            break;
  520|  8.22k|        }
  521|  58.1k|        break;
  522|  66.3k|    }
  523|       |
  524|  67.4k|    return value;
  525|   424k|}
readstat_por.c:por_big_set:
  249|   325k|static void por_big_set(por_bignum_t *big, uint64_t value) {
  250|   325k|    big->n = 0;
  251|   325k|    big->overflow = 0;
  252|   650k|    while (value) {
  ------------------
  |  Branch (252:12): [True: 325k, False: 325k]
  ------------------
  253|   325k|        big->limbs[big->n++] = (uint32_t)(value % POR_BIG_LIMB_BASE);
  ------------------
  |  |  239|   325k|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  254|   325k|        value /= POR_BIG_LIMB_BASE;
  ------------------
  |  |  239|   325k|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  255|   325k|    }
  256|   325k|}
readstat_por.c:por_big_mul_pow:
  279|   186k|static void por_big_mul_pow(por_bignum_t *big, uint32_t base, long exponent) {
  280|   186k|    uint32_t chunk_mult = 1;
  281|   186k|    long chunk = 0;
  282|  4.96M|    while ((uint64_t)chunk_mult * base <= 0xFFFFFFFFu) {
  ------------------
  |  Branch (282:12): [True: 4.77M, False: 186k]
  ------------------
  283|  4.77M|        chunk_mult *= base;
  284|  4.77M|        chunk++;
  285|  4.77M|    }
  286|  1.50M|    while (exponent >= chunk && !big->overflow) {
  ------------------
  |  Branch (286:12): [True: 1.31M, False: 186k]
  |  Branch (286:33): [True: 1.31M, False: 0]
  ------------------
  287|  1.31M|        por_big_mul_add(big, chunk_mult, 0);
  288|  1.31M|        exponent -= chunk;
  289|  1.31M|    }
  290|   186k|    if (exponent > 0) {
  ------------------
  |  Branch (290:9): [True: 171k, False: 15.5k]
  ------------------
  291|   171k|        uint32_t mult = 1;
  292|  2.45M|        while (exponent-- > 0)
  ------------------
  |  Branch (292:16): [True: 2.27M, False: 171k]
  ------------------
  293|  2.27M|            mult *= base;
  294|   171k|        por_big_mul_add(big, mult, 0);
  295|   171k|    }
  296|   186k|}
readstat_por.c:por_big_mul_add:
  259|  2.21M|static void por_big_mul_add(por_bignum_t *big, uint32_t mult, uint32_t add) {
  260|  2.21M|    uint64_t carry = add;
  261|  2.21M|    int i;
  262|  20.4M|    for (i=0; i<big->n; i++) {
  ------------------
  |  Branch (262:15): [True: 18.2M, False: 2.21M]
  ------------------
  263|  18.2M|        uint64_t product = (uint64_t)big->limbs[i] * mult + carry;
  264|  18.2M|        big->limbs[i] = (uint32_t)(product % POR_BIG_LIMB_BASE);
  ------------------
  |  |  239|  18.2M|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  265|  18.2M|        carry = product / POR_BIG_LIMB_BASE;
  ------------------
  |  |  239|  18.2M|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  266|  18.2M|    }
  267|  4.43M|    while (carry) {
  ------------------
  |  Branch (267:12): [True: 2.21M, False: 2.21M]
  ------------------
  268|  2.21M|        if (big->n == POR_BIG_LIMBS) {
  ------------------
  |  |  241|  2.21M|#define POR_BIG_LIMBS       200         /* 1200 trigesimals; a denormal needs ~870 */
  ------------------
  |  Branch (268:13): [True: 0, False: 2.21M]
  ------------------
  269|      0|            big->overflow = 1;
  270|      0|            return;
  271|      0|        }
  272|  2.21M|        big->limbs[big->n++] = (uint32_t)(carry % POR_BIG_LIMB_BASE);
  ------------------
  |  |  239|  2.21M|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  273|  2.21M|        carry /= POR_BIG_LIMB_BASE;
  ------------------
  |  |  239|  2.21M|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  274|  2.21M|    }
  275|  2.21M|}
readstat_por.c:por_compare_with_binary:
  362|   162k|        uint64_t mantissa, long exp2) {
  363|   162k|    por_bignum_t lhs, rhs;
  364|   162k|    size_t i;
  365|   162k|    uint32_t chunk = 0;
  366|   162k|    uint32_t chunk_mult = 1;
  367|       |
  368|   162k|    por_big_set(&lhs, 0);
  369|  4.13M|    for (i=0; i<n_digits; i++) {
  ------------------
  |  Branch (369:15): [True: 3.96M, False: 162k]
  ------------------
  370|  3.96M|        chunk = chunk * 30 + digits[i];
  371|  3.96M|        chunk_mult *= 30;
  372|  3.96M|        if (chunk_mult == POR_BIG_LIMB_BASE) {
  ------------------
  |  |  239|  3.96M|#define POR_BIG_LIMB_BASE   729000000u  /* 30^6 */
  ------------------
  |  Branch (372:13): [True: 584k, False: 3.38M]
  ------------------
  373|   584k|            por_big_mul_add(&lhs, chunk_mult, chunk);
  374|   584k|            chunk = 0;
  375|   584k|            chunk_mult = 1;
  376|   584k|        }
  377|  3.96M|    }
  378|   162k|    if (chunk_mult > 1)
  ------------------
  |  Branch (378:9): [True: 144k, False: 18.7k]
  ------------------
  379|   144k|        por_big_mul_add(&lhs, chunk_mult, chunk);
  380|       |
  381|   162k|    por_big_set(&rhs, mantissa);
  382|       |
  383|   162k|    if (exp30 > 0) {
  ------------------
  |  Branch (383:9): [True: 4.45k, False: 158k]
  ------------------
  384|  4.45k|        por_big_mul_pow(&lhs, 30, exp30);
  385|   158k|    } else if (exp30 < 0) {
  ------------------
  |  Branch (385:16): [True: 36.3k, False: 122k]
  ------------------
  386|  36.3k|        por_big_mul_pow(&rhs, 30, -exp30);
  387|  36.3k|    }
  388|   162k|    if (exp2 > 0) {
  ------------------
  |  Branch (388:9): [True: 110k, False: 52.3k]
  ------------------
  389|   110k|        por_big_mul_pow(&rhs, 2, exp2);
  390|   110k|    } else if (exp2 < 0) {
  ------------------
  |  Branch (390:16): [True: 35.6k, False: 16.6k]
  ------------------
  391|  35.6k|        por_big_mul_pow(&lhs, 2, -exp2);
  392|  35.6k|    }
  393|   162k|    if (lhs.overflow || rhs.overflow)
  ------------------
  |  Branch (393:9): [True: 0, False: 162k]
  |  Branch (393:25): [True: 0, False: 162k]
  ------------------
  394|      0|        return 2;
  395|       |
  396|   162k|    return por_big_compare(&lhs, &rhs);
  397|   162k|}
readstat_por.c:por_big_compare:
  298|   162k|static int por_big_compare(const por_bignum_t *a, const por_bignum_t *b) {
  299|   162k|    int i;
  300|   162k|    if (a->n != b->n)
  ------------------
  |  Branch (300:9): [True: 383, False: 162k]
  ------------------
  301|    383|        return a->n > b->n ? 1 : -1;
  ------------------
  |  Branch (301:16): [True: 167, False: 216]
  ------------------
  302|   432k|    for (i=a->n-1; i>=0; i--) {
  ------------------
  |  Branch (302:20): [True: 423k, False: 8.68k]
  ------------------
  303|   423k|        if (a->limbs[i] != b->limbs[i])
  ------------------
  |  Branch (303:13): [True: 153k, False: 270k]
  ------------------
  304|   153k|            return a->limbs[i] > b->limbs[i] ? 1 : -1;
  ------------------
  |  Branch (304:20): [True: 66.0k, False: 87.6k]
  ------------------
  305|   423k|    }
  306|  8.68k|    return 0;
  307|   162k|}

readstat_por_parse_double:
   79|   488k|readstat_error_handler error_cb, void *user_ctx) {
   80|   488k|	ssize_t retval = 0;
   81|   488k|	double val = 0.0;
   82|       |	
   83|       |	/* Significant digits of the mantissa, most significant first; leading
   84|       |	* zeros are dropped and digits beyond POR_PARSE_MAX_DIGITS are folded
   85|       |	* into the scale. */
   86|   488k|	unsigned char digits[POR_PARSE_MAX_DIGITS] = { 0 };
   87|   488k|	size_t n_digits = 0;
   88|   488k|	long scale = 0;
   89|   488k|	long exp = 0;
   90|       |	
   91|   488k|	const unsigned char *p = (const unsigned char *)data;
   92|   488k|	const unsigned char *pe = p + len;
   93|       |	
   94|   488k|	int cs;
   95|   488k|	int is_negative = 0, exp_is_negative = 0;
   96|   488k|	int got_dot = 0;
   97|   488k|	int is_missing = 0;
   98|   488k|	int success = 0;
   99|       |	
  100|       |	
  101|   488k|#line 102 "src/spss/readstat_por_parse.c"
  102|   488k|	{
  103|   488k|		cs = (int)por_field_parse_start;
  104|   488k|	}
  105|       |	
  106|   488k|#line 107 "src/spss/readstat_por_parse.c"
  107|   488k|	{
  108|   488k|		int _klen;
  109|   488k|		unsigned int _trans = 0;
  110|   488k|		const char * _keys;
  111|   488k|		const signed char * _acts;
  112|   488k|		unsigned int _nacts;
  113|  4.32M|		_resume: {}
  114|  4.32M|		if ( p == pe )
  ------------------
  |  Branch (114:8): [True: 0, False: 4.32M]
  ------------------
  115|      0|			goto _out;
  116|  4.32M|		_keys = ( _por_field_parse_trans_keys + (_por_field_parse_key_offsets[cs]));
  117|  4.32M|		_trans = (unsigned int)_por_field_parse_index_offsets[cs];
  118|       |		
  119|  4.32M|		_klen = (int)_por_field_parse_single_lengths[cs];
  120|  4.32M|		if ( _klen > 0 ) {
  ------------------
  |  Branch (120:8): [True: 4.29M, False: 32.5k]
  ------------------
  121|  4.29M|			const char *_lower = _keys;
  122|  4.29M|			const char *_upper = _keys + _klen - 1;
  123|  4.29M|			const char *_mid;
  124|  15.5M|			while ( 1 ) {
  ------------------
  |  Branch (124:12): [True: 15.5M, Folded]
  ------------------
  125|  15.5M|				if ( _upper < _lower ) {
  ------------------
  |  Branch (125:10): [True: 3.52M, False: 12.0M]
  ------------------
  126|  3.52M|					_keys += _klen;
  127|  3.52M|					_trans += (unsigned int)_klen;
  128|  3.52M|					break;
  129|  3.52M|				}
  130|       |				
  131|  12.0M|				_mid = _lower + ((_upper-_lower) >> 1);
  132|  12.0M|				if ( ( (*( p))) < (*( _mid)) )
  ------------------
  |  Branch (132:10): [True: 261k, False: 11.7M]
  ------------------
  133|   261k|					_upper = _mid - 1;
  134|  11.7M|				else if ( ( (*( p))) > (*( _mid)) )
  ------------------
  |  Branch (134:15): [True: 11.0M, False: 772k]
  ------------------
  135|  11.0M|					_lower = _mid + 1;
  136|   772k|				else {
  137|   772k|					_trans += (unsigned int)(_mid - _keys);
  138|   772k|					goto _match;
  139|   772k|				}
  140|  12.0M|			}
  141|  4.29M|		}
  142|       |		
  143|  3.55M|		_klen = (int)_por_field_parse_range_lengths[cs];
  144|  3.55M|		if ( _klen > 0 ) {
  ------------------
  |  Branch (144:8): [True: 3.55M, False: 2]
  ------------------
  145|  3.55M|			const char *_lower = _keys;
  146|  3.55M|			const char *_upper = _keys + (_klen<<1) - 2;
  147|  3.55M|			const char *_mid;
  148|  4.89M|			while ( 1 ) {
  ------------------
  |  Branch (148:12): [True: 4.89M, Folded]
  ------------------
  149|  4.89M|				if ( _upper < _lower ) {
  ------------------
  |  Branch (149:10): [True: 96, False: 4.89M]
  ------------------
  150|     96|					_trans += (unsigned int)_klen;
  151|     96|					break;
  152|     96|				}
  153|       |				
  154|  4.89M|				_mid = _lower + (((_upper-_lower) >> 1) & ~1);
  155|  4.89M|				if ( ( (*( p))) < (*( _mid)) )
  ------------------
  |  Branch (155:10): [True: 53, False: 4.89M]
  ------------------
  156|     53|					_upper = _mid - 2;
  157|  4.89M|				else if ( ( (*( p))) > (*( _mid + 1)) )
  ------------------
  |  Branch (157:15): [True: 1.34M, False: 3.55M]
  ------------------
  158|  1.34M|					_lower = _mid + 2;
  159|  3.55M|				else {
  160|  3.55M|					_trans += (unsigned int)((_mid - _keys)>>1);
  161|  3.55M|					break;
  162|  3.55M|				}
  163|  4.89M|			}
  164|  3.55M|		}
  165|       |		
  166|  4.32M|		_match: {}
  167|  4.32M|		cs = (int)_por_field_parse_cond_targs[_trans];
  168|       |		
  169|  4.32M|		if ( _por_field_parse_cond_actions[_trans] != 0 ) {
  ------------------
  |  Branch (169:8): [True: 4.06M, False: 261k]
  ------------------
  170|       |			
  171|  4.06M|			_acts = ( _por_field_parse_actions + (_por_field_parse_cond_actions[_trans]));
  172|  4.06M|			_nacts = (unsigned int)(*( _acts));
  173|  4.06M|			_acts += 1;
  174|  7.64M|			while ( _nacts > 0 ) {
  ------------------
  |  Branch (174:12): [True: 4.06M, False: 3.57M]
  ------------------
  175|  4.06M|				switch ( (*( _acts)) )
  ------------------
  |  Branch (175:14): [True: 4.06M, False: 0]
  ------------------
  176|  4.06M|				{
  177|  3.32M|					case 0:  {
  ------------------
  |  Branch (177:6): [True: 3.32M, False: 746k]
  ------------------
  178|  3.32M|						{
  179|  3.32M|#line 42 "src/spss/readstat_por_parse.rl"
  180|       |							
  181|  3.32M|							int digit = por_base30_digit_value((( (*( p)))));
  182|  3.32M|							if (n_digits == 0 && digit == 0) {
  ------------------
  |  Branch (182:12): [True: 1.62M, False: 1.69M]
  |  Branch (182:29): [True: 1.18M, False: 437k]
  ------------------
  183|  1.18M|								if (got_dot)
  ------------------
  |  Branch (183:13): [True: 2.63k, False: 1.18M]
  ------------------
  184|  2.63k|								scale--;
  185|  2.13M|							} else if (n_digits < POR_PARSE_MAX_DIGITS) {
  ------------------
  |  |    7|  2.13M|#define POR_PARSE_MAX_DIGITS 128
  ------------------
  |  Branch (185:19): [True: 2.13M, False: 0]
  ------------------
  186|  2.13M|								digits[n_digits++] = digit;
  187|  2.13M|								if (got_dot)
  ------------------
  |  Branch (187:13): [True: 65.7k, False: 2.07M]
  ------------------
  188|  65.7k|								scale--;
  189|  2.13M|							} else if (!got_dot) {
  ------------------
  |  Branch (189:19): [True: 0, False: 0]
  ------------------
  190|      0|								scale++;
  191|      0|							}
  192|  3.32M|						}
  193|       |						
  194|  3.32M|#line 195 "src/spss/readstat_por_parse.c"
  195|       |						
  196|  3.32M|						break; 
  197|      0|					}
  198|   236k|					case 1:  {
  ------------------
  |  Branch (198:6): [True: 236k, False: 3.83M]
  ------------------
  199|   236k|						{
  200|   236k|#line 56 "src/spss/readstat_por_parse.rl"
  201|       |							
  202|   236k|							if (exp < 100000)
  ------------------
  |  Branch (202:12): [True: 194k, False: 41.8k]
  ------------------
  203|   194k|							exp = 30 * exp + por_base30_digit_value((( (*( p)))));
  204|   236k|						}
  205|       |						
  206|   236k|#line 207 "src/spss/readstat_por_parse.c"
  207|       |						
  208|   236k|						break; 
  209|      0|					}
  210|  1.63k|					case 2:  {
  ------------------
  |  Branch (210:6): [True: 1.63k, False: 4.06M]
  ------------------
  211|  1.63k|						{
  212|  1.63k|#line 63 "src/spss/readstat_por_parse.rl"
  213|  1.63k|							got_dot = 1; }
  214|       |						
  215|  1.63k|#line 216 "src/spss/readstat_por_parse.c"
  216|       |						
  217|  1.63k|						break; 
  218|      0|					}
  219|  3.05k|					case 3:  {
  ------------------
  |  Branch (219:6): [True: 3.05k, False: 4.06M]
  ------------------
  220|  3.05k|						{
  221|  3.05k|#line 64 "src/spss/readstat_por_parse.rl"
  222|  3.05k|							got_dot = 1; }
  223|       |						
  224|  3.05k|#line 225 "src/spss/readstat_por_parse.c"
  225|       |						
  226|  3.05k|						break; 
  227|      0|					}
  228|  16.6k|					case 4:  {
  ------------------
  |  Branch (228:6): [True: 16.6k, False: 4.05M]
  ------------------
  229|  16.6k|						{
  230|  16.6k|#line 66 "src/spss/readstat_por_parse.rl"
  231|  16.6k|							exp_is_negative = 1; }
  232|       |						
  233|  16.6k|#line 234 "src/spss/readstat_por_parse.c"
  234|       |						
  235|  16.6k|						break; 
  236|      0|					}
  237|    685|					case 5:  {
  ------------------
  |  Branch (237:6): [True: 685, False: 4.06M]
  ------------------
  238|    685|						{
  239|    685|#line 68 "src/spss/readstat_por_parse.rl"
  240|    685|							is_negative = 1; }
  241|       |						
  242|    685|#line 243 "src/spss/readstat_por_parse.c"
  243|       |						
  244|    685|						break; 
  245|      0|					}
  246|    194|					case 6:  {
  ------------------
  |  Branch (246:6): [True: 194, False: 4.06M]
  ------------------
  247|    194|						{
  248|    194|#line 70 "src/spss/readstat_por_parse.rl"
  249|    194|							is_missing = 1; }
  250|       |						
  251|    194|#line 252 "src/spss/readstat_por_parse.c"
  252|       |						
  253|    194|						break; 
  254|      0|					}
  255|   488k|					case 7:  {
  ------------------
  |  Branch (255:6): [True: 488k, False: 3.57M]
  ------------------
  256|   488k|						{
  257|   488k|#line 72 "src/spss/readstat_por_parse.rl"
  258|   488k|							success = 1; {p += 1; goto _out; } }
  259|       |						
  260|      0|#line 261 "src/spss/readstat_por_parse.c"
  261|       |						
  262|      0|						break; 
  263|      0|					}
  264|  4.06M|				}
  265|  3.57M|				_nacts -= 1;
  266|  3.57M|				_acts += 1;
  267|  3.57M|			}
  268|       |			
  269|  4.06M|		}
  270|       |		
  271|  3.84M|		if ( cs != 0 ) {
  ------------------
  |  Branch (271:8): [True: 3.84M, False: 98]
  ------------------
  272|  3.84M|			p += 1;
  273|  3.84M|			goto _resume;
  274|  3.84M|		}
  275|   488k|		_out: {}
  276|   488k|	}
  277|       |	
  278|      0|#line 76 "src/spss/readstat_por_parse.rl"
  279|       |	
  280|       |	
  281|   488k|	if (is_missing) {
  ------------------
  |  Branch (281:6): [True: 194, False: 488k]
  ------------------
  282|    194|		val = NAN;
  283|   488k|	} else {
  284|   488k|		if (exp_is_negative)
  ------------------
  |  Branch (284:7): [True: 16.6k, False: 471k]
  ------------------
  285|  16.6k|			exp = -exp;
  286|   488k|		val = por_base30_to_double(digits, n_digits, scale + exp);
  287|   488k|		if (is_negative)
  ------------------
  |  Branch (287:7): [True: 685, False: 487k]
  ------------------
  288|    685|			val = -val;
  289|   488k|	}
  290|       |	
  291|   488k|	if (!success) {
  ------------------
  |  Branch (291:6): [True: 98, False: 488k]
  ------------------
  292|     98|		retval = -1;
  293|     98|		if (error_cb) {
  ------------------
  |  Branch (293:7): [True: 0, False: 98]
  ------------------
  294|      0|			char error_buf[1024];
  295|      0|			snprintf(error_buf, sizeof(error_buf), "Read bytes: %ld   String: %.*s  Ending state: %d",
  296|      0|			(long)(p - (const unsigned char *)data), (int)len, data, cs);
  297|      0|			error_cb(error_buf, user_ctx);
  298|      0|		}
  299|     98|	}
  300|       |	
  301|   488k|	if (retval == 0) {
  ------------------
  |  Branch (301:6): [True: 488k, False: 98]
  ------------------
  302|   488k|		if (result)
  ------------------
  |  Branch (302:7): [True: 488k, False: 0]
  ------------------
  303|   488k|			*result = val;
  304|       |		
  305|   488k|		retval = (p - (const unsigned char *)data);
  306|   488k|	}
  307|       |	
  308|       |	/* suppress warning */
  309|   488k|	(void)por_field_parse_en_main;
  310|       |	
  311|   488k|	return retval;
  312|  3.84M|}
readstat_por_parse.c:por_base30_digit_value:
   72|  3.51M|static int por_base30_digit_value(unsigned char c) {
   73|  3.51M|	if (c >= '0' && c <= '9')
  ------------------
  |  Branch (73:6): [True: 3.51M, False: 0]
  |  Branch (73:18): [True: 2.19M, False: 1.32M]
  ------------------
   74|  2.19M|		return c - '0';
   75|  1.32M|	return 10 + c - 'A';
   76|  3.51M|}

read_version_and_timestamp:
  700|  2.48k|readstat_error_t read_version_and_timestamp(por_ctx_t *ctx) {
  701|  2.48k|    readstat_error_t retval = READSTAT_OK;
  702|  2.48k|    char string[256];
  703|  2.48k|    struct tm timestamp = { .tm_isdst = -1 };
  704|  2.48k|    unsigned char version;
  705|       |
  706|  2.48k|    if (read_bytes(ctx, &version, sizeof(version)) != sizeof(version)) {
  ------------------
  |  Branch (706:9): [True: 11, False: 2.47k]
  ------------------
  707|     11|        retval = READSTAT_ERROR_READ;
  708|     11|        goto cleanup;
  709|     11|    }
  710|  2.47k|    if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) { /* creation date */
  ------------------
  |  Branch (710:9): [True: 490, False: 1.98k]
  ------------------
  711|    490|        goto cleanup;
  712|    490|    }
  713|  1.98k|    if (sscanf(string, "%04d%02d%02d", &timestamp.tm_year, &timestamp.tm_mon, &timestamp.tm_mday) != 3) {
  ------------------
  |  Branch (713:9): [True: 195, False: 1.78k]
  ------------------
  714|    195|        retval = READSTAT_ERROR_BAD_TIMESTAMP_STRING;
  715|    195|        goto cleanup;
  716|    195|    }
  717|  1.78k|    if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) { /* creation time */
  ------------------
  |  Branch (717:9): [True: 37, False: 1.74k]
  ------------------
  718|     37|        goto cleanup;
  719|     37|    }
  720|  1.74k|    if (sscanf(string, "%02d%02d%02d", &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec) != 3) {
  ------------------
  |  Branch (720:9): [True: 1.67k, False: 77]
  ------------------
  721|       |        /* optional */
  722|  1.67k|    }
  723|       |
  724|  1.74k|    timestamp.tm_year -= 1900;
  725|  1.74k|    timestamp.tm_mon--;
  726|       |
  727|  1.74k|    ctx->timestamp = mktime(&timestamp);
  728|  1.74k|    ctx->version = ctx->byte2unicode[version] - 'A';
  729|       |
  730|  2.48k|cleanup:
  731|  2.48k|    return retval;
  732|  1.74k|}
handle_variables:
  734|    403|readstat_error_t handle_variables(por_ctx_t *ctx) {
  735|    403|    readstat_error_t retval = READSTAT_OK;
  736|    403|    int i;
  737|    403|    int index_after_skipping = 0;
  738|  2.10k|    for (i=0; i<ctx->var_count; i++) {
  ------------------
  |  Branch (738:15): [True: 1.70k, False: 403]
  ------------------
  739|  1.70k|        char label_name_buf[256];
  740|  1.70k|        spss_varinfo_t *info = &ctx->varinfo[i];
  741|  1.70k|        info->index = i;
  742|       |
  743|  1.70k|        ctx->variables[i] = spss_init_variable_for_info(info, index_after_skipping, ctx->converter);
  744|       |
  745|  1.70k|        snprintf(label_name_buf, sizeof(label_name_buf), POR_LABEL_NAME_PREFIX "%d", info->labels_index);
  ------------------
  |  |   25|  1.70k|#define POR_LABEL_NAME_PREFIX   "labels"
  ------------------
  746|       |
  747|  1.70k|        int cb_retval = READSTAT_HANDLER_OK;
  ------------------
  |  |   22|  1.70k|#define READSTAT_HANDLER_OK             0
  ------------------
  748|       |
  749|  1.70k|        if (ctx->handle.variable) {
  ------------------
  |  Branch (749:13): [True: 1.70k, False: 0]
  ------------------
  750|  1.70k|            cb_retval = ctx->handle.variable(i, ctx->variables[i],
  751|  1.70k|                    info->labels_index == -1 ? NULL : label_name_buf,
  ------------------
  |  Branch (751:21): [True: 1.67k, False: 22]
  ------------------
  752|  1.70k|                    ctx->user_ctx);
  753|  1.70k|        }
  754|       |
  755|  1.70k|        if (cb_retval == READSTAT_HANDLER_ABORT) {
  ------------------
  |  |   23|  1.70k|#define READSTAT_HANDLER_ABORT          1
  ------------------
  |  Branch (755:13): [True: 0, False: 1.70k]
  ------------------
  756|      0|            retval = READSTAT_ERROR_USER_ABORT;
  757|      0|            goto cleanup;
  758|      0|        }
  759|       |
  760|  1.70k|        if (cb_retval == READSTAT_HANDLER_SKIP_VARIABLE) {
  ------------------
  |  |   24|  1.70k|#define READSTAT_HANDLER_SKIP_VARIABLE  2
  ------------------
  |  Branch (760:13): [True: 0, False: 1.70k]
  ------------------
  761|      0|            ctx->variables[i]->skip = 1;
  762|  1.70k|        } else {
  763|  1.70k|            index_after_skipping++;
  764|  1.70k|        }
  765|  1.70k|    }
  766|    403|    if (ctx->handle.fweight && ctx->fweight_name[0]) {
  ------------------
  |  Branch (766:9): [True: 403, False: 0]
  |  Branch (766:32): [True: 92, False: 311]
  ------------------
  767|    403|        for (i=0; i<ctx->var_count; i++) {
  ------------------
  |  Branch (767:19): [True: 314, False: 89]
  ------------------
  768|    314|            spss_varinfo_t *info = &ctx->varinfo[i];
  769|    314|            if (strcmp(info->name, ctx->fweight_name) == 0) {
  ------------------
  |  Branch (769:17): [True: 3, False: 311]
  ------------------
  770|      3|                if (ctx->handle.fweight(ctx->variables[i], ctx->user_ctx) != READSTAT_HANDLER_OK) {
  ------------------
  |  |   22|      3|#define READSTAT_HANDLER_OK             0
  ------------------
  |  Branch (770:21): [True: 0, False: 3]
  ------------------
  771|      0|                    retval = READSTAT_ERROR_USER_ABORT;
  772|      0|                    goto cleanup;
  773|      0|                }
  774|      3|                break;
  775|      3|            }
  776|    314|        }
  777|     92|    }
  778|    403|cleanup:
  779|    403|    return retval;
  780|    403|}
readstat_parse_por:
  782|  2.80k|readstat_error_t readstat_parse_por(readstat_parser_t *parser, const char *path, void *user_ctx) {
  783|  2.80k|    readstat_error_t retval = READSTAT_OK;
  784|  2.80k|    readstat_io_t *io = parser->io;
  785|  2.80k|    unsigned char reverse_lookup[256];
  786|  2.80k|    char vanity[5][40];
  787|  2.80k|    char error_buf[1024];
  788|       |
  789|  2.80k|    por_ctx_t *ctx = por_ctx_init();
  790|       |    
  791|  2.80k|    ctx->handle = parser->handlers;
  792|  2.80k|    ctx->user_ctx = user_ctx;
  793|  2.80k|    ctx->io = io;
  794|  2.80k|    ctx->row_limit = parser->row_limit;
  795|  2.80k|    if (parser->row_offset > 0)
  ------------------
  |  Branch (795:9): [True: 0, False: 2.80k]
  ------------------
  796|      0|        ctx->row_offset = parser->row_offset;
  797|       |
  798|  2.80k|    if (parser->output_encoding) {
  ------------------
  |  Branch (798:9): [True: 2.80k, False: 0]
  ------------------
  799|  2.80k|        if (strcmp(parser->output_encoding, "UTF-8") != 0)
  ------------------
  |  Branch (799:13): [True: 0, False: 2.80k]
  ------------------
  800|      0|            ctx->converter = iconv_open(parser->output_encoding, "UTF-8");
  801|       |
  802|  2.80k|        if (ctx->converter == (iconv_t)-1) {
  ------------------
  |  Branch (802:13): [True: 0, False: 2.80k]
  ------------------
  803|      0|            ctx->converter = NULL;
  804|      0|            retval = READSTAT_ERROR_UNSUPPORTED_CHARSET;
  805|      0|            goto cleanup;
  806|      0|        }
  807|  2.80k|    }
  808|       |    
  809|  2.80k|    if (io->open(path, io->io_ctx) == -1) {
  ------------------
  |  Branch (809:9): [True: 0, False: 2.80k]
  ------------------
  810|      0|        retval = READSTAT_ERROR_OPEN;
  811|      0|        goto cleanup;
  812|      0|    }
  813|       |
  814|  2.80k|    if ((ctx->file_size = io->seek(0, READSTAT_SEEK_END, io->io_ctx)) == -1) {
  ------------------
  |  Branch (814:9): [True: 0, False: 2.80k]
  ------------------
  815|      0|        retval = READSTAT_ERROR_SEEK;
  816|      0|        goto cleanup;
  817|      0|    }
  818|       |
  819|  2.80k|    if (io->seek(0, READSTAT_SEEK_SET, io->io_ctx) == -1) {
  ------------------
  |  Branch (819:9): [True: 0, False: 2.80k]
  ------------------
  820|      0|        retval = READSTAT_ERROR_SEEK;
  821|      0|        goto cleanup;
  822|      0|    }
  823|       |    
  824|  2.80k|    if (read_bytes(ctx, vanity, sizeof(vanity)) != sizeof(vanity)) {
  ------------------
  |  Branch (824:9): [True: 60, False: 2.74k]
  ------------------
  825|     60|        retval = READSTAT_ERROR_READ;
  826|     60|        goto cleanup;
  827|     60|    }
  828|       |
  829|  2.74k|    retval = readstat_convert(ctx->file_label, sizeof(ctx->file_label), vanity[1] + 20, 20, NULL);
  830|  2.74k|    if (retval != READSTAT_OK)
  ------------------
  |  Branch (830:9): [True: 0, False: 2.74k]
  ------------------
  831|      0|        goto cleanup;
  832|       |    
  833|  2.74k|    if (read_bytes(ctx, reverse_lookup, sizeof(reverse_lookup)) != sizeof(reverse_lookup)) {
  ------------------
  |  Branch (833:9): [True: 90, False: 2.65k]
  ------------------
  834|     90|        retval = READSTAT_ERROR_READ;
  835|     90|        goto cleanup;
  836|     90|    }
  837|       |    
  838|  2.65k|    ctx->space = reverse_lookup[126];
  839|       |
  840|  2.65k|    int i;
  841|       |
  842|       |    /* A byte that appears at several positions in the translation table
  843|       |     * keeps its first meaning, as in PSPP and R's foreign package. PSPP for
  844|       |     * instance maps the superscript digits (positions 167-176) to '0'-'9'
  845|       |     * as well, and last-writer-wins would turn every digit into a
  846|       |     * superscript. */
  847|   681k|    for (i=0; i<256; i++) {
  ------------------
  |  Branch (847:15): [True: 678k, False: 2.65k]
  ------------------
  848|   678k|        if (ctx->byte2unicode[reverse_lookup[i]])
  ------------------
  |  Branch (848:13): [True: 334k, False: 344k]
  ------------------
  849|   334k|            continue;
  850|   344k|        if (por_ascii_lookup[i]) {
  ------------------
  |  Branch (850:13): [True: 106k, False: 237k]
  ------------------
  851|   106k|            ctx->byte2unicode[reverse_lookup[i]] = por_ascii_lookup[i];
  852|   237k|        } else if (por_unicode_lookup[i]) {
  ------------------
  |  Branch (852:20): [True: 517, False: 237k]
  ------------------
  853|    517|            ctx->byte2unicode[reverse_lookup[i]] = por_unicode_lookup[i];
  854|    517|        }
  855|   344k|    }
  856|       |
  857|  2.65k|    ctx->byte2unicode[reverse_lookup[64]] = por_unicode_lookup[64];
  858|       |
  859|  2.65k|    unsigned char check[8];
  860|  2.65k|    char tr_check[8];
  861|       |    
  862|  2.65k|    if (read_bytes(ctx, check, sizeof(check)) != sizeof(check)) {
  ------------------
  |  Branch (862:9): [True: 32, False: 2.62k]
  ------------------
  863|     32|        retval = READSTAT_ERROR_READ;
  864|     32|        goto cleanup;
  865|     32|    }
  866|       |
  867|  2.62k|    ssize_t encoded_len;
  868|       |
  869|  2.62k|    if ((encoded_len = por_utf8_encode(check, sizeof(check), tr_check, sizeof(tr_check), ctx->byte2unicode)) == -1) {
  ------------------
  |  Branch (869:9): [True: 0, False: 2.62k]
  ------------------
  870|      0|        if (ctx->handle.error) {
  ------------------
  |  Branch (870:13): [True: 0, False: 0]
  ------------------
  871|      0|            snprintf(error_buf, sizeof(error_buf), "Error converting check string: %.*s", (int)sizeof(check), check);
  872|      0|            ctx->handle.error(error_buf, ctx->user_ctx);
  873|      0|        }
  874|      0|        retval = READSTAT_ERROR_CONVERT;
  875|      0|        goto cleanup;
  876|      0|    }
  877|       |
  878|  2.62k|    if (strncmp("SPSSPORT", tr_check, encoded_len) != 0) {
  ------------------
  |  Branch (878:9): [True: 138, False: 2.48k]
  ------------------
  879|    138|        retval = READSTAT_ERROR_PARSE;
  880|    138|        goto cleanup;
  881|    138|    }
  882|       |    
  883|  2.48k|    ctx->var_offset = -1;
  884|       |    
  885|  2.48k|    char string[256];
  886|       |
  887|  2.48k|    retval = read_version_and_timestamp(ctx);
  888|  2.48k|    if (retval != READSTAT_OK)
  ------------------
  |  Branch (888:9): [True: 733, False: 1.74k]
  ------------------
  889|    733|        goto cleanup;
  890|       |
  891|  33.9k|    while (1) {
  ------------------
  |  Branch (891:12): [True: 33.9k, Folded]
  ------------------
  892|  33.9k|        uint16_t tr_tag = read_tag(ctx);
  893|  33.9k|        switch (tr_tag) {
  894|    223|            case '1': /* product ID */
  ------------------
  |  Branch (894:13): [True: 223, False: 33.7k]
  ------------------
  895|    607|            case '2': /* author ID */
  ------------------
  |  Branch (895:13): [True: 384, False: 33.5k]
  ------------------
  896|  1.24k|            case '3': /* sub-product ID */
  ------------------
  |  Branch (896:13): [True: 636, False: 33.2k]
  ------------------
  897|  1.24k|                retval = read_string(ctx, string, sizeof(string));
  898|  1.24k|                break;
  899|  1.18k|            case '4': /* variable count */
  ------------------
  |  Branch (899:13): [True: 1.18k, False: 32.7k]
  ------------------
  900|  1.18k|                retval = read_variable_count_record(ctx);
  901|  1.18k|                break;
  902|    487|            case '5': /* precision */
  ------------------
  |  Branch (902:13): [True: 487, False: 33.4k]
  ------------------
  903|    487|                retval = read_precision_record(ctx);
  904|    487|                break;
  905|  1.25k|            case '6': /* case weight */
  ------------------
  |  Branch (905:13): [True: 1.25k, False: 32.6k]
  ------------------
  906|  1.25k|                retval = read_case_weight_record(ctx);
  907|  1.25k|                break;
  908|  8.23k|            case '7': /* variable */
  ------------------
  |  Branch (908:13): [True: 8.23k, False: 25.6k]
  ------------------
  909|  8.23k|                retval = read_variable_record(ctx);
  910|  8.23k|                break;
  911|    867|            case '8': /* missing value */
  ------------------
  |  Branch (911:13): [True: 867, False: 33.0k]
  ------------------
  912|    867|                retval = read_missing_value_record(ctx);
  913|    867|                break;
  914|  3.97k|            case 'B': /* missing value range */
  ------------------
  |  Branch (914:13): [True: 3.97k, False: 29.9k]
  ------------------
  915|  3.97k|                retval = read_missing_value_range_record(ctx);
  916|  3.97k|                break;
  917|  2.15k|            case '9': /* LO THRU x */
  ------------------
  |  Branch (917:13): [True: 2.15k, False: 31.7k]
  ------------------
  918|  2.15k|                retval = read_missing_value_lo_range_record(ctx);
  919|  2.15k|                break;
  920|  2.12k|            case 'A': /* x THRU HI */
  ------------------
  |  Branch (920:13): [True: 2.12k, False: 31.8k]
  ------------------
  921|  2.12k|                retval = read_missing_value_hi_range_record(ctx);
  922|  2.12k|                break;
  923|  1.16k|            case 'C': /* variable label */
  ------------------
  |  Branch (923:13): [True: 1.16k, False: 32.7k]
  ------------------
  924|  1.16k|                retval = read_variable_label_record(ctx);
  925|  1.16k|                break;
  926|  9.78k|            case 'D': /* value label */
  ------------------
  |  Branch (926:13): [True: 9.78k, False: 24.1k]
  ------------------
  927|  9.78k|                retval = read_value_label_record(ctx);
  928|  9.78k|                break;
  929|    707|            case 'E': /* document record */
  ------------------
  |  Branch (929:13): [True: 707, False: 33.2k]
  ------------------
  930|    707|                retval = read_document_record(ctx);
  931|    707|                break;
  932|    434|            case 'F': /* file data */
  ------------------
  |  Branch (932:13): [True: 434, False: 33.4k]
  ------------------
  933|    434|                if (ctx->var_offset != ctx->var_count - 1) {
  ------------------
  |  Branch (933:21): [True: 31, False: 403]
  ------------------
  934|     31|                    retval = READSTAT_ERROR_COLUMN_COUNT_MISMATCH;
  935|     31|                    goto cleanup;
  936|     31|                }
  937|       |
  938|    403|                retval = handle_variables(ctx);
  939|    403|                if (retval != READSTAT_OK)
  ------------------
  |  Branch (939:21): [True: 0, False: 403]
  ------------------
  940|      0|                    goto cleanup;
  941|       |
  942|    403|                if (ctx->handle.value) {
  ------------------
  |  Branch (942:21): [True: 403, False: 0]
  ------------------
  943|    403|                    retval = read_por_file_data(ctx);
  944|    403|                }
  945|    403|                goto cleanup;
  946|    322|            default:
  ------------------
  |  Branch (946:13): [True: 322, False: 33.6k]
  ------------------
  947|    322|                retval = READSTAT_ERROR_PARSE;
  948|    322|                goto cleanup;
  949|  33.9k|        }
  950|  33.1k|        if (retval != READSTAT_OK)
  ------------------
  |  Branch (950:13): [True: 993, False: 32.1k]
  ------------------
  951|    993|            break;
  952|  33.1k|    }
  953|       |
  954|  2.80k|cleanup:
  955|  2.80k|    io->close(io->io_ctx);
  956|  2.80k|    por_ctx_free(ctx);
  957|       |    
  958|  2.80k|    return retval;
  959|  1.74k|}
readstat_por_read.c:read_bytes:
   49|  4.46M|static ssize_t read_bytes(por_ctx_t *ctx, void *dst, size_t len) {
   50|  4.46M|    char *dst_pos = (char *)dst;
   51|  4.46M|    readstat_io_t *io = ctx->io;
   52|  4.46M|    char byte;
   53|       |
   54|  11.4M|    while (dst_pos < (char *)dst + len) {
  ------------------
  |  Branch (54:12): [True: 6.99M, False: 4.46M]
  ------------------
   55|  6.99M|        if (ctx->num_spaces) {
  ------------------
  |  Branch (55:13): [True: 3.02M, False: 3.97M]
  ------------------
   56|  3.02M|            *dst_pos++ = ctx->space;
   57|  3.02M|            ctx->num_spaces--;
   58|  3.02M|            continue;
   59|  3.02M|        }
   60|  3.97M|        ssize_t bytes_read = io->read(&byte, 1, io->io_ctx);
   61|  3.97M|        if (bytes_read == 0) {
  ------------------
  |  Branch (61:13): [True: 1.88k, False: 3.96M]
  ------------------
   62|  1.88k|            break;
   63|  1.88k|        }
   64|  3.96M|        if (bytes_read == -1) {
  ------------------
  |  Branch (64:13): [True: 0, False: 3.96M]
  ------------------
   65|      0|            return -1;
   66|      0|        }
   67|       |        /* Like PSPP: ignore carriage returns entirely; a line feed ends the
   68|       |         * line, and a line shorter than 80 characters is padded with spaces.
   69|       |         * Lines longer than 80 characters are read as-is. */
   70|  3.96M|        if (byte == '\r') {
  ------------------
  |  Branch (70:13): [True: 2.72k, False: 3.96M]
  ------------------
   71|  2.72k|            continue;
   72|  3.96M|        } else if (byte == '\n') {
  ------------------
  |  Branch (72:20): [True: 48.0k, False: 3.91M]
  ------------------
   73|  48.0k|            if (ctx->pos < POR_LINE_LENGTH)
  ------------------
  |  |   24|  48.0k|#define POR_LINE_LENGTH         80
  ------------------
  |  Branch (73:17): [True: 46.1k, False: 1.96k]
  ------------------
   74|  46.1k|                ctx->num_spaces = POR_LINE_LENGTH - ctx->pos;
  ------------------
  |  |   24|  46.1k|#define POR_LINE_LENGTH         80
  ------------------
   75|  48.0k|            ctx->pos = 0;
   76|  48.0k|            continue;
   77|  48.0k|        }
   78|  3.91M|        *dst_pos++ = byte;
   79|  3.91M|        ctx->pos++;
   80|  3.91M|    }
   81|       |    
   82|  4.46M|    return (int)(dst_pos - (char *)dst);
   83|  4.46M|}
readstat_por_read.c:read_string:
  248|  71.7k|static readstat_error_t read_string(por_ctx_t *ctx, char *data, size_t len) {
  249|  71.7k|    int finished = 0;
  250|  71.7k|    readstat_error_t retval = maybe_read_string(ctx, data, len, &finished);
  251|  71.7k|    if (retval == READSTAT_OK && finished) {
  ------------------
  |  Branch (251:9): [True: 70.7k, False: 1.02k]
  |  Branch (251:34): [True: 9, False: 70.7k]
  ------------------
  252|      9|        return READSTAT_ERROR_PARSE;
  253|      9|    }
  254|  71.7k|    return retval;
  255|  71.7k|}
readstat_por_read.c:maybe_read_string:
  196|  72.1k|static readstat_error_t maybe_read_string(por_ctx_t *ctx, char *data, size_t len, int *out_finished) {
  197|  72.1k|    readstat_error_t retval = READSTAT_OK;
  198|  72.1k|    double value;
  199|  72.1k|    int finished = 0;
  200|  72.1k|    char error_buf[1024];
  201|  72.1k|    size_t string_length = 0;
  202|  72.1k|    retval = maybe_read_double(ctx, &value, &finished);
  203|  72.1k|    if (retval != READSTAT_OK || finished) {
  ------------------
  |  Branch (203:9): [True: 825, False: 71.3k]
  |  Branch (203:34): [True: 12, False: 71.3k]
  ------------------
  204|    837|        if (out_finished)
  ------------------
  |  Branch (204:13): [True: 837, False: 0]
  ------------------
  205|    837|            *out_finished = finished;
  206|       |
  207|    837|        return retval;
  208|    837|    }
  209|       |    
  210|  71.3k|    if (value < 0 || value > MAX_STRING_LENGTH || isnan(value)) {
  ------------------
  |  |   31|   142k|#define MAX_STRING_LENGTH   20000
  ------------------
  |  Branch (210:9): [True: 1, False: 71.3k]
  |  Branch (210:22): [True: 262, False: 71.0k]
  |  Branch (210:51): [True: 2, False: 71.0k]
  ------------------
  211|    265|        retval = READSTAT_ERROR_PARSE;
  212|    265|        goto cleanup;
  213|    265|    }
  214|  71.0k|    string_length = (size_t)value;
  215|       |    
  216|  71.0k|    if (string_length > ctx->string_buffer_len) {
  ------------------
  |  Branch (216:9): [True: 2.38k, False: 68.6k]
  ------------------
  217|  2.38k|        unsigned char *new_string_buf = realloc(ctx->string_buffer, string_length);
  218|  2.38k|        if (new_string_buf == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; }
  ------------------
  |  Branch (218:13): [True: 0, False: 2.38k]
  ------------------
  219|  2.38k|        ctx->string_buffer = new_string_buf;
  220|  2.38k|        ctx->string_buffer_len = string_length;
  221|  2.38k|        memset(ctx->string_buffer, 0, ctx->string_buffer_len);
  222|  2.38k|    }
  223|       |    
  224|  71.0k|    if (read_bytes(ctx, ctx->string_buffer, string_length) != string_length) {
  ------------------
  |  Branch (224:9): [True: 115, False: 70.9k]
  ------------------
  225|    115|        retval = READSTAT_ERROR_READ;
  226|    115|        goto cleanup;
  227|    115|    }
  228|  70.9k|    size_t bytes_encoded = por_utf8_encode(ctx->string_buffer, string_length, 
  229|  70.9k|            data, len - 1, ctx->byte2unicode);
  230|  70.9k|    if (bytes_encoded == -1) {
  ------------------
  |  Branch (230:9): [True: 0, False: 70.9k]
  ------------------
  231|      0|        if (ctx->handle.error) {
  ------------------
  |  Branch (231:13): [True: 0, False: 0]
  ------------------
  232|      0|            snprintf(error_buf, sizeof(error_buf), "Error converting string: %.*s", 
  233|      0|                    (int)string_length, ctx->string_buffer);
  234|      0|            ctx->handle.error(error_buf, ctx->user_ctx);
  235|      0|        }
  236|      0|        retval = READSTAT_ERROR_CONVERT;
  237|      0|        goto cleanup;
  238|      0|    }
  239|       |    
  240|  70.9k|    data[bytes_encoded] = '\0';
  241|  70.9k|    if (out_finished)
  ------------------
  |  Branch (241:9): [True: 70.9k, False: 0]
  ------------------
  242|  70.9k|        *out_finished = 0;
  243|       |
  244|  71.3k|cleanup:
  245|  71.3k|    return retval;
  246|  70.9k|}
readstat_por_read.c:maybe_read_double:
  176|   357k|static readstat_error_t maybe_read_double(por_ctx_t *ctx, double *out_double, int *out_finished) {
  177|   357k|    unsigned char peek;
  178|   357k|    size_t bytes_read = read_bytes(ctx, &peek, 1);
  179|   357k|    if (bytes_read != 1)
  ------------------
  |  Branch (179:9): [True: 606, False: 356k]
  ------------------
  180|    606|        return READSTAT_ERROR_PARSE;
  181|       |
  182|   356k|    if (ctx->byte2unicode[peek] == 'Z') {
  ------------------
  |  Branch (182:9): [True: 15, False: 356k]
  ------------------
  183|     15|        if (out_double)
  ------------------
  |  Branch (183:13): [True: 15, False: 0]
  ------------------
  184|     15|            *out_double = NAN;
  185|     15|        if (out_finished)
  ------------------
  |  Branch (185:13): [True: 15, False: 0]
  ------------------
  186|     15|            *out_finished = 1;
  187|     15|        return READSTAT_OK;
  188|     15|    }
  189|       |
  190|   356k|    if (out_finished)
  ------------------
  |  Branch (190:9): [True: 356k, False: 0]
  ------------------
  191|   356k|        *out_finished = 0;
  192|       |
  193|   356k|    return read_double_with_peek(ctx, out_double, peek);
  194|   356k|}
readstat_por_read.c:read_double_with_peek:
   94|   489k|        unsigned char peek) {
   95|   489k|    readstat_error_t retval = READSTAT_OK;
   96|   489k|    double value = NAN;
   97|   489k|    unsigned char buffer[100];
   98|   489k|    char utf8_buffer[300];
   99|   489k|    char error_buf[1024];
  100|   489k|    int64_t len = 0;
  101|   489k|    ssize_t bytes_read = 0;
  102|       |
  103|   489k|    buffer[0] = peek;
  104|       |
  105|   489k|    bytes_read = read_bytes(ctx, &buffer[1], 1);
  106|   489k|    if (bytes_read != 1)
  ------------------
  |  Branch (106:9): [True: 85, False: 489k]
  ------------------
  107|     85|        return READSTAT_ERROR_PARSE;
  108|       |
  109|   489k|    if (ctx->byte2unicode[buffer[0]] == '*' && 
  ------------------
  |  Branch (109:9): [True: 252, False: 488k]
  ------------------
  110|    252|            ctx->byte2unicode[buffer[1]] == '.') {
  ------------------
  |  Branch (110:13): [True: 242, False: 10]
  ------------------
  111|    242|        if (out_double)
  ------------------
  |  Branch (111:13): [True: 242, False: 0]
  ------------------
  112|    242|            *out_double = NAN;
  113|    242|        return READSTAT_OK;
  114|    242|    }
  115|   488k|    int64_t i=2;
  116|  3.86M|    while (i<sizeof(buffer) && ctx->byte2unicode[buffer[i-1]] != '/') {
  ------------------
  |  Branch (116:12): [True: 3.86M, False: 20]
  |  Branch (116:32): [True: 3.37M, False: 488k]
  ------------------
  117|  3.37M|        bytes_read = read_bytes(ctx, &buffer[i], 1);
  118|  3.37M|        if (bytes_read != 1)
  ------------------
  |  Branch (118:13): [True: 370, False: 3.37M]
  ------------------
  119|    370|            return READSTAT_ERROR_PARSE;
  120|  3.37M|        i++;
  121|  3.37M|    }
  122|       |
  123|   488k|    if (i == sizeof(buffer)) {
  ------------------
  |  Branch (123:9): [True: 20, False: 488k]
  ------------------
  124|     20|        return READSTAT_ERROR_PARSE;
  125|     20|    }
  126|       |
  127|   488k|    len = por_utf8_encode(buffer, i, utf8_buffer, sizeof(utf8_buffer), ctx->byte2unicode);
  128|   488k|    if (len == -1) {
  ------------------
  |  Branch (128:9): [True: 0, False: 488k]
  ------------------
  129|      0|        if (ctx->handle.error) {
  ------------------
  |  Branch (129:13): [True: 0, False: 0]
  ------------------
  130|      0|            snprintf(error_buf, sizeof(error_buf), "Error converting double string (length=%" PRId64 "): %.*s", 
  131|      0|                    i, (int)i, buffer);
  132|      0|            ctx->handle.error(error_buf, ctx->user_ctx);
  133|      0|        }
  134|      0|        retval = READSTAT_ERROR_CONVERT;
  135|      0|        goto cleanup;
  136|      0|    }
  137|       |    
  138|   488k|    bytes_read = readstat_por_parse_double(utf8_buffer, len, &value, ctx->handle.error, ctx->user_ctx);
  139|   488k|    if (bytes_read == -1) {
  ------------------
  |  Branch (139:9): [True: 98, False: 488k]
  ------------------
  140|     98|        if (ctx->handle.error) {
  ------------------
  |  Branch (140:13): [True: 0, False: 98]
  ------------------
  141|      0|            snprintf(error_buf, sizeof(error_buf), "Error parsing double string (length=%" PRId64 "): %.*s [%.*s]",
  142|      0|                    len, (int)len, utf8_buffer, (int)i, buffer);
  143|      0|            ctx->handle.error(error_buf, ctx->user_ctx);
  144|      0|        }
  145|     98|        retval = READSTAT_ERROR_PARSE;
  146|     98|        goto cleanup;
  147|     98|    }
  148|       |    
  149|   488k|cleanup:
  150|   488k|    if (out_double)
  ------------------
  |  Branch (150:9): [True: 488k, False: 0]
  ------------------
  151|   488k|        *out_double = value;
  152|       |
  153|   488k|    return retval;
  154|   488k|}
readstat_por_read.c:read_tag:
   85|  33.9k|static uint16_t read_tag(por_ctx_t *ctx) {
   86|  33.9k|    unsigned char tag;
   87|  33.9k|    if (read_bytes(ctx, &tag, 1) != 1) {
  ------------------
  |  Branch (87:9): [True: 244, False: 33.6k]
  ------------------
   88|    244|        return -1;
   89|    244|    }
   90|  33.6k|    return ctx->byte2unicode[tag];
   91|  33.9k|}
readstat_por_read.c:read_variable_count_record:
  257|  1.18k|static readstat_error_t read_variable_count_record(por_ctx_t *ctx) {
  258|  1.18k|    int value;
  259|  1.18k|    readstat_error_t retval = READSTAT_OK;
  260|  1.18k|    if (ctx->var_count) {
  ------------------
  |  Branch (260:9): [True: 15, False: 1.16k]
  ------------------
  261|     15|        retval = READSTAT_ERROR_PARSE;
  262|     15|        goto cleanup;
  263|     15|    }
  264|  1.16k|    if ((retval = read_integer_in_range(ctx, 0, MAX_VARS, &value)) != READSTAT_OK) {
  ------------------
  |  |   35|  1.16k|#define MAX_VARS    1000000
  ------------------
  |  Branch (264:9): [True: 13, False: 1.15k]
  ------------------
  265|     13|        goto cleanup;
  266|     13|    }
  267|  1.15k|    ctx->var_count = value;
  268|  1.15k|    ctx->variables = readstat_calloc(ctx->var_count, sizeof(readstat_variable_t *));
  269|  1.15k|    ctx->varinfo = readstat_calloc(ctx->var_count, sizeof(spss_varinfo_t));
  270|  1.15k|    if (ctx->variables == NULL || ctx->varinfo == NULL) {
  ------------------
  |  Branch (270:9): [True: 2, False: 1.15k]
  |  Branch (270:35): [True: 6, False: 1.14k]
  ------------------
  271|      8|        retval = READSTAT_ERROR_MALLOC;
  272|      8|        goto cleanup;
  273|      8|    }
  274|       |
  275|  1.14k|    if (ctx->handle.metadata) {
  ------------------
  |  Branch (275:9): [True: 1.14k, False: 0]
  ------------------
  276|  1.14k|        readstat_metadata_t metadata = {
  277|  1.14k|            .row_count = -1,
  278|  1.14k|            .var_count = ctx->var_count,
  279|  1.14k|            .creation_time = ctx->timestamp,
  280|  1.14k|            .modified_time = ctx->timestamp,
  281|  1.14k|            .file_format_version = ctx->version,
  282|  1.14k|            .file_label = ctx->file_label
  283|  1.14k|        };
  284|  1.14k|        if (ctx->handle.metadata(&metadata, ctx->user_ctx) != READSTAT_HANDLER_OK) {
  ------------------
  |  |   22|  1.14k|#define READSTAT_HANDLER_OK             0
  ------------------
  |  Branch (284:13): [True: 0, False: 1.14k]
  ------------------
  285|      0|            retval = READSTAT_ERROR_USER_ABORT;
  286|      0|            goto cleanup;
  287|      0|        }
  288|  1.14k|    }
  289|       |        
  290|  1.18k|cleanup:
  291|  1.18k|    return retval;
  292|  1.14k|}
readstat_por_read.c:read_integer_in_range:
  164|  78.2k|static readstat_error_t read_integer_in_range(por_ctx_t *ctx, int min, int max, int *out_integer) {
  165|  78.2k|    double dval = NAN;
  166|  78.2k|    readstat_error_t retval = read_double(ctx, &dval);
  167|  78.2k|    if (retval != READSTAT_OK)
  ------------------
  |  Branch (167:9): [True: 274, False: 77.9k]
  ------------------
  168|    274|        return retval;
  169|  77.9k|    if (isnan(dval) || dval < min || dval > max)
  ------------------
  |  Branch (169:9): [True: 11, False: 77.9k]
  |  Branch (169:24): [True: 9, False: 77.9k]
  |  Branch (169:38): [True: 16, False: 77.9k]
  ------------------
  170|     36|        return READSTAT_ERROR_PARSE;
  171|  77.9k|    if (out_integer)
  ------------------
  |  Branch (171:9): [True: 77.9k, False: 0]
  ------------------
  172|  77.9k|        *out_integer = (int)dval;
  173|  77.9k|    return READSTAT_OK;
  174|  77.9k|}
readstat_por_read.c:read_double:
  156|   132k|static readstat_error_t read_double(por_ctx_t *ctx, double *out_double) {
  157|   132k|    unsigned char peek;
  158|   132k|    size_t bytes_read = read_bytes(ctx, &peek, 1);
  159|   132k|    if (bytes_read != 1)
  ------------------
  |  Branch (159:9): [True: 267, False: 132k]
  ------------------
  160|    267|        return READSTAT_ERROR_PARSE;
  161|   132k|    return read_double_with_peek(ctx, out_double, peek);
  162|   132k|}
readstat_por_read.c:read_precision_record:
  294|    487|static readstat_error_t read_precision_record(por_ctx_t *ctx) {
  295|    487|    int precision = 0;
  296|    487|    readstat_error_t error = read_integer_in_range(ctx, 0, 100, &precision);
  297|    487|    if (error == READSTAT_OK)
  ------------------
  |  Branch (297:9): [True: 465, False: 22]
  ------------------
  298|    465|        ctx->base30_precision = precision;
  299|    487|    return error;
  300|    487|}
readstat_por_read.c:read_case_weight_record:
  302|  1.25k|static readstat_error_t read_case_weight_record(por_ctx_t *ctx) {
  303|  1.25k|    return read_string(ctx, ctx->fweight_name, sizeof(ctx->fweight_name));
  304|  1.25k|}
readstat_por_read.c:read_variable_record:
  306|  8.23k|static readstat_error_t read_variable_record(por_ctx_t *ctx) {
  307|  8.23k|    readstat_error_t retval = READSTAT_OK;
  308|  8.23k|    int value;
  309|  8.23k|    int i;
  310|  8.23k|    spss_varinfo_t *varinfo = NULL;
  311|  8.23k|    spss_format_t *formats[2];
  312|       |
  313|  8.23k|    ctx->var_offset++;
  314|       |
  315|  8.23k|    if (ctx->var_offset == ctx->var_count) {
  ------------------
  |  Branch (315:9): [True: 3, False: 8.22k]
  ------------------
  316|      3|        retval = READSTAT_ERROR_PARSE;
  317|      3|        goto cleanup;
  318|      3|    }
  319|       |
  320|  8.22k|    varinfo = &ctx->varinfo[ctx->var_offset];
  321|  8.22k|    formats[0] = &varinfo->print_format;
  322|  8.22k|    formats[1] = &varinfo->write_format;
  323|       |
  324|  8.22k|    varinfo->labels_index = -1;
  325|  8.22k|    if ((retval = read_integer_in_range(ctx, 0, MAX_WIDTH, &value)) != READSTAT_OK) {
  ------------------
  |  |   36|  8.22k|#define MAX_WIDTH   1000000
  ------------------
  |  Branch (325:9): [True: 22, False: 8.20k]
  ------------------
  326|     22|        goto cleanup;
  327|     22|    }
  328|  8.20k|    varinfo->width = value;
  329|  8.20k|    if (varinfo->width == 0) {
  ------------------
  |  Branch (329:9): [True: 3.39k, False: 4.81k]
  ------------------
  330|  3.39k|        varinfo->type = READSTAT_TYPE_DOUBLE;
  331|  3.39k|        varinfo->width = 1; /* one eight-byte slot, as in SAV files */
  332|  4.81k|    } else {
  333|  4.81k|        varinfo->type = READSTAT_TYPE_STRING;
  334|       |        /* The declared width is the string length in characters */
  335|  4.81k|        varinfo->string_length = value;
  336|  4.81k|    }
  337|  8.20k|    if ((retval = read_string(ctx, varinfo->name, sizeof(varinfo->name))) != READSTAT_OK) {
  ------------------
  |  Branch (337:9): [True: 36, False: 8.17k]
  ------------------
  338|     36|        goto cleanup;
  339|     36|    }
  340|  8.17k|    ck_str_hash_insert(varinfo->name, varinfo, ctx->var_dict);
  341|       |
  342|  24.1k|    for (i=0; i<sizeof(formats)/sizeof(spss_format_t *); i++) {
  ------------------
  |  Branch (342:15): [True: 16.1k, False: 8.00k]
  ------------------
  343|  16.1k|        spss_format_t *format = formats[i];
  344|  16.1k|        if ((retval = read_integer_in_range(ctx, 0, MAX_FORMAT_TYPE, &value)) != READSTAT_OK) {
  ------------------
  |  |   28|  16.1k|#define MAX_FORMAT_TYPE     (POR_FORMAT_SHIFT+SPSS_FORMAT_TYPE_YMDHMS)
  |  |  ------------------
  |  |  |  |   27|  16.1k|#define POR_FORMAT_SHIFT     82
  |  |  ------------------
  |  |               #define MAX_FORMAT_TYPE     (POR_FORMAT_SHIFT+SPSS_FORMAT_TYPE_YMDHMS)
  |  |  ------------------
  |  |  |  |   38|  16.1k|#define SPSS_FORMAT_TYPE_YMDHMS   41
  |  |  ------------------
  ------------------
  |  Branch (344:13): [True: 109, False: 16.0k]
  ------------------
  345|    109|            goto cleanup;
  346|    109|        }
  347|  16.0k|        if (value > POR_FORMAT_SHIFT) {
  ------------------
  |  |   27|  16.0k|#define POR_FORMAT_SHIFT     82
  ------------------
  |  Branch (347:13): [True: 642, False: 15.4k]
  ------------------
  348|       |            // Some files in the wild have their format types shifted by 82 for date/time values
  349|       |            // I have no idea why, but see test files linked from:
  350|       |            // https://github.com/WizardMac/ReadStat/issues/158
  351|    642|            format->type = value - POR_FORMAT_SHIFT;
  ------------------
  |  |   27|    642|#define POR_FORMAT_SHIFT     82
  ------------------
  352|  15.4k|        } else {
  353|  15.4k|            format->type = value;
  354|  15.4k|        }
  355|       |
  356|  16.0k|        if ((retval = read_integer_in_range(ctx, 0, MAX_FORMAT_WIDTH, &value)) != READSTAT_OK) {
  ------------------
  |  |   29|  16.0k|#define MAX_FORMAT_WIDTH    20000
  ------------------
  |  Branch (356:13): [True: 39, False: 16.0k]
  ------------------
  357|     39|            goto cleanup;
  358|     39|        }
  359|  16.0k|        format->width = value;
  360|       |
  361|  16.0k|        if ((retval = read_integer_in_range(ctx, 0, MAX_FORMAT_DECIMALS, &value)) != READSTAT_OK) {
  ------------------
  |  |   30|  16.0k|#define MAX_FORMAT_DECIMALS   100
  ------------------
  |  Branch (361:13): [True: 20, False: 16.0k]
  ------------------
  362|     20|            goto cleanup;
  363|     20|        }
  364|  16.0k|        format->decimal_places = value;
  365|  16.0k|    }
  366|       |
  367|  8.23k|cleanup:
  368|  8.23k|    return retval;
  369|  8.17k|}
readstat_por_read.c:read_missing_value_record:
  402|    867|static readstat_error_t read_missing_value_record(por_ctx_t *ctx) {
  403|    867|    readstat_error_t retval = READSTAT_OK;
  404|    867|    spss_varinfo_t *varinfo = NULL;
  405|       |
  406|    867|    if (ctx->var_offset < 0 || ctx->var_offset >= ctx->var_count) {
  ------------------
  |  Branch (406:9): [True: 3, False: 864]
  |  Branch (406:32): [True: 0, False: 864]
  ------------------
  407|      3|        retval = READSTAT_ERROR_PARSE;
  408|      3|        goto cleanup;
  409|      3|    }
  410|    864|    varinfo = &ctx->varinfo[ctx->var_offset];
  411|       |
  412|    864|    if (varinfo->n_missing_values >= 3) {
  ------------------
  |  Branch (412:9): [True: 5, False: 859]
  ------------------
  413|      5|        retval = READSTAT_ERROR_PARSE;
  414|      5|        goto cleanup;
  415|      5|    }
  416|    859|    if (varinfo->type == READSTAT_TYPE_DOUBLE) {
  ------------------
  |  Branch (416:9): [True: 602, False: 257]
  ------------------
  417|    602|        if ((retval = read_double(ctx, &varinfo->missing_double_values[varinfo->n_missing_values])) != READSTAT_OK) {
  ------------------
  |  Branch (417:13): [True: 14, False: 588]
  ------------------
  418|     14|            goto cleanup;
  419|     14|        }
  420|    602|    } else {
  421|    257|        if ((retval = read_missing_string_value(ctx, varinfo, varinfo->n_missing_values)) != READSTAT_OK) {
  ------------------
  |  Branch (421:13): [True: 8, False: 249]
  ------------------
  422|      8|            goto cleanup;
  423|      8|        }
  424|    257|    }
  425|    837|    varinfo->n_missing_values++;
  426|       |
  427|    867|cleanup:
  428|    867|    return retval;
  429|    837|}
readstat_por_read.c:read_missing_string_value:
  397|  2.53k|static readstat_error_t read_missing_string_value(por_ctx_t *ctx, spss_varinfo_t *varinfo, int index) {
  398|  2.53k|    return read_converted_string(ctx, varinfo->missing_string_values[index],
  399|  2.53k|            sizeof(varinfo->missing_string_values[index]));
  400|  2.53k|}
readstat_por_read.c:read_converted_string:
  375|  47.9k|static readstat_error_t read_converted_string(por_ctx_t *ctx, char *dst, size_t dst_len) {
  376|  47.9k|    readstat_error_t retval = READSTAT_OK;
  377|  47.9k|    char string[POR_STRING_BUFFER_SIZE];
  378|  47.9k|    size_t len = 0;
  379|       |
  380|  47.9k|    if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK)
  ------------------
  |  Branch (380:9): [True: 192, False: 47.7k]
  ------------------
  381|    192|        goto cleanup;
  382|       |
  383|  47.7k|    len = strlen(string);
  384|  49.4k|    while (len > 0 && string[len-1] == ' ')
  ------------------
  |  Branch (384:12): [True: 45.4k, False: 4.06k]
  |  Branch (384:23): [True: 1.71k, False: 43.7k]
  ------------------
  385|  1.71k|        len--;
  386|  47.7k|    if (len + 1 > dst_len) {
  ------------------
  |  Branch (386:9): [True: 911, False: 46.8k]
  ------------------
  387|    911|        len = dst_len - 1;
  388|  1.27k|        while (len > 0 && (string[len] & 0xC0) == 0x80)
  ------------------
  |  Branch (388:16): [True: 1.27k, False: 0]
  |  Branch (388:27): [True: 362, False: 911]
  ------------------
  389|    362|            len--;
  390|    911|    }
  391|  47.7k|    retval = readstat_convert(dst, dst_len, string, len, ctx->converter);
  392|       |
  393|  47.9k|cleanup:
  394|  47.9k|    return retval;
  395|  47.7k|}
readstat_por_read.c:read_missing_value_range_record:
  431|  3.97k|static readstat_error_t read_missing_value_range_record(por_ctx_t *ctx) {
  432|  3.97k|    readstat_error_t retval = READSTAT_OK;
  433|  3.97k|    spss_varinfo_t *varinfo = NULL;
  434|       |
  435|  3.97k|    if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) {
  ------------------
  |  Branch (435:9): [True: 1, False: 3.97k]
  |  Branch (435:32): [True: 0, False: 3.97k]
  ------------------
  436|      1|        retval = READSTAT_ERROR_PARSE;
  437|      1|        goto cleanup;
  438|      1|    }
  439|  3.97k|    varinfo = &ctx->varinfo[ctx->var_offset];
  440|       |
  441|  3.97k|    varinfo->missing_range = 1;
  442|  3.97k|    varinfo->n_missing_values = 2;
  443|  3.97k|    if (varinfo->type == READSTAT_TYPE_DOUBLE) {
  ------------------
  |  Branch (443:9): [True: 3.41k, False: 560]
  ------------------
  444|  3.41k|        if ((retval = read_double(ctx, &varinfo->missing_double_values[0])) != READSTAT_OK) {
  ------------------
  |  Branch (444:13): [True: 17, False: 3.39k]
  ------------------
  445|     17|            goto cleanup;
  446|     17|        }
  447|  3.39k|        if ((retval = read_double(ctx, &varinfo->missing_double_values[1])) != READSTAT_OK) {
  ------------------
  |  Branch (447:13): [True: 19, False: 3.38k]
  ------------------
  448|     19|            goto cleanup;
  449|     19|        }
  450|  3.39k|    } else {
  451|    560|        if ((retval = read_missing_string_value(ctx, varinfo, 0)) != READSTAT_OK) {
  ------------------
  |  Branch (451:13): [True: 12, False: 548]
  ------------------
  452|     12|            goto cleanup;
  453|     12|        }
  454|    548|        if ((retval = read_missing_string_value(ctx, varinfo, 1)) != READSTAT_OK) {
  ------------------
  |  Branch (454:13): [True: 20, False: 528]
  ------------------
  455|     20|            goto cleanup;
  456|     20|        }
  457|    548|    }
  458|  3.97k|cleanup:
  459|  3.97k|    return retval;
  460|  3.97k|}
readstat_por_read.c:read_missing_value_lo_range_record:
  462|  2.15k|static readstat_error_t read_missing_value_lo_range_record(por_ctx_t *ctx) {
  463|  2.15k|    readstat_error_t retval = READSTAT_OK;
  464|  2.15k|    spss_varinfo_t *varinfo = NULL;
  465|       |
  466|  2.15k|    if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) {
  ------------------
  |  Branch (466:9): [True: 1, False: 2.15k]
  |  Branch (466:32): [True: 0, False: 2.15k]
  ------------------
  467|      1|        retval = READSTAT_ERROR_PARSE;
  468|      1|        goto cleanup;
  469|      1|    }
  470|  2.15k|    varinfo = &ctx->varinfo[ctx->var_offset];
  471|       |
  472|  2.15k|    varinfo->missing_range = 1;
  473|  2.15k|    varinfo->n_missing_values = 2;
  474|  2.15k|    if (varinfo->type == READSTAT_TYPE_DOUBLE) {
  ------------------
  |  Branch (474:9): [True: 1.92k, False: 226]
  ------------------
  475|  1.92k|        varinfo->missing_double_values[0] = -HUGE_VAL;
  476|  1.92k|        if ((retval = read_double(ctx, &varinfo->missing_double_values[1])) != READSTAT_OK) {
  ------------------
  |  Branch (476:13): [True: 10, False: 1.91k]
  ------------------
  477|     10|            goto cleanup;
  478|     10|        }
  479|  1.92k|    } else {
  480|    226|        varinfo->missing_string_values[0][0] = '\0';
  481|    226|        if ((retval = read_missing_string_value(ctx, varinfo, 1)) != READSTAT_OK) {
  ------------------
  |  Branch (481:13): [True: 14, False: 212]
  ------------------
  482|     14|            goto cleanup;
  483|     14|        }
  484|    226|    }
  485|  2.15k|cleanup:
  486|  2.15k|    return retval;
  487|  2.15k|}
readstat_por_read.c:read_missing_value_hi_range_record:
  489|  2.12k|static readstat_error_t read_missing_value_hi_range_record(por_ctx_t *ctx) {
  490|  2.12k|    readstat_error_t retval = READSTAT_OK;
  491|  2.12k|    spss_varinfo_t *varinfo = NULL;
  492|       |
  493|  2.12k|    if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) {
  ------------------
  |  Branch (493:9): [True: 1, False: 2.12k]
  |  Branch (493:32): [True: 0, False: 2.12k]
  ------------------
  494|      1|        retval = READSTAT_ERROR_PARSE;
  495|      1|        goto cleanup;
  496|      1|    }
  497|  2.12k|    varinfo = &ctx->varinfo[ctx->var_offset];
  498|       |
  499|  2.12k|    varinfo->missing_range = 1;
  500|  2.12k|    varinfo->n_missing_values = 2;
  501|  2.12k|    if (varinfo->type == READSTAT_TYPE_DOUBLE) {
  ------------------
  |  Branch (501:9): [True: 1.18k, False: 940]
  ------------------
  502|  1.18k|        if ((retval = read_double(ctx, &varinfo->missing_double_values[0])) != READSTAT_OK) {
  ------------------
  |  Branch (502:13): [True: 20, False: 1.16k]
  ------------------
  503|     20|            goto cleanup;
  504|     20|        }
  505|  1.16k|        varinfo->missing_double_values[1] = HUGE_VAL;
  506|  1.16k|    } else {
  507|    940|        if ((retval = read_missing_string_value(ctx, varinfo, 0)) != READSTAT_OK) {
  ------------------
  |  Branch (507:13): [True: 9, False: 931]
  ------------------
  508|      9|            goto cleanup;
  509|      9|        }
  510|    931|        varinfo->missing_string_values[1][0] = '\0';
  511|    931|    }
  512|  2.12k|cleanup:
  513|  2.12k|    return retval;
  514|  2.12k|}
readstat_por_read.c:read_variable_label_record:
  539|  1.16k|static readstat_error_t read_variable_label_record(por_ctx_t *ctx) {
  540|  1.16k|    readstat_error_t retval = READSTAT_OK;
  541|  1.16k|    char string[POR_STRING_BUFFER_SIZE];
  542|  1.16k|    spss_varinfo_t *varinfo = NULL;
  543|       |
  544|  1.16k|    if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) {
  ------------------
  |  Branch (544:9): [True: 1, False: 1.16k]
  |  Branch (544:32): [True: 0, False: 1.16k]
  ------------------
  545|      1|        retval = READSTAT_ERROR_PARSE;
  546|      1|        goto cleanup;
  547|      1|    }
  548|  1.16k|    varinfo = &ctx->varinfo[ctx->var_offset];
  549|       |
  550|  1.16k|    if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) {
  ------------------
  |  Branch (550:9): [True: 33, False: 1.13k]
  ------------------
  551|     33|        goto cleanup;
  552|     33|    }
  553|       |
  554|  1.13k|    size_t label_alloc_len = 4*strlen(string) + 1;
  555|  1.13k|    char *new_label = realloc(varinfo->label, label_alloc_len);
  556|  1.13k|    if (new_label == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; }
  ------------------
  |  Branch (556:9): [True: 0, False: 1.13k]
  ------------------
  557|  1.13k|    varinfo->label = new_label;
  558|  1.13k|    retval = readstat_convert(varinfo->label, label_alloc_len, string, strlen(string), ctx->converter);
  559|       |
  560|  1.16k|cleanup:
  561|  1.16k|    return retval;
  562|  1.13k|}
readstat_por_read.c:read_value_label_record:
  564|  9.78k|static readstat_error_t read_value_label_record(por_ctx_t *ctx) {
  565|  9.78k|    readstat_error_t retval = READSTAT_OK;
  566|  9.78k|    double dval;
  567|  9.78k|    int i;
  568|  9.78k|    char string[POR_STRING_BUFFER_SIZE];
  569|  9.78k|    int count = 0, label_count = 0;
  570|  9.78k|    char label_name_buf[256];
  571|  9.78k|    char key_buf[4*POR_STRING_BUFFER_SIZE+1];
  572|  9.78k|    char label_buf[4*POR_STRING_BUFFER_SIZE+1];
  573|  9.78k|    snprintf(label_name_buf, sizeof(label_name_buf), POR_LABEL_NAME_PREFIX "%d", ctx->labels_offset);
  ------------------
  |  |   25|  9.78k|#define POR_LABEL_NAME_PREFIX   "labels"
  ------------------
  574|  9.78k|    readstat_type_t value_type = READSTAT_TYPE_DOUBLE;
  575|  9.78k|    if ((retval = read_integer_in_range(ctx, 0, MAX_STRINGS, &count)) != READSTAT_OK) {
  ------------------
  |  |   38|  9.78k|#define MAX_STRINGS 1000000
  ------------------
  |  Branch (575:9): [True: 21, False: 9.76k]
  ------------------
  576|     21|        goto cleanup;
  577|     21|    }
  578|  17.2k|    for (i=0; i<count; i++) {
  ------------------
  |  Branch (578:15): [True: 7.66k, False: 9.57k]
  ------------------
  579|  7.66k|        if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) {
  ------------------
  |  Branch (579:13): [True: 188, False: 7.47k]
  ------------------
  580|    188|            goto cleanup;
  581|    188|        }
  582|  7.47k|        spss_varinfo_t *info = (spss_varinfo_t *)ck_str_hash_lookup(string, ctx->var_dict);
  583|  7.47k|        if (info) {
  ------------------
  |  Branch (583:13): [True: 3.31k, False: 4.16k]
  ------------------
  584|  3.31k|            value_type = info->type;
  585|  3.31k|            info->labels_index = ctx->labels_offset;
  586|  3.31k|        }
  587|  7.47k|    }
  588|  9.57k|    if ((retval = read_integer_in_range(ctx, 0, MAX_LABELS, &label_count)) != READSTAT_OK) {
  ------------------
  |  |   39|  9.57k|#define MAX_LABELS  1000000
  ------------------
  |  Branch (588:9): [True: 50, False: 9.52k]
  ------------------
  589|     50|        goto cleanup;
  590|     50|    }
  591|  53.4k|    for (i=0; i<label_count; i++) {
  ------------------
  |  Branch (591:15): [True: 44.0k, False: 9.41k]
  ------------------
  592|  44.0k|        readstat_value_t value = { .type = value_type };
  593|  44.0k|        if (value_type == READSTAT_TYPE_STRING) {
  ------------------
  |  Branch (593:13): [True: 294, False: 43.7k]
  ------------------
  594|    294|            if ((retval = read_converted_string(ctx, key_buf, sizeof(key_buf))) != READSTAT_OK) {
  ------------------
  |  Branch (594:17): [True: 10, False: 284]
  ------------------
  595|     10|                goto cleanup;
  596|     10|            }
  597|    284|            if ((retval = read_converted_string(ctx, label_buf, sizeof(label_buf))) != READSTAT_OK) {
  ------------------
  |  Branch (597:17): [True: 2, False: 282]
  ------------------
  598|      2|                goto cleanup;
  599|      2|            }
  600|    282|            value.v.string_value = key_buf;
  601|  43.7k|        } else {
  602|  43.7k|            if ((retval = read_double(ctx, &dval)) != READSTAT_OK) {
  ------------------
  |  Branch (602:17): [True: 54, False: 43.6k]
  ------------------
  603|     54|                goto cleanup;
  604|     54|            }
  605|  43.6k|            if ((retval = read_converted_string(ctx, label_buf, sizeof(label_buf))) != READSTAT_OK) {
  ------------------
  |  Branch (605:17): [True: 43, False: 43.6k]
  ------------------
  606|     43|                goto cleanup;
  607|     43|            }
  608|  43.6k|            value.v.double_value = dval;
  609|  43.6k|        }
  610|  43.8k|        if (ctx->handle.value_label) {
  ------------------
  |  Branch (610:13): [True: 43.8k, False: 0]
  ------------------
  611|  43.8k|            if (ctx->handle.value_label(label_name_buf, value, label_buf, ctx->user_ctx) != READSTAT_HANDLER_OK) {
  ------------------
  |  |   22|  43.8k|#define READSTAT_HANDLER_OK             0
  ------------------
  |  Branch (611:17): [True: 0, False: 43.8k]
  ------------------
  612|      0|                retval = READSTAT_ERROR_USER_ABORT;
  613|      0|                goto cleanup;
  614|      0|            }
  615|  43.8k|        }
  616|  43.8k|    }
  617|  9.41k|    ctx->labels_offset++;
  618|       |
  619|  9.78k|cleanup:
  620|  9.78k|    return retval;
  621|  9.41k|}
readstat_por_read.c:read_document_record:
  516|    707|static readstat_error_t read_document_record(por_ctx_t *ctx) {
  517|    707|    readstat_error_t retval = READSTAT_OK;
  518|    707|    char string[4*POR_STRING_BUFFER_SIZE+1];
  519|    707|    int i;
  520|    707|    int line_count = 0;
  521|    707|    if ((retval = read_integer_in_range(ctx, 0, MAX_LINES, &line_count)) != READSTAT_OK) {
  ------------------
  |  |   37|    707|#define MAX_LINES   1000000
  ------------------
  |  Branch (521:9): [True: 14, False: 693]
  ------------------
  522|     14|        goto cleanup;
  523|     14|    }
  524|  1.83k|    for (i=0; i<line_count; i++) {
  ------------------
  |  Branch (524:15): [True: 1.21k, False: 619]
  ------------------
  525|  1.21k|        if ((retval = read_converted_string(ctx, string, sizeof(string))) != READSTAT_OK) {
  ------------------
  |  Branch (525:13): [True: 74, False: 1.13k]
  ------------------
  526|     74|            goto cleanup;
  527|     74|        }
  528|  1.13k|        if (ctx->handle.note) {
  ------------------
  |  Branch (528:13): [True: 1.13k, False: 0]
  ------------------
  529|  1.13k|            if (ctx->handle.note(i, string, ctx->user_ctx) != READSTAT_OK) {
  ------------------
  |  Branch (529:17): [True: 0, False: 1.13k]
  ------------------
  530|      0|                retval = READSTAT_ERROR_USER_ABORT;
  531|      0|                goto cleanup;
  532|      0|            }
  533|  1.13k|        }
  534|  1.13k|    }
  535|    707|cleanup:
  536|    707|    return retval;
  537|    693|}
readstat_por_read.c:read_por_file_data:
  623|    403|static readstat_error_t read_por_file_data(por_ctx_t *ctx) {
  624|    403|    int i;
  625|    403|    char input_string[POR_STRING_BUFFER_SIZE];
  626|    403|    char output_string[4*POR_STRING_BUFFER_SIZE+1];
  627|    403|    char error_buf[1024];
  628|    403|    readstat_error_t rs_retval = READSTAT_OK;
  629|       |
  630|    403|    if (ctx->var_count == 0)
  ------------------
  |  Branch (630:9): [True: 8, False: 395]
  ------------------
  631|      8|        return READSTAT_OK;
  632|       |
  633|   147k|    while (1) {
  ------------------
  |  Branch (633:12): [True: 147k, Folded]
  ------------------
  634|   147k|        int finished = 0;
  635|   432k|        for (i=0; i<ctx->var_count; i++) {
  ------------------
  |  Branch (635:19): [True: 285k, False: 146k]
  ------------------
  636|   285k|            spss_varinfo_t *info = &ctx->varinfo[i];
  637|   285k|            readstat_value_t value = { .type = info->type };
  638|       |
  639|   285k|            if (info->type == READSTAT_TYPE_STRING) {
  ------------------
  |  Branch (639:17): [True: 388, False: 285k]
  ------------------
  640|    388|                rs_retval = maybe_read_string(ctx, input_string, sizeof(input_string), &finished);
  641|    388|                if (rs_retval != READSTAT_OK) {
  ------------------
  |  Branch (641:21): [True: 176, False: 212]
  ------------------
  642|    176|                    if (ctx->handle.error) {
  ------------------
  |  Branch (642:25): [True: 0, False: 176]
  ------------------
  643|      0|                        snprintf(error_buf, sizeof(error_buf), "Error in %s (row=%d)", 
  644|      0|                                info->name, ctx->obs_count+1);
  645|      0|                        ctx->handle.error(error_buf, ctx->user_ctx);
  646|      0|                    }
  647|    176|                    goto cleanup;
  648|    212|                } else if (finished) {
  ------------------
  |  Branch (648:28): [True: 3, False: 209]
  ------------------
  649|      3|                    if (i != 0)
  ------------------
  |  Branch (649:25): [True: 2, False: 1]
  ------------------
  650|      2|                        rs_retval = READSTAT_ERROR_PARSE;
  651|      3|                    goto cleanup;
  652|      3|                }
  653|    209|                rs_retval = readstat_convert(output_string, sizeof(output_string),
  654|    209|                        input_string, strlen(input_string), ctx->converter);
  655|    209|                if (rs_retval != READSTAT_OK) {
  ------------------
  |  Branch (655:21): [True: 0, False: 209]
  ------------------
  656|      0|                    goto cleanup;
  657|      0|                }
  658|    209|                value.v.string_value = output_string;
  659|   285k|            } else if (info->type == READSTAT_TYPE_DOUBLE) {
  ------------------
  |  Branch (659:24): [True: 285k, False: 0]
  ------------------
  660|   285k|                rs_retval = maybe_read_double(ctx, &value.v.double_value, &finished);
  661|   285k|                if (rs_retval != READSTAT_OK) {
  ------------------
  |  Branch (661:21): [True: 213, False: 285k]
  ------------------
  662|    213|                    if (ctx->handle.error) {
  ------------------
  |  Branch (662:25): [True: 0, False: 213]
  ------------------
  663|      0|                        snprintf(error_buf, sizeof(error_buf), "Error in %s (row=%d)", 
  664|      0|                                info->name, ctx->obs_count+1);
  665|      0|                        ctx->handle.error(error_buf, ctx->user_ctx);
  666|      0|                    }
  667|    213|                    goto cleanup;
  668|   285k|                } else if (finished) {
  ------------------
  |  Branch (668:28): [True: 3, False: 285k]
  ------------------
  669|      3|                    if (i != 0)
  ------------------
  |  Branch (669:25): [True: 2, False: 1]
  ------------------
  670|      2|                        rs_retval = READSTAT_ERROR_PARSE;
  671|      3|                    goto cleanup;
  672|      3|                }
  673|   285k|                value.is_system_missing = isnan(value.v.double_value);
  674|   285k|            }
  675|   285k|            if (ctx->handle.value && !ctx->variables[i]->skip && !ctx->row_offset) {
  ------------------
  |  Branch (675:17): [True: 285k, False: 0]
  |  Branch (675:38): [True: 285k, False: 0]
  |  Branch (675:66): [True: 285k, False: 0]
  ------------------
  676|   285k|                if (ctx->handle.value(ctx->obs_count, ctx->variables[i], value, ctx->user_ctx) != READSTAT_HANDLER_OK) {
  ------------------
  |  |   22|   285k|#define READSTAT_HANDLER_OK             0
  ------------------
  |  Branch (676:21): [True: 0, False: 285k]
  ------------------
  677|      0|                    rs_retval = READSTAT_ERROR_USER_ABORT;
  678|      0|                    goto cleanup;
  679|      0|                }
  680|   285k|            }
  681|       |
  682|   285k|        }
  683|   146k|        if (ctx->row_offset) {
  ------------------
  |  Branch (683:13): [True: 0, False: 146k]
  ------------------
  684|      0|            ctx->row_offset--;
  685|   146k|        } else {
  686|   146k|            ctx->obs_count++;
  687|   146k|        }
  688|       |
  689|   146k|        rs_retval = por_update_progress(ctx);
  690|   146k|        if (rs_retval != READSTAT_OK)
  ------------------
  |  Branch (690:13): [True: 0, False: 146k]
  ------------------
  691|      0|            break;
  692|       |            
  693|   146k|        if (ctx->row_limit > 0 && ctx->obs_count == ctx->row_limit)
  ------------------
  |  Branch (693:13): [True: 0, False: 146k]
  |  Branch (693:35): [True: 0, False: 0]
  ------------------
  694|      0|            break;
  695|   146k|    }
  696|    395|cleanup:
  697|    395|    return rs_retval;
  698|    395|}
readstat_por_read.c:por_update_progress:
   44|   146k|static readstat_error_t por_update_progress(por_ctx_t *ctx) {
   45|   146k|    readstat_io_t *io = ctx->io;
   46|   146k|    return io->update(ctx->file_size, ctx->handle.progress, ctx->user_ctx, io->io_ctx);
   47|   146k|}

spss_format:
   51|  1.70k|int spss_format(char *buffer, size_t len, spss_format_t *format) {
   52|  1.70k|    if (format->type < 0 
  ------------------
  |  Branch (52:9): [True: 0, False: 1.70k]
  ------------------
   53|  1.70k|            || format->type >= sizeof(spss_type_strings)/sizeof(spss_type_strings[0])
  ------------------
  |  Branch (53:16): [True: 11, False: 1.69k]
  ------------------
   54|  1.69k|            || spss_type_strings[format->type][0] == '\0') {
  ------------------
  |  Branch (54:16): [True: 585, False: 1.10k]
  ------------------
   55|    596|        return 0;
   56|    596|    }
   57|  1.10k|    char *string = spss_type_strings[format->type];
   58|       |
   59|  1.10k|    if (format->decimal_places || format->type == SPSS_FORMAT_TYPE_F) {
  ------------------
  |  |    6|    520|#define SPSS_FORMAT_TYPE_F        5
  ------------------
  |  Branch (59:9): [True: 585, False: 520]
  |  Branch (59:35): [True: 197, False: 323]
  ------------------
   60|    782|        snprintf(buffer, len, "%s%d.%d", string, format->width, format->decimal_places);
   61|    782|    } else if (format->width) {
  ------------------
  |  Branch (61:16): [True: 227, False: 96]
  ------------------
   62|    227|        snprintf(buffer, len, "%s%d", string, format->width);
   63|    227|    } else {
   64|     96|        snprintf(buffer, len, "%s", string);
   65|     96|    }
   66|       |
   67|  1.10k|    return 1;
   68|  1.70k|}
spss_missingness_for_info:
  127|  1.70k|readstat_missingness_t spss_missingness_for_info(spss_varinfo_t *info) {
  128|  1.70k|    readstat_missingness_t missingness;
  129|  1.70k|    memset(&missingness, '\0', sizeof(readstat_missingness_t));
  130|       |
  131|  1.70k|    if (info->missing_range) {
  ------------------
  |  Branch (131:9): [True: 111, False: 1.59k]
  ------------------
  132|    111|        missingness.missing_ranges_count++;
  133|    111|        missingness.missing_ranges[0] = spss_boxed_missing_value(info, 0);
  134|    111|        missingness.missing_ranges[1] = spss_boxed_missing_value(info, 1);
  135|       |
  136|    111|        if (info->n_missing_values == 3) {
  ------------------
  |  Branch (136:13): [True: 36, False: 75]
  ------------------
  137|     36|            missingness.missing_ranges_count++;
  138|     36|            missingness.missing_ranges[2] = missingness.missing_ranges[3] = spss_boxed_missing_value(info, 2);
  139|     36|        }
  140|  1.59k|    } else if (info->n_missing_values > 0) {
  ------------------
  |  Branch (140:16): [True: 104, False: 1.48k]
  ------------------
  141|    104|        missingness.missing_ranges_count = info->n_missing_values;
  142|    104|        int i=0;
  143|    275|        for (i=0; i<info->n_missing_values; i++) {
  ------------------
  |  Branch (143:19): [True: 171, False: 104]
  ------------------
  144|    171|            missingness.missing_ranges[2*i] = missingness.missing_ranges[2*i+1] = spss_boxed_missing_value(info, i);
  145|    171|        }
  146|    104|    }
  147|  1.70k|    return missingness;
  148|  1.70k|}
spss_init_variable_for_info:
  151|  1.70k|        iconv_t converter) {
  152|  1.70k|    readstat_variable_t *variable = calloc(1, sizeof(readstat_variable_t));
  153|       |
  154|  1.70k|    variable->index = info->index;
  155|  1.70k|    variable->index_after_skipping = index_after_skipping;
  156|  1.70k|    variable->type = info->type;
  157|  1.70k|    if (info->string_length) {
  ------------------
  |  Branch (157:9): [True: 975, False: 726]
  ------------------
  158|    975|        variable->storage_width = info->string_length;
  159|    975|    } else {
  160|    726|        variable->storage_width = 8 * info->width;
  161|    726|    }
  162|       |
  163|  1.70k|    if (info->longname[0]) {
  ------------------
  |  Branch (163:9): [True: 0, False: 1.70k]
  ------------------
  164|      0|        readstat_convert(variable->name, sizeof(variable->name),
  165|      0|                info->longname, sizeof(info->longname), converter);
  166|  1.70k|    } else {
  167|  1.70k|        readstat_convert(variable->name, sizeof(variable->name),
  168|  1.70k|                info->name, sizeof(info->name), converter);
  169|  1.70k|    }
  170|  1.70k|    if (info->label) {
  ------------------
  |  Branch (170:9): [True: 37, False: 1.66k]
  ------------------
  171|     37|        snprintf(variable->label, sizeof(variable->label), "%s", info->label);
  172|     37|    }
  173|       |
  174|  1.70k|    spss_format(variable->format, sizeof(variable->format), &info->print_format);
  175|       |
  176|  1.70k|    variable->missingness = spss_missingness_for_info(info);
  177|  1.70k|    variable->measure = info->measure;
  178|  1.70k|    variable->alignment = info->alignment;
  179|  1.70k|    if (info->display_width) {
  ------------------
  |  Branch (179:9): [True: 0, False: 1.70k]
  ------------------
  180|      0|        variable->display_width = info->display_width;
  181|  1.70k|    } else {
  182|  1.70k|        variable->display_width = info->print_format.width;
  183|  1.70k|    }
  184|       |
  185|  1.70k|    return variable;
  186|  1.70k|}
readstat_spss.c:spss_boxed_missing_value:
  120|    429|static readstat_value_t spss_boxed_missing_value(spss_varinfo_t *info, int i) {
  121|    429|    if (info->type == READSTAT_TYPE_DOUBLE) {
  ------------------
  |  Branch (121:9): [True: 273, False: 156]
  ------------------
  122|    273|        return spss_boxed_double_value(info->missing_double_values[i]);
  123|    273|    }
  124|    156|    return spss_boxed_string_value(info->missing_string_values[i]);
  125|    429|}
readstat_spss.c:spss_boxed_double_value:
  103|    273|static readstat_value_t spss_boxed_double_value(double fp_value) {
  104|    273|    readstat_value_t value = {
  105|    273|        .type = READSTAT_TYPE_DOUBLE,
  106|    273|        .v = { .double_value = fp_value },
  107|       |        .is_system_missing = isnan(fp_value)
  108|    273|    };
  109|    273|    return value;
  110|    273|}
readstat_spss.c:spss_boxed_string_value:
  112|    156|static readstat_value_t spss_boxed_string_value(const char *string) {
  113|    156|    readstat_value_t value = {
  114|    156|        .type = READSTAT_TYPE_STRING,
  115|    156|        .v = { .string_value = string }
  116|    156|    };
  117|    156|    return value;
  118|    156|}

rt_open_handler:
    8|  2.80k|int rt_open_handler(const char *path, void *io_ctx) {
    9|  2.80k|    return 0;
   10|  2.80k|}
rt_close_handler:
   12|  2.80k|int rt_close_handler(void *io_ctx) {
   13|  2.80k|    return 0;
   14|  2.80k|}
rt_seek_handler:
   17|  5.60k|        readstat_io_flags_t whence, void *io_ctx) {
   18|  5.60k|    rt_buffer_ctx_t *buffer_ctx = (rt_buffer_ctx_t *)io_ctx;
   19|  5.60k|    readstat_off_t newpos = -1;
   20|  5.60k|    if (whence == READSTAT_SEEK_SET) {
  ------------------
  |  Branch (20:9): [True: 2.80k, False: 2.80k]
  ------------------
   21|  2.80k|        newpos = offset;
   22|  2.80k|    } else if (whence == READSTAT_SEEK_CUR) {
  ------------------
  |  Branch (22:16): [True: 0, False: 2.80k]
  ------------------
   23|      0|        newpos = buffer_ctx->pos + offset;
   24|  2.80k|    } else if (whence == READSTAT_SEEK_END) {
  ------------------
  |  Branch (24:16): [True: 2.80k, False: 0]
  ------------------
   25|  2.80k|        newpos = buffer_ctx->buffer->used + offset;
   26|  2.80k|    }
   27|       |
   28|  5.60k|    if (newpos < 0)
  ------------------
  |  Branch (28:9): [True: 0, False: 5.60k]
  ------------------
   29|      0|        return -1;
   30|       |
   31|  5.60k|    if (newpos > buffer_ctx->buffer->used)
  ------------------
  |  Branch (31:9): [True: 0, False: 5.60k]
  ------------------
   32|      0|        return -1;
   33|       |
   34|  5.60k|    buffer_ctx->pos = newpos;
   35|  5.60k|    return newpos;
   36|  5.60k|}
rt_read_handler:
   38|  3.97M|ssize_t rt_read_handler(void *buf, size_t nbytes, void *io_ctx) {
   39|  3.97M|    rt_buffer_ctx_t *buffer_ctx = (rt_buffer_ctx_t *)io_ctx;
   40|  3.97M|    ssize_t bytes_copied = 0;
   41|  3.97M|    ssize_t bytes_left = buffer_ctx->buffer->used - buffer_ctx->pos;
   42|  3.97M|    if (nbytes <= bytes_left) {
  ------------------
  |  Branch (42:9): [True: 3.96M, False: 1.88k]
  ------------------
   43|  3.96M|        memcpy(buf, buffer_ctx->buffer->bytes + buffer_ctx->pos, nbytes);
   44|  3.96M|        bytes_copied = nbytes;
   45|  3.96M|    } else if (bytes_left > 0) {
  ------------------
  |  Branch (45:16): [True: 0, False: 1.88k]
  ------------------
   46|      0|        memcpy(buf, buffer_ctx->buffer->bytes + buffer_ctx->pos, bytes_left);
   47|      0|        bytes_copied = bytes_left;
   48|      0|    }
   49|  3.97M|    buffer_ctx->pos += bytes_copied;
   50|  3.97M|    return bytes_copied;
   51|  3.97M|}
rt_update_handler:
   54|   146k|        void *user_ctx, void *io_ctx) {
   55|   146k|    if (!progress_handler)
  ------------------
  |  Branch (55:9): [True: 146k, False: 0]
  ------------------
   56|   146k|        return READSTAT_OK;
   57|       |
   58|      0|    rt_buffer_ctx_t *buffer_ctx = (rt_buffer_ctx_t *)io_ctx;
   59|       |
   60|      0|    if (progress_handler(1.0 * buffer_ctx->pos / buffer_ctx->buffer->used, user_ctx))
  ------------------
  |  Branch (60:9): [True: 0, False: 0]
  ------------------
   61|      0|        return READSTAT_ERROR_USER_ABORT;
   62|       |
   63|      0|    return READSTAT_OK;
   64|      0|}

