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

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/ *, int);
void _ld_blocks_to_str(uint64_t *blocks, char *message, uint8_t num_blocks) {
  uint8_t i = 0, j = 0;
  for (; i < num_blocks; i++, j += 8) {
    memcpy(message + j, &blocks[i], sizeof(uint64_t));
  }
}


x86 assembly (clang, -O0):
<_ld_blocks_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1178 <_ld_blocks_to_str+0x68>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <_ld_blocks_to_str+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ld_blocks_to_str>:
push   %r15
push   %r14
push   %rbx
test   %edx,%edx
jle    114e <_ld_blocks_to_str+0x3e>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x4,%rbx
add    $0x8,%r14
add    $0xffffffffffffffff,%r15
jne    1130 <_ld_blocks_to_str+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @_ld_blocks_to_str(i32* %0, i8* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %16
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %13, %7 ]
%9 = phi i64 [ 0, %5 ], [ %14, %7 ]
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = getelementptr inbounds i32, i32* %0, i64 %8
%12 = tail call i32 @memcpy(i8* %10, i32* %11, i32 4)
%13 = add nuw nsw i64 %8, 1
%14 = add nuw nsw i64 %9, 8
%15 = icmp eq i64 %13, %6
br i1 %15, label %16, label %7
16: ; preds = %7, %3
ret void
}