#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
void output_hex_text(FILE *fp, char *s, int ptr) {
  if (ptr == 0) {
    return;
  }
  s[ptr] = 0;
  int n;
  for (n = 0; n < ((16 - ptr) * 3) + 2; n++) {
    putc(' ', fp);
  }
  fprintf(fp, "%s", s);
}


x86 assembly (clang, -O0):
<output_hex_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1142 <output_hex_text+0x22>
jmp    119e <output_hex_text+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
sub    -0x14(%rbp),%ecx
imul   $0x3,%ecx,%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    118a <output_hex_text+0x6a>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <putc@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <output_hex_text+0x35>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_hex_text>:
test   %edx,%edx
je     1171 <output_hex_text+0x51>
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movslq %edx,%rax
movb   $0x0,(%rsi,%rax,1)
mov    $0x10,%eax
sub    %edx,%eax
lea    (%rax,%rax,2),%eax
cmp    $0xffffffff,%eax
jl     1162 <output_hex_text+0x42>
lea    (%rdx,%rdx,2),%eax
mov    $0x32,%ebp
sub    %eax,%ebp
xchg   %ax,%ax
mov    $0x20,%edi
mov    %rbx,%rsi
call   1040 <putc@plt>
add    $0xffffffff,%ebp
jne    1150 <output_hex_text+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fputs@plt>
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @output_hex_text(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %3
br label %33
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 0, i8* %15
store i32 0, i32* %7
br label %16
16: ; preds = %26, %11
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = sub nsw i32 16, %18
%20 = mul nsw i32 %19, 3
%21 = add nsw i32 %20, 2
%22 = icmp slt i32 %17, %21
br i1 %22, label %23, label %29
23: ; preds = %16
%24 = load i32*, i32** %4
%25 = call i32 @putc(i8 signext 32, i32* %24)
br label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %16
29: ; preds = %16
%30 = load i32*, i32** %4
%31 = load i8*, i8** %5
%32 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %29, %10
ret void
}

LLVM IR (-O2):
define void @output_hex_text(i32* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %21, label %5
5: ; preds = %3
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 0, i8* %7
%8 = sub nsw i32 16, %2
%9 = mul nsw i32 %8, 3
%10 = icmp sgt i32 %9, -2
br i1 %10, label %11, label %19
11: ; preds = %5
%12 = mul i32 %2, -3
%13 = add i32 %12, 49
br label %14
14: ; preds = %11, %14
%15 = phi i32 [ %17, %14 ], [ 0, %11 ]
%16 = tail call i32 @putc(i8 signext 32, i32* %0)
%17 = add nuw i32 %15, 1
%18 = icmp eq i32 %15, %13
br i1 %18, label %19, label %14
19: ; preds = %14, %5
%20 = tail call i32 @fputs(i8* %1, i32* %0)
br label %21
21: ; preds = %3, %19
ret void
}