#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*/ log_message(char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int read_long_data(unsigned char *packet, unsigned char *data) {
  int size = packet[0] - 3;
  if (size > 32) {
    log_message("operations: read_long_data: size is bigger than max size");
    return 0;
  }
  memcpy(data, (packet + 1), size);
  return size;
}


x86 assembly (clang, -O0):
<read_long_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sub    $0x3,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jle    115f <read_long_data+0x3f>
lea    0xeb2(%rip),%rdi
call   1040 <log_message@plt>
movl   $0x0,-0x4(%rbp)
jmp    1179 <read_long_data+0x59>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x1c(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_long_data>:
push   %rbx
movzbl (%rdi),%ebx
cmp    $0x24,%ebx
jb     1139 <read_long_data+0x19>
lea    0xed0(%rip),%rdi
call   1040 <log_message@plt>
xor    %ebx,%ebx
jmp    1150 <read_long_data+0x30>
mov    %rdi,%rax
add    $0xfffffffd,%ebx
add    $0x1,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"operations: read_long_data: size is bigger than max size\00"
define i32 @read_long_data(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = sub nsw i32 %10, 3
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 32
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @log_message(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %23
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i32, i32* %6
%21 = call i32 @memcpy(i8* %17, i8* %19, i32 %20)
%22 = load i32, i32* %6
store i32 %22, i32* %3
br label %23
23: ; preds = %16, %14
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str = [57 x i8] c"operations: read_long_data: size is bigger than max size\00"
define i32 @read_long_data(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = zext i8 %3 to i32
%5 = add nsw i32 %4, -3
%6 = icmp ugt i8 %3, 35
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @log_message(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %12
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = tail call i32 @memcpy(i8* %1, i8* %10, i32 %5)
br label %12
12: ; preds = %9, %7
%13 = phi i32 [ 0, %7 ], [ %5, %9 ]
ret i32 %13
}