#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*/ remote_decode_nibble(char const *, unsigned int *);
int remote_decode_byte(const char *in, unsigned int *byte) {
  unsigned int ls_nibble;
  unsigned int ms_nibble;
  if (!remote_decode_nibble(in, &ms_nibble))
    return 0;
  if (!remote_decode_nibble(in + 1, &ls_nibble))
    return 0;
  *byte = (ms_nibble << 4) + ls_nibble;
  return (!0);
}


x86 assembly (clang, -O0):
<remote_decode_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <remote_decode_nibble@plt>
cmp    $0x0,%eax
jne    1142 <remote_decode_byte+0x32>
movl   $0x0,-0x4(%rbp)
jmp    117e <remote_decode_byte+0x6e>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <remote_decode_nibble@plt>
cmp    $0x0,%eax
jne    1168 <remote_decode_byte+0x58>
movl   $0x0,-0x4(%rbp)
jmp    117e <remote_decode_byte+0x6e>
mov    -0x20(%rbp),%ecx
shl    $0x4,%ecx
add    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remote_decode_byte>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <remote_decode_nibble@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1156 <remote_decode_byte+0x46>
add    $0x1,%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <remote_decode_nibble@plt>
test   %eax,%eax
je     1156 <remote_decode_byte+0x46>
mov    0x8(%rsp),%eax
shl    $0x4,%eax
add    0xc(%rsp),%eax
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @remote_decode_byte(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @remote_decode_nibble(i8* %0, i32* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = call i32 @remote_decode_nibble(i8* %10, i32* %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %9
%14 = load i32, i32* %4
%15 = shl i32 %14, 4
%16 = load i32, i32* %3
%17 = add i32 %15, %16
store i32 %17, i32* %1
br label %18
18: ; preds = %9, %2, %13
%19 = phi i32 [ 1, %13 ], [ 0, %2 ], [ 0, %9 ]
ret i32 %19
}