#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 /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ dump_data(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ printf(char *);
void read_data(uint8_t *data, uint32_t len) {
  if (len > 40) {
    printf("Data start:\n");
    dump_data(data, 20);
    printf("Data end:\n");
    dump_data(data + (len - 20), 20);
  } else {
    printf("Data:\n");
    dump_data(data, len);
  }
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x28,-0xc(%rbp)
jle    1181 <read_data+0x61>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x14,%esi
call   1040 <dump_data@plt>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
sub    $0x14,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    $0x14,%esi
call   1040 <dump_data@plt>
jmp    1199 <read_data+0x79>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <dump_data@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
cmp    $0x29,%esi
jl     1161 <read_data+0x41>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x14,%esi
call   1040 <dump_data@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
add    $0xffffffec,%ebx
lea    (%r14,%rbx,4),%rdi
mov    $0x14,%esi
jmp    1172 <read_data+0x52>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <dump_data@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Data start:\0A\00"
@.str.1 = [11 x i8] c"Data end:\0A\00"
@.str.2 = [7 x i8] c"Data:\0A\00"
define void @read_data(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sgt i32 %5, 40
br i1 %6, label %7, label %18
7: ; preds = %2
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = load i32*, i32** %3
%10 = call i32 @dump_data(i32* %9, i32 20)
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32*, i32** %3
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 20
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %12, i64 %15
%17 = call i32 @dump_data(i32* %16, i32 20)
br label %23
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32*, i32** %3
%21 = load i32, i32* %4
%22 = call i32 @dump_data(i32* %20, i32 %21)
br label %23
23: ; preds = %18, %7
ret void
}

LLVM IR (-O2):
@str = [6 x i8] c"Data:\00"
@str.3 = [12 x i8] c"Data start:\00"
@str.4 = [10 x i8] c"Data end:\00"
define void @read_data(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 40
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i32 @dump_data(i32* %0, i32 20)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0))
%8 = add nsw i32 %1, -20
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = tail call i32 @dump_data(i32* %10, i32 20)
br label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @dump_data(i32* %0, i32 %1)
br label %15
15: ; preds = %12, %4
ret void
}