#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 */

/* Variables and functions */
unsigned int cpl_expr(char **, char *);
int /*<<< orphan*/ skip_space(char **);
unsigned int cpl_dict(char **expr, char *bin) {
  unsigned int length, total = 2;
  bin[0] = 9;
  bin++;
  (*expr)++;
  while (**expr != '}') {
    length = cpl_expr(expr, bin);
    bin += length;
    total += length;
    (*expr)++;
    length = cpl_expr(expr, bin);
    skip_space(expr);
    bin += length;
    total += length;
  }
  (*expr)++;
  *bin = '\x00';
  return total;
}


x86 assembly (clang, -O0):
<cpl_dict>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x9,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
je     11d9 <cpl_dict+0xb9>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <cpl_expr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <cpl_expr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <skip_space@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <cpl_dict+0x38>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpl_dict>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
movb   $0x9,(%rsi)
add    $0x1,%rbx
mov    (%rdi),%rcx
lea    0x1(%rcx),%rax
mov    %rax,(%rdi)
mov    $0x2,%ebp
cmpb   $0x7d,0x1(%rcx)
je     118e <cpl_dict+0x6e>
mov    $0x2,%ebp
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <cpl_expr@plt>
mov    %eax,%r15d
add    %rbx,%r15
add    %eax,%ebp
addq   $0x1,(%r14)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <cpl_expr@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1030 <skip_space@plt>
mov    %r12d,%ebx
add    %r15,%rbx
add    %r12d,%ebp
mov    (%r14),%rax
cmpb   $0x7d,(%rax)
jne    1150 <cpl_dict+0x30>
add    $0x1,%rax
mov    %rax,(%r14)
movb   $0x0,(%rbx)
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cpl_dict(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
store i32 2, i32* %6
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 9, i8* %8
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %4
%11 = load i8**, i8*** %3
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %11
br label %14
14: ; preds = %20, %2
%15 = load i8**, i8*** %3
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 125
br i1 %19, label %20, label %46
20: ; preds = %14
%21 = load i8**, i8*** %3
%22 = load i8*, i8** %4
%23 = call i32 @cpl_expr(i8** %21, i8* %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = load i8*, i8** %4
%26 = zext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8* %27, i8** %4
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = add i32 %29, %28
store i32 %30, i32* %6
%31 = load i8**, i8*** %3
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %31
%34 = load i8**, i8*** %3
%35 = load i8*, i8** %4
%36 = call i32 @cpl_expr(i8** %34, i8* %35)
store i32 %36, i32* %5
%37 = load i8**, i8*** %3
%38 = call i32 @skip_space(i8** %37)
%39 = load i32, i32* %5
%40 = load i8*, i8** %4
%41 = zext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %40, i64 %41
store i8* %42, i8** %4
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = add i32 %44, %43
store i32 %45, i32* %6
br label %14
46: ; preds = %14
%47 = load i8**, i8*** %3
%48 = load i8*, i8** %47
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %47
%50 = load i8*, i8** %4
store i8 0, i8* %50
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
define i32 @cpl_dict(i8** %0, i8* %1) {
store i8 9, i8* %1
%3 = getelementptr inbounds i8, i8* %1, i64 1
%4 = load i8*, i8** %0
%5 = getelementptr inbounds i8, i8* %4, i64 1
store i8* %5, i8** %0
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 125
br i1 %7, label %25, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %21, %8 ], [ 2, %2 ]
%10 = phi i8* [ %20, %8 ], [ %3, %2 ]
%11 = tail call i32 @cpl_expr(i8** %0, i8* %10)
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = add i32 %11, %9
%15 = load i8*, i8** %0
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %16, i8** %0
%17 = tail call i32 @cpl_expr(i8** %0, i8* %13)
%18 = tail call i32 @skip_space(i8** %0)
%19 = zext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %13, i64 %19
%21 = add i32 %14, %17
%22 = load i8*, i8** %0
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 125
br i1 %24, label %25, label %8
25: ; preds = %8, %2
%26 = phi i8* [ %3, %2 ], [ %20, %8 ]
%27 = phi i32 [ 2, %2 ], [ %21, %8 ]
%28 = phi i8* [ %5, %2 ], [ %22, %8 ]
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8* %29, i8** %0
store i8 0, i8* %26
ret i32 %27
}