#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ rp_decode_nibble(char const *, unsigned int *);
int rp_decode_4bytes(const char *in, uint32_t *val) {
  unsigned int nibble;
  uint32_t tmp;
  int count;
  for (tmp = 0, count = 0; count < 8; count++, in++) {
    if (!rp_decode_nibble(in, &nibble))
      break;
    tmp = (tmp << 4) + nibble;
  }
  *val = tmp;
  return (!0);
}


x86 assembly (clang, -O0):
<rp_decode_4bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1179 <rp_decode_4bytes+0x69>
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <rp_decode_nibble@plt>
cmp    $0x0,%eax
jne    1153 <rp_decode_4bytes+0x43>
jmp    1179 <rp_decode_4bytes+0x69>
mov    -0x18(%rbp),%eax
shl    $0x4,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112e <rp_decode_4bytes+0x1e>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rp_decode_4bytes>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f0 <rp_decode_4bytes+0xe0>
mov    0xc(%rsp),%ebp
lea    0x1(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
lea    0x2(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
lea    0x3(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
lea    0x4(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
lea    0x5(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
lea    0x6(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
add    $0x7,%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <rp_decode_nibble@plt>
test   %eax,%eax
je     11f2 <rp_decode_4bytes+0xe2>
shl    $0x4,%ebp
add    0xc(%rsp),%ebp
jmp    11f2 <rp_decode_4bytes+0xe2>
xor    %ebp,%ebp
mov    %ebp,(%r14)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rp_decode_4bytes(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %21, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = call i32 @rp_decode_nibble(i8* %12, i32* %5)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
br label %26
16: ; preds = %11
%17 = load i32, i32* %6
%18 = shl i32 %17, 4
%19 = load i32, i32* %5
%20 = add i32 %18, %19
store i32 %20, i32* %6
br label %21
21: ; preds = %16
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
br label %8
26: ; preds = %15, %8
%27 = load i32, i32* %6
%28 = load i32*, i32** %4
store i32 %27, i32* %28
ret i32 1
}

LLVM IR (-O2):
define i32 @rp_decode_4bytes(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @rp_decode_nibble(i8* %0, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %58, label %7
7: ; preds = %2
%8 = load i32, i32* %3
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = call i32 @rp_decode_nibble(i8* %9, i32* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %58, label %12
12: ; preds = %7
%13 = shl i32 %8, 4
%14 = load i32, i32* %3
%15 = add i32 %14, %13
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = call i32 @rp_decode_nibble(i8* %16, i32* %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %58, label %19
19: ; preds = %12
%20 = shl i32 %15, 4
%21 = load i32, i32* %3
%22 = add i32 %21, %20
%23 = getelementptr inbounds i8, i8* %0, i64 3
%24 = call i32 @rp_decode_nibble(i8* %23, i32* %3)
%25 = icmp eq i32 %24, 0
br i1 %25, label %58, label %26
26: ; preds = %19
%27 = shl i32 %22, 4
%28 = load i32, i32* %3
%29 = add i32 %28, %27
%30 = getelementptr inbounds i8, i8* %0, i64 4
%31 = call i32 @rp_decode_nibble(i8* %30, i32* %3)
%32 = icmp eq i32 %31, 0
br i1 %32, label %58, label %33
33: ; preds = %26
%34 = shl i32 %29, 4
%35 = load i32, i32* %3
%36 = add i32 %35, %34
%37 = getelementptr inbounds i8, i8* %0, i64 5
%38 = call i32 @rp_decode_nibble(i8* %37, i32* %3)
%39 = icmp eq i32 %38, 0
br i1 %39, label %58, label %40
40: ; preds = %33
%41 = shl i32 %36, 4
%42 = load i32, i32* %3
%43 = add i32 %42, %41
%44 = getelementptr inbounds i8, i8* %0, i64 6
%45 = call i32 @rp_decode_nibble(i8* %44, i32* %3)
%46 = icmp eq i32 %45, 0
br i1 %46, label %58, label %47
47: ; preds = %40
%48 = shl i32 %43, 4
%49 = load i32, i32* %3
%50 = add i32 %49, %48
%51 = getelementptr inbounds i8, i8* %0, i64 7
%52 = call i32 @rp_decode_nibble(i8* %51, i32* %3)
%53 = icmp eq i32 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %47
%55 = shl i32 %50, 4
%56 = load i32, i32* %3
%57 = add i32 %56, %55
br label %58
58: ; preds = %54, %47, %40, %33, %26, %19, %12, %7, %2
%59 = phi i32 [ 0, %2 ], [ %8, %7 ], [ %15, %12 ], [ %22, %19 ], [ %29, %26 ], [ %36, %33 ], [ %43, %40 ], [ %50, %47 ], [ %57, %54 ]
store i32 %59, i32* %1
ret i32 1
}