#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*/ tea_decode(int *, int *);
void tea_decode_buffer(char *in_buffer, unsigned int in_size, int *key) {
  char *p;
  unsigned int remain = in_size % 8;
  unsigned int align_size = in_size - remain;
  for (p = in_buffer; p < in_buffer + align_size; p += 8)
    tea_decode((int *)p, key);
}


x86 assembly (clang, -O0):
<tea_decode_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%edx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    1172 <tea_decode_buffer+0x62>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <tea_decode@plt>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    113d <tea_decode_buffer+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tea_decode_buffer>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
and    $0xfffffff8,%r15d
je     1144 <tea_decode_buffer+0x34>
mov    %rdx,%r14
mov    %rdi,%rbx
add    %rdi,%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <tea_decode@plt>
add    $0x8,%rbx
cmp    %r15,%rbx
jb     1130 <tea_decode_buffer+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @tea_decode_buffer(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%10 = load i32, i32* %5
%11 = urem i32 %10, 8
store i32 %11, i32* %8
%12 = load i32, i32* %5
%13 = load i32, i32* %8
%14 = sub i32 %12, %13
store i32 %14, i32* %9
%15 = load i8*, i8** %4
store i8* %15, i8** %7
br label %16
16: ; preds = %28, %3
%17 = load i8*, i8** %7
%18 = load i8*, i8** %4
%19 = load i32, i32* %9
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = icmp ult i8* %17, %21
br i1 %22, label %23, label %31
23: ; preds = %16
%24 = load i8*, i8** %7
%25 = bitcast i8* %24 to i32*
%26 = load i32*, i32** %6
%27 = call i32 @tea_decode(i32* %25, i32* %26)
br label %28
28: ; preds = %23
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 8
store i8* %30, i8** %7
br label %16
31: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @tea_decode_buffer(i8* %0, i32 %1, i32* %2) {
%4 = and i32 %1, -8
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = icmp eq i32 %4, 0
br i1 %7, label %14, label %8
8: ; preds = %3, %8
%9 = phi i8* [ %12, %8 ], [ %0, %3 ]
%10 = bitcast i8* %9 to i32*
%11 = tail call i32 @tea_decode(i32* %10, i32* %2)
%12 = getelementptr inbounds i8, i8* %9, i64 8
%13 = icmp ult i8* %12, %6
br i1 %13, label %8, label %14
14: ; preds = %8, %3
ret void
}