#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 size_t uint64_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int ascii_dump(uint8_t *buf, uint64_t count) {
  if (buf == NULL)
    return EXIT_FAILURE;
  uint64_t i;
  for (i = 0; i < count; i++) {
    if (buf[i] <= 31 || buf[i] >= 127)
      fprintf(stdout, ".");
    else
      fprintf(stdout, "%c", (char)buf[i]);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<ascii_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113c <ascii_dump+0x2c>
mov    0x2eae(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <ascii_dump+0xc9>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11cd <ascii_dump+0xbd>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpl   $0x1f,(%rax,%rcx,4)
jle    1176 <ascii_dump+0x66>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpl   $0x7f,(%rax,%rcx,4)
jl     1192 <ascii_dump+0x82>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11b7 <ascii_dump+0xa7>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
movsbl %al,%edx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11bc <ascii_dump+0xac>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <ascii_dump+0x34>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ascii_dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     117e <ascii_dump+0x6e>
mov    %rsi,%r14
mov    0x2ea6(%rip),%rax
test   %rsi,%rsi
je     118e <ascii_dump+0x7e>
mov    %rdi,%rbx
mov    0x2e9f(%rip),%rbp
lea    0xec0(%rip),%r15
lea    0xebb(%rip),%r12
xor    %r13d,%r13d
jmp    1163 <ascii_dump+0x53>
nopl   0x0(%rax)
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
je     1187 <ascii_dump+0x77>
mov    (%rbx,%r13,4),%edx
lea    -0x7f(%rdx),%eax
mov    0x0(%rbp),%edi
cmp    $0xffffffa0,%eax
ja     1150 <ascii_dump+0x40>
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    115a <ascii_dump+0x4a>
mov    0x2e5b(%rip),%rax
jmp    118e <ascii_dump+0x7e>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @ascii_dump(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %3
br label %46
11: ; preds = %2
store i64 0, i64* %6
br label %12
12: ; preds = %41, %11
%13 = load i64, i64* %6
%14 = load i64, i64* %5
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i64, i64* %6
%19 = getelementptr inbounds i32, i32* %17, i64 %18
%20 = load i32, i32* %19
%21 = icmp sle i32 %20, 31
br i1 %21, label %28, label %22
22: ; preds = %16
%23 = load i32*, i32** %4
%24 = load i64, i64* %6
%25 = getelementptr inbounds i32, i32* %23, i64 %24
%26 = load i32, i32* %25
%27 = icmp sge i32 %26, 127
br i1 %27, label %28, label %31
28: ; preds = %22, %16
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %40
31: ; preds = %22
%32 = load i32, i32* @stdout
%33 = load i32*, i32** %4
%34 = load i64, i64* %6
%35 = getelementptr inbounds i32, i32* %33, i64 %34
%36 = load i32, i32* %35
%37 = trunc i32 %36 to i8
%38 = sext i8 %37 to i32
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %31, %28
br label %41
41: ; preds = %40
%42 = load i64, i64* %6
%43 = add i64 %42, 1
store i64 %43, i64* %6
br label %12
44: ; preds = %12
%45 = load i32, i32* @EXIT_SUCCESS
store i32 %45, i32* %3
br label %46
46: ; preds = %44, %9
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str = [2 x i8] c".\00"
@.str.1 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @ascii_dump(i32* %0, i64 %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %20, label %4
4: ; preds = %2
%5 = icmp eq i64 %1, 0
br i1 %5, label %20, label %6
6: ; preds = %4, %17
%7 = phi i64 [ %18, %17 ], [ 0, %4 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = add i32 %9, -127
%11 = icmp ult i32 %10, -95
%12 = load i32, i32* @stdout
br i1 %11, label %13, label %15
13: ; preds = %6
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
15: ; preds = %6
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %17
17: ; preds = %13, %15
%18 = add nuw i64 %7, 1
%19 = icmp eq i64 %18, %1
br i1 %19, label %20, label %6
20: ; preds = %17, %4, %2
%21 = phi i32* [ @EXIT_FAILURE, %2 ], [ @EXIT_SUCCESS, %4 ], [ @EXIT_SUCCESS, %17 ]
%22 = load i32, i32* %21
ret i32 %22
}