#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 */
int sn_decode_crlf(char **, char *);
int /*<<< orphan*/ sn_decode_has(char *, char *, int);
int sn_decode_value(char **p, char *end, int size, char **result) {
  char *start = *p;
  if (!sn_decode_has(start, end, size))
    return (-1);
  *p += size;
  int rc = sn_decode_crlf(p, end);
  if (rc < 0)
    return rc;
  *result = start;
  return size;
}


x86 assembly (clang, -O0):
<sn_decode_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <sn_decode_has@plt>
cmp    $0x0,%eax
jne    1167 <sn_decode_value+0x47>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <sn_decode_value+0x90>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <sn_decode_crlf@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    119f <sn_decode_value+0x7f>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <sn_decode_value+0x90>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sn_decode_value>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%rbx
mov    (%rdi),%r15
mov    %r15,%rdi
call   1030 <sn_decode_has@plt>
test   %eax,%eax
je     115c <sn_decode_value+0x3c>
movslq %ebp,%rax
add    %rax,(%rbx)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <sn_decode_crlf@plt>
test   %eax,%eax
js     1163 <sn_decode_value+0x43>
mov    %r15,(%r14)
jmp    1165 <sn_decode_value+0x45>
mov    $0xffffffff,%ebp
jmp    1165 <sn_decode_value+0x45>
mov    %eax,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @sn_decode_value(i8** %0, i8* %1, i32 %2, i8** nocapture writeonly %3) {
%5 = load i8*, i8** %0
%6 = tail call i32 @sn_decode_has(i8* %5, i8* %1, i32 %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = load i8*, i8** %0
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds i8, i8* %9, i64 %10
store i8* %11, i8** %0
%12 = tail call i32 @sn_decode_crlf(i8** %0, i8* %1)
%13 = icmp slt i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %8
store i8* %5, i8** %3
br label %15
15: ; preds = %14, %8, %4
%16 = phi i32 [ -1, %4 ], [ %2, %14 ], [ %12, %8 ]
ret i32 %16
}