#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 /*<<< orphan*/ assert(int);
int rp_decode_data(char const *, unsigned char *, size_t, size_t *);
int /*<<< orphan*/ rp_decode_uint32(char const **, unsigned int *, char);
int rp_decode_reg_assignment(const char *in, unsigned int *reg_no,
                             unsigned char *out, size_t out_size,
                             size_t *out_len) {
  assert(in != NULL);
  assert(reg_no != NULL);
  assert(out != NULL);
  assert(out_size > 0);
  assert(out_len != NULL);
  if (!rp_decode_uint32(&in, reg_no, '='))
    return 0;
  out_size -= 8;
  return rp_decode_data(in, out, out_size - 1, out_len);
}


x86 assembly (clang, -O0):
<rp_decode_reg_assignment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x28(%rbp)
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rsi
lea    -0x10(%rbp),%rdi
mov    $0x3d,%edx
call   1030 <rp_decode_uint32@plt>
cmp    $0x0,%eax
jne    11cd <rp_decode_reg_assignment+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    11f5 <rp_decode_reg_assignment+0xc5>
mov    -0x28(%rbp),%rax
sub    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
mov    -0x30(%rbp),%rcx
call   1050 <rp_decode_data@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rp_decode_reg_assignment>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,(%rsp)
xor    %eax,%eax
test   %rdi,%rdi
setne  %al
mov    %eax,%edi
call   1040 <assert@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    %rsp,%rdi
mov    %r12,%rsi
mov    $0x3d,%edx
call   1030 <rp_decode_uint32@plt>
test   %eax,%eax
je     11bb <rp_decode_reg_assignment+0x8b>
mov    (%rsp),%rdi
add    $0xfffffffffffffff7,%rbx
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <rp_decode_data@plt>
jmp    11bd <rp_decode_reg_assignment+0x8d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @rp_decode_reg_assignment(i8* %0, i32* %1, i8* %2, i64 %3, i64* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64*
store i8* %0, i8** %7
store i32* %1, i32** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i64* %4, i64** %11
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32*, i32** %8
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i8*, i8** %9
%21 = icmp ne i8* %20, null
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i64, i64* %10
%25 = icmp ugt i64 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i64*, i64** %11
%29 = icmp ne i64* %28, null
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32*, i32** %8
%33 = call i32 @rp_decode_uint32(i8** %7, i32* %32, i8 signext 61)
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %5
store i32 0, i32* %6
br label %45
36: ; preds = %5
%37 = load i64, i64* %10
%38 = sub i64 %37, 8
store i64 %38, i64* %10
%39 = load i8*, i8** %7
%40 = load i8*, i8** %9
%41 = load i64, i64* %10
%42 = sub i64 %41, 1
%43 = load i64*, i64** %11
%44 = call i32 @rp_decode_data(i8* %39, i8* %40, i64 %42, i64* %43)
store i32 %44, i32* %6
br label %45
45: ; preds = %36, %35
%46 = load i32, i32* %6
ret i32 %46
}

LLVM IR (-O2):
define i32 @rp_decode_reg_assignment(i8* %0, i32* %1, i8* %2, i64 %3, i64* %4) {
%6 = alloca i8*
store i8* %0, i8** %6
%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 i8* %2, null
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = icmp ne i64 %3, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = icmp ne i64* %4, null
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = call i32 @rp_decode_uint32(i8** %6, i32* %1, i8 signext 61)
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %5
%25 = load i8*, i8** %6
%26 = add i64 %3, -9
%27 = call i32 @rp_decode_data(i8* %25, i8* %2, i64 %26, i64* %4)
br label %28
28: ; preds = %5, %24
%29 = phi i32 [ %27, %24 ], [ 0, %5 ]
ret i32 %29
}