#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 */
unsigned int dectou(char const *);
scalar_t__ hextou(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
char *skipstring(char *);
void command_R(char *params) {
  unsigned char *address = (unsigned char *)hextou(params);
  const char *q = skipstring(params);
  unsigned length = 16;
  if (*q)
    length = dectou(q);
  while (length) {
    unsigned ll = 16;
    if (length < 16)
      ll = length;
    printf("%p", address);
    unsigned sep = ':';
    for (unsigned i = 0; i != ll; ++i) {
      printf("%c%02x", sep, address[i]);
      sep = ' ';
    }
    putchar('\n');
    length -= ll;
    address += ll;
  }
}


x86 assembly (clang, -O0):
<command_R>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <hextou@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <skipstring@plt>
mov    %rax,-0x18(%rbp)
movl   $0x10,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1196 <command_R+0x46>
mov    -0x18(%rbp),%rdi
call   1060 <dectou@plt>
mov    %eax,-0x1c(%rbp)
jmp    119b <command_R+0x4b>
cmpl   $0x0,-0x1c(%rbp)
je     1243 <command_R+0xf3>
movl   $0x10,-0x20(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jae    11bc <command_R+0x6c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x3a,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1219 <command_R+0xc9>
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x20,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11dc <command_R+0x8c>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    119b <command_R+0x4b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command_R>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbp
call   1070 <hextou@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <skipstring@plt>
mov    $0x10,%r15d
cmpb   $0x0,(%rax)
je     118c <command_R+0x3c>
mov    %rax,%rdi
call   1060 <dectou@plt>
mov    %eax,%r15d
test   %eax,%eax
je     121f <command_R+0xcf>
lea    0xe70(%rip),%r13
jmp    11b2 <command_R+0x62>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %rbp,%rbx
sub    %r12d,%r15d
je     121f <command_R+0xcf>
cmp    $0x10,%r15d
mov    $0x10,%r12d
cmovb  %r15d,%r12d
lea    0xe39(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rbx),%edx
mov    %r13,%rdi
mov    $0x3a,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%ebp
cmp    $0x1,%r12d
je     11a0 <command_R+0x50>
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%r14,1),%edx
mov    %r13,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14
cmp    %r14d,%ebp
jne    1200 <command_R+0xb0>
jmp    11a0 <command_R+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%p\00"
@.str.1 = [7 x i8] c"%c%02x\00"
define void @command_R(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i64 @hextou(i8* %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %3
%12 = load i8*, i8** %2
%13 = call i8* @skipstring(i8* %12)
store i8* %13, i8** %4
store i32 16, i32* %5
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i8*, i8** %4
%19 = call i32 @dectou(i8* %18)
store i32 %19, i32* %5
br label %20
20: ; preds = %17, %1
br label %21
21: ; preds = %48, %20
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %57
24: ; preds = %21
store i32 16, i32* %6
%25 = load i32, i32* %5
%26 = icmp ult i32 %25, 16
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = load i32, i32* %5
store i32 %28, i32* %6
br label %29
29: ; preds = %27, %24
%30 = load i8*, i8** %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %30)
store i32 58, i32* %7
store i32 0, i32* %8
br label %32
32: ; preds = %45, %29
%33 = load i32, i32* %8
%34 = load i32, i32* %6
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %48
36: ; preds = %32
%37 = load i32, i32* %7
%38 = load i8*, i8** %3
%39 = load i32, i32* %8
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %43)
store i32 32, i32* %7
br label %45
45: ; preds = %36
%46 = load i32, i32* %8
%47 = add i32 %46, 1
store i32 %47, i32* %8
br label %32
48: ; preds = %32
%49 = call i32 @putchar(i8 signext 10)
%50 = load i32, i32* %6
%51 = load i32, i32* %5
%52 = sub i32 %51, %50
store i32 %52, i32* %5
%53 = load i32, i32* %6
%54 = load i8*, i8** %3
%55 = zext i32 %53 to i64
%56 = getelementptr inbounds i8, i8* %54, i64 %55
store i8* %56, i8** %3
br label %21
57: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%p\00"
@.str.1 = [7 x i8] c"%c%02x\00"
define void @command_R(i8* %0) {
%2 = tail call i64 @hextou(i8* %0)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i8* @skipstring(i8* %0)
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = tail call i32 @dectou(i8* %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %37, label %10
10: ; preds = %1, %7
%11 = phi i32 [ 16, %1 ], [ %8, %7 ]
br label %12
12: ; preds = %10, %22
%13 = phi i32 [ %24, %22 ], [ %11, %10 ]
%14 = phi i8* [ %26, %22 ], [ %3, %10 ]
%15 = icmp ult i32 %13, 16
%16 = select i1 %15, i32 %13, i32 16
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%18 = load i8, i8* %14
%19 = zext i8 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 58, i32 %19)
%21 = icmp eq i32 %16, 1
br i1 %21, label %22, label %28
22: ; preds = %28, %12
%23 = tail call i32 @putchar(i8 signext 10)
%24 = sub i32 %13, %16
%25 = zext i32 %16 to i64
%26 = getelementptr inbounds i8, i8* %14, i64 %25
%27 = icmp eq i32 %24, 0
br i1 %27, label %37, label %12
28: ; preds = %12, %28
%29 = phi i64 [ %34, %28 ], [ 1, %12 ]
%30 = getelementptr inbounds i8, i8* %14, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 32, i32 %32)
%34 = add nuw nsw i64 %29, 1
%35 = trunc i64 %34 to i32
%36 = icmp eq i32 %16, %35
br i1 %36, label %22, label %28
37: ; preds = %22, %7
ret void
}