#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct katcp_type {
  int dummy;
};
struct katcp_dispatch {
  int dummy;
};
typedef void katcp_dict;

/* Variables and functions */
int /*<<< orphan*/ add_type_dict_katcp(void *, char *, struct katcp_type *,
                                       void *);
void *create_dict_katcp(char *);
int /*<<< orphan*/ destroy_dict_type_katcp(void *);
struct katcp_type *find_name_type_katcp(struct katcp_dispatch *, char *);
int /*<<< orphan*/ free(char *);
void *search_named_type_katcp(struct katcp_dispatch *, char *, char *,
                              int /*<<< orphan*/ *);
void *search_type_katcp(struct katcp_dispatch *, struct katcp_type *, char *,
                        char *);
int strlen(char *);
char *strndup(char *, int);
void *parse_dict_type_katcp(struct katcp_dispatch *d, char **str) {
  struct katcp_dict *dt;
  struct katcp_type *stringtype;
  int i, j, tlen, state, ipos, spos, len;
  char c, *key, *value;
  void *data;
  if (str == NULL || str[0] == NULL)
    return NULL;
  dt = NULL;
  state = 0;
  c = '{';
  ipos = 0;
  spos = 0;
  len = 0;
  key = NULL;
  value = NULL;
  dt = search_named_type_katcp(d, "dict", str[0], NULL);
  if (dt == NULL) {
    dt = create_dict_katcp(str[0]);
  }
  if (dt == NULL)
    return NULL;
  stringtype = find_name_type_katcp(d, "string");
  for (i = 1; str[i] != NULL; i++) {
    tlen = strlen(str[i]);
    for (j = 0; j < tlen; j++) {
      c = str[i][j];
      switch (state) {
      case 0:
        switch (c) {
        case '{':
          state = 1;
          spos = j + 1;
          ipos = i;
          break;
        }
        break;
      case 1:
        switch (c) {
        case ':':
          if ((i - ipos) > 0 && j > 0) {
            ipos++;
            spos = 0;
            len = j - spos;
          } else if ((i - ipos) == 2) {
            ipos = i - 1;
            spos = 0;
            len = strlen(str[ipos]);
          } else {
            len = j - spos;
          }
          key = strndup(str[ipos] + spos, len);
          if (key == NULL) {
            destroy_dict_type_katcp(dt);
            if (value != NULL)
              free(value);
            return NULL;
          }
          state = 2;
          spos = j + 1;
          ipos = i;
          break;
        }
        break;
      case 2:
        switch (c) {
        case '}':
          state = 3;
        case ',':
          if ((i - ipos) > 0 && j > 0) {
            ipos++;
            spos = 0;
            len = j - spos;
          } else if ((i - ipos) == 2) {
            ipos = i - 1;
            spos = 0;
            len = strlen(str[ipos]);
          } else {
            len = j - spos;
          }
          value = strndup(str[ipos] + spos, len);
          if (value == NULL) {
            destroy_dict_type_katcp(dt);
            if (key != NULL)
              free(key);
            return NULL;
          }
          data = search_type_katcp(d, stringtype, value, value);
          if (data != NULL) {
            if (add_type_dict_katcp(dt, key, stringtype, data) < 0) {
            }
          } else {
            if (value != NULL) {
              free(value);
              value = NULL;
            }
          }
          if (key != NULL) {
            free(key);
            key = NULL;
          }
          value = NULL;
          state = (state != '}') ? 1 : state;
          spos = j + 1;
          ipos = i;
          break;
        }
        break;
      case 3:
        break;
      }
    }
  }
  return dt;
}


