#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_list(char **expr, char *bin) {
  unsigned int length, total = 2;
  bin[0] = 7;
  bin++;
  (*expr)++;
  while (**expr != ']') {
    length = cpl_expr(expr, bin);
    skip_space(expr);
    bin += length;
    total += length;
  }
  (*expr)++;
  *bin = '\x00';
  return total;
}


x86 assembly (clang, -O0):
<cpl_list>:
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   $0x7,(%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    $0x5d,%eax
je     11a2 <cpl_list+0x82>
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_list+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_list>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movb   $0x7,(%rsi)
add    $0x1,%rbx
mov    (%rdi),%rcx
lea    0x1(%rcx),%rax
mov    %rax,(%rdi)
mov    $0x2,%r15d
cmpb   $0x5d,0x1(%rcx)
je     1175 <cpl_list+0x55>
mov    $0x2,%r15d
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <cpl_expr@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <skip_space@plt>
mov    %ebp,%eax
add    %rax,%rbx
add    %ebp,%r15d
mov    (%r14),%rax
cmpb   $0x5d,(%rax)
jne    1150 <cpl_list+0x30>
add    $0x1,%rax
mov    %rax,(%r14)
movb   $0x0,(%rbx)
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cpl_list(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 7, 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, 93
br i1 %19, label %20, label %33
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 i8**, i8*** %3
%25 = call i32 @skip_space(i8** %24)
%26 = load i32, i32* %5
%27 = load i8*, i8** %4
%28 = zext i32 %26 to i64
%29 = getelementptr inbounds i8, i8* %27, i64 %28
store i8* %29, i8** %4
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = add i32 %31, %30
store i32 %32, i32* %6
br label %14
33: ; preds = %14
%34 = load i8**, i8*** %3
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %34
%37 = load i8*, i8** %4
store i8 0, i8* %37
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
define i32 @cpl_list(i8** %0, i8* %1) {
store i8 7, 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, 93
br i1 %7, label %19, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %15, %8 ], [ 2, %2 ]
%10 = phi i8* [ %14, %8 ], [ %3, %2 ]
%11 = tail call i32 @cpl_expr(i8** %0, i8* %10)
%12 = tail call i32 @skip_space(i8** %0)
%13 = zext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = add i32 %11, %9
%16 = load i8*, i8** %0
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 93
br i1 %18, label %19, label %8
19: ; preds = %8, %2
%20 = phi i8* [ %3, %2 ], [ %14, %8 ]
%21 = phi i32 [ 2, %2 ], [ %15, %8 ]
%22 = phi i8* [ %5, %2 ], [ %16, %8 ]
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %0
store i8 0, i8* %20
ret i32 %21
}