#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_byte(char const *, unsigned int *);
int remote_decode_4bytes(const char *in, unsigned int *val) {
  unsigned int tmp;
  unsigned int byte;
  int i;
  tmp = 0;
  for (i = 0; i < 4; i++, in += 2) {
    if (!remote_decode_byte(in, &byte))
      return 0;
    tmp = (tmp << 8) + byte;
  }
  *val = tmp;
  return (!0);
}


x86 assembly (clang, -O0):
<remote_decode_4bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1180 <remote_decode_4bytes+0x70>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <remote_decode_byte@plt>
cmp    $0x0,%eax
jne    115a <remote_decode_4bytes+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1190 <remote_decode_4bytes+0x80>
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    112e <remote_decode_4bytes+0x1e>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remote_decode_4bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x4(%rsp),%rsi
call   1030 <remote_decode_byte@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1198 <remote_decode_4bytes+0x88>
mov    0x4(%rsp),%r15d
lea    0x2(%rbx),%rdi
lea    0x4(%rsp),%rsi
call   1030 <remote_decode_byte@plt>
test   %eax,%eax
je     1198 <remote_decode_4bytes+0x88>
mov    0x4(%rsp),%r12d
lea    0x4(%rbx),%rdi
lea    0x4(%rsp),%rsi
call   1030 <remote_decode_byte@plt>
test   %eax,%eax
je     1198 <remote_decode_4bytes+0x88>
mov    0x4(%rsp),%r13d
add    $0x6,%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <remote_decode_byte@plt>
test   %eax,%eax
je     1198 <remote_decode_4bytes+0x88>
shl    $0x8,%r15d
add    %r15d,%r12d
shl    $0x8,%r12d
add    %r12d,%r13d
shl    $0x8,%r13d
add    0x4(%rsp),%r13d
mov    %r13d,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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