#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 */
typedef int /*<<< orphan*/ uint64_t;
typedef size_t uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ rp_decode_uint32(char const **, size_t *, char);
int /*<<< orphan*/ rp_decode_uint64(char const **, int /*<<< orphan*/ *, char);
int rp_decode_mem(const char *in, uint64_t *addr, size_t *len) {
  uint32_t val;
  assert(in != NULL);
  assert(addr != NULL);
  assert(len != 0);
  if (!rp_decode_uint64(&in, addr, ','))
    return 0;
  if (!rp_decode_uint32(&in, &val, '\0'))
    return 0;
  *len = val;
  return (!0);
}


x86 assembly (clang, -O0):
<rp_decode_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdi
mov    $0x2c,%edx
call   1040 <rp_decode_uint64@plt>
cmp    $0x0,%eax
jne    11a1 <rp_decode_mem+0x71>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <rp_decode_mem+0xa7>
lea    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <rp_decode_uint32@plt>
cmp    $0x0,%eax
jne    11c5 <rp_decode_mem+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <rp_decode_mem+0xa7>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rp_decode_mem>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,0x8(%rsp)
xor    %eax,%eax
test   %rdi,%rdi
setne  %al
mov    %eax,%edi
call   1050 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1050 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x2c,%edx
call   1040 <rp_decode_uint64@plt>
test   %eax,%eax
je     11a9 <rp_decode_mem+0x79>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1030 <rp_decode_uint32@plt>
test   %eax,%eax
je     11ab <rp_decode_mem+0x7b>
mov    0x10(%rsp),%rax
mov    %rax,(%r14)
mov    $0x1,%ebx
jmp    11ab <rp_decode_mem+0x7b>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @rp_decode_mem(i8* %0, i32* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64*
%8 = alloca i64
store i8* %0, i8** %5
store i32* %1, i32** %6
store i64* %2, i64** %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i64*, i64** %7
%18 = icmp ne i64* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32*, i32** %6
%22 = call i32 @rp_decode_uint64(i8** %5, i32* %21, i8 signext 44)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %3
store i32 0, i32* %4
br label %32
25: ; preds = %3
%26 = call i32 @rp_decode_uint32(i8** %5, i64* %8, i8 signext 0)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %25
store i32 0, i32* %4
br label %32
29: ; preds = %25
%30 = load i64, i64* %8
%31 = load i64*, i64** %7
store i64 %30, i64* %31
store i32 1, i32* %4
br label %32
32: ; preds = %29, %28, %24
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @rp_decode_mem(i8* %0, i32* %1, i64* writeonly %2) {
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
%6 = bitcast i64* %5 to i8*
%7 = icmp ne i8* %0, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ne i32* %1, null
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp ne i64* %2, null
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = call i32 @rp_decode_uint64(i8** %4, i32* %1, i8 signext 44)
%17 = icmp eq i32 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %3
%19 = call i32 @rp_decode_uint32(i8** %4, i64* %5, i8 signext 0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = load i64, i64* %5
store i64 %22, i64* %2
br label %23
23: ; preds = %18, %3, %21
%24 = phi i32 [ 1, %21 ], [ 0, %3 ], [ 0, %18 ]
ret i32 %24
}