x86 assembly (clang, -O0):
<parse_dict_type_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b9 <parse_dict_type_katcp+0x29>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11c6 <parse_dict_type_katcp+0x36>
movq   $0x0,-0x8(%rbp)
jmp    1600 <parse_dict_type_katcp+0x470>
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x38(%rbp)
movb   $0x7b,-0x45(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe00(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <search_named_type_katcp@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1238 <parse_dict_type_katcp+0xa8>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1040 <create_dict_katcp@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1250 <parse_dict_type_katcp+0xc0>
movq   $0x0,-0x8(%rbp)
jmp    1600 <parse_dict_type_katcp+0x470>
mov    -0x10(%rbp),%rdi
lea    0xdba(%rip),%rsi
call   1060 <find_name_type_katcp@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     15f8 <parse_dict_type_katcp+0x468>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    15e5 <parse_dict_type_katcp+0x455>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x45(%rbp)
mov    -0x38(%rbp),%eax
mov    %rax,-0x68(%rbp)
sub    $0x3,%rax
ja     15d2 <parse_dict_type_katcp+0x442>
mov    -0x68(%rbp),%rax
lea    0xd29(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x45(%rbp),%al
sub    $0x7b,%al
jne    1306 <parse_dict_type_katcp+0x176>
jmp    12f0 <parse_dict_type_katcp+0x160>
movl   $0x1,-0x38(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    15d2 <parse_dict_type_katcp+0x442>
mov    -0x45(%rbp),%al
sub    $0x3a,%al
jne    1402 <parse_dict_type_katcp+0x272>
jmp    131b <parse_dict_type_katcp+0x18b>
mov    -0x2c(%rbp),%eax
sub    -0x3c(%rbp),%eax
cmp    $0x0,%eax
jle    1352 <parse_dict_type_katcp+0x1c2>
cmpl   $0x0,-0x30(%rbp)
jle    1352 <parse_dict_type_katcp+0x1c2>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%eax
sub    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1398 <parse_dict_type_katcp+0x208>
mov    -0x2c(%rbp),%eax
sub    -0x3c(%rbp),%eax
cmp    $0x2,%eax
jne    138a <parse_dict_type_katcp+0x1fa>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
jmp    1393 <parse_dict_type_katcp+0x203>
mov    -0x30(%rbp),%eax
sub    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1398 <parse_dict_type_katcp+0x208>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    -0x44(%rbp),%esi
call   1080 <strndup@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13ec <parse_dict_type_katcp+0x25c>
mov    -0x20(%rbp),%rdi
call   10a0 <destroy_dict_type_katcp@plt>
cmpq   $0x0,-0x58(%rbp)
je     13df <parse_dict_type_katcp+0x24f>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1600 <parse_dict_type_katcp+0x470>
movl   $0x2,-0x38(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    15d2 <parse_dict_type_katcp+0x442>
movsbl -0x45(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x2c,%eax
je     1434 <parse_dict_type_katcp+0x2a4>
jmp    141c <parse_dict_type_katcp+0x28c>
mov    -0x6c(%rbp),%eax
sub    $0x7d,%eax
jne    15c8 <parse_dict_type_katcp+0x438>
jmp    142d <parse_dict_type_katcp+0x29d>
movl   $0x3,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
sub    -0x3c(%rbp),%eax
cmp    $0x0,%eax
jle    146b <parse_dict_type_katcp+0x2db>
cmpl   $0x0,-0x30(%rbp)
jle    146b <parse_dict_type_katcp+0x2db>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%eax
sub    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    14b1 <parse_dict_type_katcp+0x321>
mov    -0x2c(%rbp),%eax
sub    -0x3c(%rbp),%eax
cmp    $0x2,%eax
jne    14a3 <parse_dict_type_katcp+0x313>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
jmp    14ac <parse_dict_type_katcp+0x31c>
mov    -0x30(%rbp),%eax
sub    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    14b1 <parse_dict_type_katcp+0x321>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rdi
mov    -0x44(%rbp),%esi
call   1080 <strndup@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1505 <parse_dict_type_katcp+0x375>
mov    -0x20(%rbp),%rdi
call   10a0 <destroy_dict_type_katcp@plt>
cmpq   $0x0,-0x50(%rbp)
je     14f8 <parse_dict_type_katcp+0x368>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1600 <parse_dict_type_katcp+0x470>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x58(%rbp),%rcx
call   1090 <search_type_katcp@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1551 <parse_dict_type_katcp+0x3c1>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x60(%rbp),%rcx
call   10b0 <add_type_dict_katcp@plt>
cmp    $0x0,%eax
jge    154c <parse_dict_type_katcp+0x3bc>
jmp    154c <parse_dict_type_katcp+0x3bc>
jmp    1572 <parse_dict_type_katcp+0x3e2>
cmpq   $0x0,-0x58(%rbp)
je     156d <parse_dict_type_katcp+0x3dd>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x58(%rbp)
jmp    1572 <parse_dict_type_katcp+0x3e2>
cmpq   $0x0,-0x50(%rbp)
je     158e <parse_dict_type_katcp+0x3fe>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpl   $0x7d,-0x38(%rbp)
je     15ad <parse_dict_type_katcp+0x41d>
mov    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    15b3 <parse_dict_type_katcp+0x423>
mov    -0x38(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    15d2 <parse_dict_type_katcp+0x442>
jmp    15d2 <parse_dict_type_katcp+0x442>
jmp    15d7 <parse_dict_type_katcp+0x447>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1299 <parse_dict_type_katcp+0x109>
jmp    15ea <parse_dict_type_katcp+0x45a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126b <parse_dict_type_katcp+0xdb>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_dict_type_katcp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %rsi,%rsi
je     1457 <parse_dict_type_katcp+0x2c7>
mov    %rsi,%rbp
mov    (%rsi),%rdx
test   %rdx,%rdx
je     1457 <parse_dict_type_katcp+0x2c7>
mov    %rdi,%r14
lea    0xe40(%rip),%rsi
xor    %ecx,%ecx
call   1070 <search_named_type_katcp@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11e4 <parse_dict_type_katcp+0x54>
mov    0x0(%rbp),%rdi
call   1040 <create_dict_katcp@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1457 <parse_dict_type_katcp+0x2c7>
lea    0xe1a(%rip),%rsi
mov    %r14,%rdi
call   1060 <find_name_type_katcp@plt>
mov    0x8(%rbp),%rdi
test   %rdi,%rdi
je     1459 <parse_dict_type_katcp+0x2c9>
mov    %rax,0x38(%rsp)
mov    %r14,0x40(%rsp)
mov    %rbx,0x20(%rsp)
mov    %rbp,0x8(%rsp)
lea    0x8(%rbp),%rdx
xor    %r14d,%r14d
mov    $0x1,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    124c <parse_dict_type_katcp+0xbc>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %ebx,%eax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rdx
mov    (%rcx,%rax,8),%rdi
test   %rdi,%rdi
je     146b <parse_dict_type_katcp+0x2db>
mov    %rdx,0x10(%rsp)
call   1050 <strlen@plt>
test   %eax,%eax
jle    1230 <parse_dict_type_katcp+0xa0>
lea    -0x1(%rbx),%ecx
mov    %ecx,0x1c(%rsp)
mov    %eax,%edx
xor    %r13d,%r13d
mov    %rbx,%rax
mov    %rbx,0x28(%rsp)
mov    0x10(%rsp),%rcx
mov    %rdx,0x30(%rsp)
jmp    1298 <parse_dict_type_katcp+0x108>
lea    0x1(%r13),%ebp
mov    $0x1,%r12d
mov    %ebx,%r15d
xor    %r14d,%r14d
mov    0x30(%rsp),%rdx
add    $0x1,%r13
cmp    %r13,%rdx
je     1230 <parse_dict_type_katcp+0xa0>
mov    (%rcx),%rax
movsbl (%rax,%r13,1),%eax
cmp    $0x2,%r12d
je     12d0 <parse_dict_type_katcp+0x140>
cmp    $0x1,%r12d
je     1300 <parse_dict_type_katcp+0x170>
test   %r12d,%r12d
jne    128f <parse_dict_type_katcp+0xff>
xor    %r12d,%r12d
cmp    $0x7b,%al
jne    128f <parse_dict_type_katcp+0xff>
lea    0x1(%r13),%ebp
mov    $0x1,%r12d
mov    %ebx,%r15d
jmp    128f <parse_dict_type_katcp+0xff>
nopw   0x0(%rax,%rax,1)
cmp    $0x7d,%eax
je     12e0 <parse_dict_type_katcp+0x150>
mov    $0x2,%r12d
cmp    $0x2c,%eax
jne    128f <parse_dict_type_katcp+0xff>
mov    %ebx,%eax
sub    %r15d,%eax
jle    1324 <parse_dict_type_katcp+0x194>
test   %r13,%r13
je     1324 <parse_dict_type_katcp+0x194>
add    $0x1,%r15d
xor    %ebp,%ebp
mov    %r13d,%esi
jmp    1376 <parse_dict_type_katcp+0x1e6>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r12d
cmp    $0x3a,%al
jne    128f <parse_dict_type_katcp+0xff>
mov    %ebx,%eax
sub    %r15d,%eax
jle    1346 <parse_dict_type_katcp+0x1b6>
test   %r13,%r13
je     1346 <parse_dict_type_katcp+0x1b6>
add    $0x1,%r15d
xor    %ebp,%ebp
mov    %r13d,%esi
jmp    13fa <parse_dict_type_katcp+0x26a>
cmp    $0x2,%eax
jne    1371 <parse_dict_type_katcp+0x1e1>
mov    %rbx,%rax
mov    0x8(%rsp),%rbx
mov    -0x8(%rbx,%rax,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
xor    %ebp,%ebp
mov    0x1c(%rsp),%r15d
jmp    137b <parse_dict_type_katcp+0x1eb>
cmp    $0x2,%eax
jne    13f5 <parse_dict_type_katcp+0x265>
mov    0x8(%rsp),%rbx
mov    0x28(%rsp),%rax
mov    -0x8(%rbx,%rax,8),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
xor    %ebp,%ebp
mov    0x1c(%rsp),%r15d
jmp    13ff <parse_dict_type_katcp+0x26f>
mov    %r13d,%esi
sub    %ebp,%esi
mov    0x8(%rsp),%rbx
movslq %r15d,%rax
movslq %ebp,%rdi
add    (%rbx,%rax,8),%rdi
call   1080 <strndup@plt>
test   %rax,%rax
je     1432 <parse_dict_type_katcp+0x2a2>
mov    %rax,%rbp
mov    0x40(%rsp),%rdi
mov    0x38(%rsp),%rbx
mov    %rbx,%rsi
mov    %rax,%rdx
mov    %rax,%rcx
call   1090 <search_type_katcp@plt>
test   %rax,%rax
je     13c8 <parse_dict_type_katcp+0x238>
mov    0x20(%rsp),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %rax,%rcx
call   10b0 <add_type_dict_katcp@plt>
jmp    13d0 <parse_dict_type_katcp+0x240>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rbx
mov    0x10(%rsp),%rcx
test   %r14,%r14
je     127a <parse_dict_type_katcp+0xea>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rcx
jmp    127a <parse_dict_type_katcp+0xea>
mov    %r13d,%esi
sub    %ebp,%esi
mov    0x8(%rsp),%rbx
movslq %r15d,%rax
movslq %ebp,%rdi
add    (%rbx,%rax,8),%rdi
call   1080 <strndup@plt>
test   %rax,%rax
je     144d <parse_dict_type_katcp+0x2bd>
mov    %rax,%r14
lea    0x1(%r13),%ebp
mov    $0x2,%r12d
mov    0x28(%rsp),%rbx
mov    %ebx,%r15d
mov    0x10(%rsp),%rcx
jmp    128a <parse_dict_type_katcp+0xfa>
mov    0x20(%rsp),%rdi
call   10a0 <destroy_dict_type_katcp@plt>
test   %r14,%r14
je     1457 <parse_dict_type_katcp+0x2c7>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
jmp    1459 <parse_dict_type_katcp+0x2c9>
mov    0x20(%rsp),%rdi
call   10a0 <destroy_dict_type_katcp@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x20(%rsp),%rbx
jmp    1459 <parse_dict_type_katcp+0x2c9>

LLVM IR (-O0):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_dict = type opaque
%struct.katcp_type = type { i32 }
@.str = [5 x i8] c"dict\00"
@.str.1 = [7 x i8] c"string\00"
define i8* @parse_dict_type_katcp(%struct.katcp_dispatch* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca %struct.katcp_dispatch*
%5 = alloca i8**
%6 = alloca %struct.katcp_dict*
%7 = alloca %struct.katcp_type*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
store %struct.katcp_dispatch* %0, %struct.katcp_dispatch** %4
store i8** %1, i8*** %5
%19 = load i8**, i8*** %5
%20 = icmp eq i8** %19, null
br i1 %20, label %26, label %21
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %21, %2
store i8* null, i8** %3
br label %265
27: ; preds = %21
store %struct.katcp_dict* null, %struct.katcp_dict** %6
store i32 0, i32* %11
store i8 123, i8* %15
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i8* null, i8** %16
store i8* null, i8** %17
%28 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i8* @search_named_type_katcp(%struct.katcp_dispatch* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %31, i32* null)
%33 = bitcast i8* %32 to %struct.katcp_dict*
store %struct.katcp_dict* %33, %struct.katcp_dict** %6
%34 = load %struct.katcp_dict*, %struct.katcp_dict** %6
%35 = icmp eq %struct.katcp_dict* %34, null
br i1 %35, label %36, label %42
36: ; preds = %27
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i8* @create_dict_katcp(i8* %39)
%41 = bitcast i8* %40 to %struct.katcp_dict*
store %struct.katcp_dict* %41, %struct.katcp_dict** %6
br label %42
42: ; preds = %36, %27
%43 = load %struct.katcp_dict*, %struct.katcp_dict** %6
%44 = icmp eq %struct.katcp_dict* %43, null
br i1 %44, label %45, label %46
45: ; preds = %42
store i8* null, i8** %3
br label %265
46: ; preds = %42
%47 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%48 = call %struct.katcp_type* @find_name_type_katcp(%struct.katcp_dispatch* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store %struct.katcp_type* %48, %struct.katcp_type** %7
store i32 1, i32* %8
br label %49
49: ; preds = %259, %46
%50 = load i8**, i8*** %5
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %262
56: ; preds = %49
%57 = load i8**, i8*** %5
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 @strlen(i8* %61)
store i32 %62, i32* %10
store i32 0, i32* %9
br label %63
63: ; preds = %255, %56
%64 = load i32, i32* %9
%65 = load i32, i32* %10
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %258
67: ; preds = %63
%68 = load i8**, i8*** %5
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
%76 = load i8, i8* %75
store i8 %76, i8* %15
%77 = load i32, i32* %11
switch i32 %77, label %254 [
i32 0, label %78
i32 1, label %86
i32 2, label %150
i32 3, label %253
]
78: ; preds = %67
%79 = load i8, i8* %15
%80 = sext i8 %79 to i32
switch i32 %80, label %85 [
i32 123, label %81
]
81: ; preds = %78
store i32 1, i32* %11
%82 = load i32, i32* %9
%83 = add nsw i32 %82, 1
store i32 %83, i32* %13
%84 = load i32, i32* %8
store i32 %84, i32* %12
br label %85
85: ; preds = %78, %81
br label %254
86: ; preds = %67
%87 = load i8, i8* %15
%88 = sext i8 %87 to i32
switch i32 %88, label %149 [
i32 58, label %89
]
89: ; preds = %86
%90 = load i32, i32* %8
%91 = load i32, i32* %12
%92 = sub nsw i32 %90, %91
%93 = icmp sgt i32 %92, 0
br i1 %93, label %94, label %103
94: ; preds = %89
%95 = load i32, i32* %9
%96 = icmp sgt i32 %95, 0
br i1 %96, label %97, label %103
97: ; preds = %94
%98 = load i32, i32* %12
%99 = add nsw i32 %98, 1
store i32 %99, i32* %12
store i32 0, i32* %13
%100 = load i32, i32* %9
%101 = load i32, i32* %13
%102 = sub nsw i32 %100, %101
store i32 %102, i32* %14
br label %122
103: ; preds = %94, %89
%104 = load i32, i32* %8
%105 = load i32, i32* %12
%106 = sub nsw i32 %104, %105
%107 = icmp eq i32 %106, 2
br i1 %107, label %108, label %117
108: ; preds = %103
%109 = load i32, i32* %8
%110 = sub nsw i32 %109, 1
store i32 %110, i32* %12
store i32 0, i32* %13
%111 = load i8**, i8*** %5
%112 = load i32, i32* %12
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8*, i8** %111, i64 %113
%115 = load i8*, i8** %114
%116 = call i32 @strlen(i8* %115)
store i32 %116, i32* %14
br label %121
117: ; preds = %103
%118 = load i32, i32* %9
%119 = load i32, i32* %13
%120 = sub nsw i32 %118, %119
store i32 %120, i32* %14
br label %121
121: ; preds = %117, %108
br label %122
122: ; preds = %121, %97
%123 = load i8**, i8*** %5
%124 = load i32, i32* %12
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8*, i8** %123, i64 %125
%127 = load i8*, i8** %126
%128 = load i32, i32* %13
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8, i8* %127, i64 %129
%131 = load i32, i32* %14
%132 = call i8* @strndup(i8* %130, i32 %131)
store i8* %132, i8** %16
%133 = load i8*, i8** %16
%134 = icmp eq i8* %133, null
br i1 %134, label %135, label %145
135: ; preds = %122
%136 = load %struct.katcp_dict*, %struct.katcp_dict** %6
%137 = bitcast %struct.katcp_dict* %136 to i8*
%138 = call i32 @destroy_dict_type_katcp(i8* %137)
%139 = load i8*, i8** %17
%140 = icmp ne i8* %139, null
br i1 %140, label %141, label %144
141: ; preds = %135
%142 = load i8*, i8** %17
%143 = call i32 @free(i8* %142)
br label %144
144: ; preds = %141, %135
store i8* null, i8** %3
br label %265
145: ; preds = %122
store i32 2, i32* %11
%146 = load i32, i32* %9
%147 = add nsw i32 %146, 1
store i32 %147, i32* %13
%148 = load i32, i32* %8
store i32 %148, i32* %12
br label %149
149: ; preds = %86, %145
br label %254
150: ; preds = %67
%151 = load i8, i8* %15
%152 = sext i8 %151 to i32
switch i32 %152, label %252 [
i32 125, label %153
i32 44, label %154
]
153: ; preds = %150
store i32 3, i32* %11
br label %154
154: ; preds = %150, %153
%155 = load i32, i32* %8
%156 = load i32, i32* %12
%157 = sub nsw i32 %155, %156
%158 = icmp sgt i32 %157, 0
br i1 %158, label %159, label %168
159: ; preds = %154
%160 = load i32, i32* %9
%161 = icmp sgt i32 %160, 0
br i1 %161, label %162, label %168
162: ; preds = %159
%163 = load i32, i32* %12
%164 = add nsw i32 %163, 1
store i32 %164, i32* %12
store i32 0, i32* %13
%165 = load i32, i32* %9
%166 = load i32, i32* %13
%167 = sub nsw i32 %165, %166
store i32 %167, i32* %14
br label %187
168: ; preds = %159, %154
%169 = load i32, i32* %8
%170 = load i32, i32* %12
%171 = sub nsw i32 %169, %170
%172 = icmp eq i32 %171, 2
br i1 %172, label %173, label %182
173: ; preds = %168
%174 = load i32, i32* %8
%175 = sub nsw i32 %174, 1
store i32 %175, i32* %12
store i32 0, i32* %13
%176 = load i8**, i8*** %5
%177 = load i32, i32* %12
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds i8*, i8** %176, i64 %178
%180 = load i8*, i8** %179
%181 = call i32 @strlen(i8* %180)
store i32 %181, i32* %14
br label %186
182: ; preds = %168
%183 = load i32, i32* %9
%184 = load i32, i32* %13
%185 = sub nsw i32 %183, %184
store i32 %185, i32* %14
br label %186
186: ; preds = %182, %173
br label %187
187: ; preds = %186, %162
%188 = load i8**, i8*** %5
%189 = load i32, i32* %12
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds i8*, i8** %188, i64 %190
%192 = load i8*, i8** %191
%193 = load i32, i32* %13
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds i8, i8* %192, i64 %194
%196 = load i32, i32* %14
%197 = call i8* @strndup(i8* %195, i32 %196)
store i8* %197, i8** %17
%198 = load i8*, i8** %17
%199 = icmp eq i8* %198, null
br i1 %199, label %200, label %210
200: ; preds = %187
%201 = load %struct.katcp_dict*, %struct.katcp_dict** %6
%202 = bitcast %struct.katcp_dict* %201 to i8*
%203 = call i32 @destroy_dict_type_katcp(i8* %202)
%204 = load i8*, i8** %16
%205 = icmp ne i8* %204, null
br i1 %205, label %206, label %209
206: ; preds = %200
%207 = load i8*, i8** %16
%208 = call i32 @free(i8* %207)
br label %209
209: ; preds = %206, %200
store i8* null, i8** %3
br label %265
210: ; preds = %187
%211 = load %struct.katcp_dispatch*, %struct.katcp_dispatch** %4
%212 = load %struct.katcp_type*, %struct.katcp_type** %7
%213 = load i8*, i8** %17
%214 = load i8*, i8** %17
%215 = call i8* @search_type_katcp(%struct.katcp_dispatch* %211, %struct.katcp_type* %212, i8* %213, i8* %214)
store i8* %215, i8** %18
%216 = load i8*, i8** %18
%217 = icmp ne i8* %216, null
br i1 %217, label %218, label %228
218: ; preds = %210
%219 = load %struct.katcp_dict*, %struct.katcp_dict** %6
%220 = bitcast %struct.katcp_dict* %219 to i8*
%221 = load i8*, i8** %16
%222 = load %struct.katcp_type*, %struct.katcp_type** %7
%223 = load i8*, i8** %18
%224 = call i32 @add_type_dict_katcp(i8* %220, i8* %221, %struct.katcp_type* %222, i8* %223)
%225 = icmp slt i32 %224, 0
br i1 %225, label %226, label %227
226: ; preds = %218
br label %227
227: ; preds = %226, %218
br label %235
228: ; preds = %210
%229 = load i8*, i8** %17
%230 = icmp ne i8* %229, null
br i1 %230, label %231, label %234
231: ; preds = %228
%232 = load i8*, i8** %17
%233 = call i32 @free(i8* %232)
store i8* null, i8** %17
br label %234
234: ; preds = %231, %228
br label %235
235: ; preds = %234, %227
%236 = load i8*, i8** %16
%237 = icmp ne i8* %236, null
br i1 %237, label %238, label %241
238: ; preds = %235
%239 = load i8*, i8** %16
%240 = call i32 @free(i8* %239)
store i8* null, i8** %16
br label %241
241: ; preds = %238, %235
store i8* null, i8** %17
%242 = load i32, i32* %11
%243 = icmp ne i32 %242, 125
br i1 %243, label %244, label %245
244: ; preds = %241
br label %247
245: ; preds = %241
%246 = load i32, i32* %11
br label %247
247: ; preds = %245, %244
%248 = phi i32 [ 1, %244 ], [ %246, %245 ]
store i32 %248, i32* %11
%249 = load i32, i32* %9
%250 = add nsw i32 %249, 1
store i32 %250, i32* %13
%251 = load i32, i32* %8
store i32 %251, i32* %12
br label %252
252: ; preds = %150, %247
br label %254
253: ; preds = %67
br label %254
254: ; preds = %67, %253, %252, %149, %85
br label %255
255: ; preds = %254
%256 = load i32, i32* %9
%257 = add nsw i32 %256, 1
store i32 %257, i32* %9
br label %63
258: ; preds = %63
br label %259
259: ; preds = %258
%260 = load i32, i32* %8
%261 = add nsw i32 %260, 1
store i32 %261, i32* %8
br label %49
262: ; preds = %49
%263 = load %struct.katcp_dict*, %struct.katcp_dict** %6
%264 = bitcast %struct.katcp_dict* %263 to i8*
store i8* %264, i8** %3
br label %265
265: ; preds = %262, %209, %144, %45, %26
%266 = load i8*, i8** %3
ret i8* %266
}

LLVM IR (-O2):
%struct.katcp_dispatch = type { i32 }
%struct.katcp_dict = type opaque
%struct.katcp_type = type { i32 }
@.str = [5 x i8] c"dict\00"
@.str.1 = [7 x i8] c"string\00"
define i8* @parse_dict_type_katcp(%struct.katcp_dispatch* %0, i8** %1) {
%3 = icmp eq i8** %1, null
br i1 %3, label %144, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %144, label %7
7: ; preds = %4
%8 = tail call i8* @search_named_type_katcp(%struct.katcp_dispatch* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %5, i32* null)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i8*, i8** %1
%12 = tail call i8* @create_dict_katcp(i8* %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %144, label %14
14: ; preds = %7, %10
%15 = phi i8* [ %12, %10 ], [ %8, %7 ]
%16 = tail call %struct.katcp_type* @find_name_type_katcp(%struct.katcp_dispatch* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = icmp eq i8* %18, null
br i1 %19, label %144, label %20
20: ; preds = %14, %134
%21 = phi i64 [ %139, %134 ], [ 1, %14 ]
%22 = phi i8* [ %142, %134 ], [ %18, %14 ]
%23 = phi i8** [ %141, %134 ], [ %17, %14 ]
%24 = phi i8* [ %138, %134 ], [ null, %14 ]
%25 = phi i32 [ %137, %134 ], [ 0, %14 ]
%26 = phi i32 [ %136, %134 ], [ 0, %14 ]
%27 = phi i32 [ %135, %134 ], [ 0, %14 ]
%28 = trunc i64 %21 to i32
%29 = tail call i32 @strlen(i8* %22)
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %134
31: ; preds = %20
%32 = add nsw i64 %21, -1
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = zext i32 %29 to i64
%35 = trunc i64 %32 to i32
br label %36
36: ; preds = %31, %127
%37 = phi i64 [ 0, %31 ], [ %132, %127 ]
%38 = phi i8* [ %24, %31 ], [ %131, %127 ]
%39 = phi i32 [ %25, %31 ], [ %130, %127 ]
%40 = phi i32 [ %26, %31 ], [ %129, %127 ]
%41 = phi i32 [ %27, %31 ], [ %128, %127 ]
%42 = trunc i64 %37 to i32
%43 = load i8*, i8** %23
%44 = getelementptr inbounds i8, i8* %43, i64 %37
%45 = load i8, i8* %44
switch i32 %41, label %127 [
i32 0, label %46
i32 1, label %51
i32 2, label %82
]
46: ; preds = %36
%47 = icmp eq i8 %45, 123
br i1 %47, label %48, label %127
48: ; preds = %46
%49 = trunc i64 %37 to i32
%50 = add i32 %49, 1
br label %127
51: ; preds = %36
%52 = icmp eq i8 %45, 58
br i1 %52, label %53, label %127
53: ; preds = %51
%54 = sub nsw i32 %28, %40
%55 = icmp sgt i32 %54, 0
%56 = icmp ne i64 %37, 0
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = add nsw i32 %40, 1
br label %67
60: ; preds = %53
%61 = icmp eq i32 %54, 2
br i1 %61, label %62, label %65
62: ; preds = %60
%63 = load i8*, i8** %33
%64 = tail call i32 @strlen(i8* %63)
br label %67
65: ; preds = %60
%66 = sub nsw i32 %42, %39
br label %67
67: ; preds = %62, %65, %58
%68 = phi i32 [ %59, %58 ], [ %35, %62 ], [ %40, %65 ]
%69 = phi i32 [ 0, %58 ], [ 0, %62 ], [ %39, %65 ]
%70 = phi i32 [ %42, %58 ], [ %64, %62 ], [ %66, %65 ]
%71 = sext i32 %68 to i64
%72 = getelementptr inbounds i8*, i8** %1, i64 %71
%73 = load i8*, i8** %72
%74 = sext i32 %69 to i64
%75 = getelementptr inbounds i8, i8* %73, i64 %74
%76 = tail call i8* @strndup(i8* %75, i32 %70)
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %80
78: ; preds = %67
%79 = tail call i32 @destroy_dict_type_katcp(i8* %15)
br label %144
80: ; preds = %67
%81 = add nuw nsw i32 %42, 1
br label %127
82: ; preds = %36
%83 = sext i8 %45 to i32
switch i32 %83, label %127 [
i32 125, label %84
i32 44, label %84
]
84: ; preds = %82, %82
%85 = sub nsw i32 %28, %40
%86 = icmp sgt i32 %85, 0
%87 = icmp ne i64 %37, 0
%88 = select i1 %86, i1 %87, i1 false
br i1 %88, label %89, label %91
89: ; preds = %84
%90 = add nsw i32 %40, 1
br label %98
91: ; preds = %84
%92 = icmp eq i32 %85, 2
br i1 %92, label %93, label %96
93: ; preds = %91
%94 = load i8*, i8** %33
%95 = tail call i32 @strlen(i8* %94)
br label %98
96: ; preds = %91
%97 = sub nsw i32 %42, %39
br label %98
98: ; preds = %93, %96, %89
%99 = phi i32 [ %90, %89 ], [ %35, %93 ], [ %40, %96 ]
%100 = phi i32 [ 0, %89 ], [ 0, %93 ], [ %39, %96 ]
%101 = phi i32 [ %42, %89 ], [ %95, %93 ], [ %97, %96 ]
%102 = sext i32 %99 to i64
%103 = getelementptr inbounds i8*, i8** %1, i64 %102
%104 = load i8*, i8** %103
%105 = sext i32 %100 to i64
%106 = getelementptr inbounds i8, i8* %104, i64 %105
%107 = tail call i8* @strndup(i8* %106, i32 %101)
%108 = icmp eq i8* %107, null
br i1 %108, label %109, label %114
109: ; preds = %98
%110 = tail call i32 @destroy_dict_type_katcp(i8* %15)
%111 = icmp eq i8* %38, null
br i1 %111, label %144, label %112
112: ; preds = %109
%113 = tail call i32 @free(i8* %38)
br label %144
114: ; preds = %98
%115 = tail call i8* @search_type_katcp(%struct.katcp_dispatch* %0, %struct.katcp_type* %16, i8* %107, i8* %107)
%116 = icmp eq i8* %115, null
br i1 %116, label %119, label %117
117: ; preds = %114
%118 = tail call i32 @add_type_dict_katcp(i8* %15, i8* %38, %struct.katcp_type* %16, i8* %115)
br label %121
119: ; preds = %114
%120 = tail call i32 @free(i8* %107)
br label %121
121: ; preds = %119, %117
%122 = icmp eq i8* %38, null
br i1 %122, label %125, label %123
123: ; preds = %121
%124 = tail call i32 @free(i8* %38)
br label %125
125: ; preds = %123, %121
%126 = add nuw nsw i32 %42, 1
br label %127
127: ; preds = %36, %46, %48, %51, %80, %82, %125
%128 = phi i32 [ %41, %36 ], [ 2, %82 ], [ 1, %125 ], [ 2, %80 ], [ 1, %51 ], [ 1, %48 ], [ 0, %46 ]
%129 = phi i32 [ %40, %36 ], [ %40, %82 ], [ %28, %125 ], [ %28, %80 ], [ %40, %51 ], [ %28, %48 ], [ %40, %46 ]
%130 = phi i32 [ %39, %36 ], [ %39, %82 ], [ %126, %125 ], [ %81, %80 ], [ %39, %51 ], [ %50, %48 ], [ %39, %46 ]
%131 = phi i8* [ %38, %36 ], [ %38, %82 ], [ null, %125 ], [ %76, %80 ], [ %38, %51 ], [ %38, %48 ], [ %38, %46 ]
%132 = add nuw nsw i64 %37, 1
%133 = icmp eq i64 %132, %34
br i1 %133, label %134, label %36
134: ; preds = %127, %20
%135 = phi i32 [ %27, %20 ], [ %128, %127 ]
%136 = phi i32 [ %26, %20 ], [ %129, %127 ]
%137 = phi i32 [ %25, %20 ], [ %130, %127 ]
%138 = phi i8* [ %24, %20 ], [ %131, %127 ]
%139 = add nuw i64 %21, 1
%140 = and i64 %139, 4294967295
%141 = getelementptr inbounds i8*, i8** %1, i64 %140
%142 = load i8*, i8** %141
%143 = icmp eq i8* %142, null
br i1 %143, label %144, label %20
144: ; preds = %134, %14, %109, %112, %10, %2, %4, %78
%145 = phi i8* [ null, %78 ], [ null, %4 ], [ null, %2 ], [ null, %10 ], [ null, %112 ], [ null, %109 ], [ %15, %14 ], [ %15, %134 ]
ret i8* %145
}