#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 */
char *calloc(unsigned int, int);
int /*<<< orphan*/ unmarshal(char const *, char **);
int sqlunmarshal(const char *ct, char **tarr, unsigned int *slen) {
  unsigned int a = 0;
  *slen = ct[1];
  for (a = 0; a < ct[0]; a++)
    tarr[a] = calloc(*slen + 1, sizeof(char));
  unmarshal(ct, tarr);
  return (int)ct[0];
}


x86 assembly (clang, -O0):
<sqlunmarshal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jae    1191 <sqlunmarshal+0x71>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1150 <sqlunmarshal+0x30>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <unmarshal@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlunmarshal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movsbl 0x1(%rdi),%ebp
mov    %ebp,(%rdx)
cmpb   $0x0,(%rdi)
je     115f <sqlunmarshal+0x3f>
add    $0x1,%ebp
xor    %ebx,%ebx
nopl   (%rax)
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
movsbq (%r15),%rax
mov    %eax,%eax
cmp    %rax,%rbx
jb     1140 <sqlunmarshal+0x20>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <unmarshal@plt>
movsbl (%r15),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sqlunmarshal(i8* %0, i8** %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = load i32*, i32** %6
store i32 %11, i32* %12
store i32 0, i32* %7
br label %13
13: ; preds = %29, %3
%14 = load i32, i32* %7
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ult i32 %14, %18
br i1 %19, label %20, label %32
20: ; preds = %13
%21 = load i32*, i32** %6
%22 = load i32, i32* %21
%23 = add i32 %22, 1
%24 = call i8* @calloc(i32 %23, i32 1)
%25 = load i8**, i8*** %5
%26 = load i32, i32* %7
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
store i8* %24, i8** %28
br label %29
29: ; preds = %20
%30 = load i32, i32* %7
%31 = add i32 %30, 1
store i32 %31, i32* %7
br label %13
32: ; preds = %13
%33 = load i8*, i8** %4
%34 = load i8**, i8*** %5
%35 = call i32 @unmarshal(i8* %33, i8** %34)
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
ret i32 %39
}

LLVM IR (-O2):
define i32 @sqlunmarshal(i8* %0, i8** %1, i32* nocapture %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
store i32 %6, i32* %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %3
%10 = add nsw i32 %6, 1
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %15, %11 ]
%13 = tail call i8* @calloc(i32 %10, i32 1)
%14 = getelementptr inbounds i8*, i8** %1, i64 %12
store i8* %13, i8** %14
%15 = add nuw nsw i64 %12, 1
%16 = load i8, i8* %0
%17 = sext i8 %16 to i64
%18 = and i64 %17, 4294967295
%19 = icmp ult i64 %15, %18
br i1 %19, label %11, label %20
20: ; preds = %11, %3
%21 = tail call i32 @unmarshal(i8* %0, i8** %1)
%22 = load i8, i8* %0
%23 = sext i8 %22 to i32
ret i32 %23
}