#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*/ db_printf0(char *);
int /*<<< orphan*/ db_printf1(char *, int /*<<< orphan*/);
void db_send_memory(int addr, int size) {
  unsigned int *ptr = (unsigned int *)addr;
  int i;
  db_printf0("*DEBUG*:D:R:M:");
  for (i = 1; i <= size; i++) {
    db_printf1("%i", *ptr++);
    if (i != size) {
      db_printf0(",");
    }
  }
  db_printf0("\n");
}


x86 assembly (clang, -O0):
<db_send_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1040 <db_printf0@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119d <db_send_memory+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
call   1030 <db_printf1@plt>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     118a <db_send_memory+0x6a>
lea    0xe8d(%rip),%rdi
call   1040 <db_printf0@plt>
jmp    118f <db_send_memory+0x6f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <db_send_memory+0x29>
lea    0xe70(%rip),%rdi
call   1040 <db_printf0@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_send_memory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
mov    %edi,%ebp
lea    0xec9(%rip),%rdi
call   1040 <db_printf0@plt>
test   %r13d,%r13d
jle    118b <db_send_memory+0x6b>
movslq %ebp,%r12
neg    %r13d
xor    %ebp,%ebp
lea    0xebf(%rip),%r14
lea    0xebb(%rip),%r15
jmp    116b <db_send_memory+0x4b>
nopl   0x0(%rax)
add    $0x1,%rbp
mov    %ebp,%eax
add    %r13d,%eax
je     118b <db_send_memory+0x6b>
lea    0x0(%r13,%rbp,1),%ebx
mov    (%r12,%rbp,4),%esi
mov    %r14,%rdi
call   1030 <db_printf1@plt>
cmp    $0xffffffff,%ebx
je     1160 <db_send_memory+0x40>
mov    %r15,%rdi
call   1040 <db_printf0@plt>
jmp    1160 <db_send_memory+0x40>
lea    0xe82(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <db_printf0@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"*DEBUG*:D:R:M:\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @db_send_memory(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %5
%10 = call i32 @db_printf0(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %11
11: ; preds = %26, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i32 1
store i32* %17, i32** %5
%18 = load i32, i32* %16
%19 = call i32 @db_printf1(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = call i32 @db_printf0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %15
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %11
29: ; preds = %11
%30 = call i32 @db_printf0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"*DEBUG*:D:R:M:\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @db_send_memory(i32 %0, i32 %1) {
%3 = tail call i32 @db_printf0(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i32 %1, 1
br i1 %4, label %20, label %5
5: ; preds = %2
%6 = sext i32 %0 to i64
%7 = inttoptr i64 %6 to i32*
br label %8
8: ; preds = %5, %17
%9 = phi i32 [ %18, %17 ], [ 1, %5 ]
%10 = phi i32* [ %11, %17 ], [ %7, %5 ]
%11 = getelementptr inbounds i32, i32* %10, i64 1
%12 = load i32, i32* %10
%13 = tail call i32 @db_printf1(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %9, %1
br i1 %14, label %17, label %15
15: ; preds = %8
%16 = tail call i32 @db_printf0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %8, %15
%18 = add nuw i32 %9, 1
%19 = icmp eq i32 %9, %1
br i1 %19, label %20, label %8
20: ; preds = %17, %2
%21 = tail call i32 @db_printf0(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}