#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*/ isprint(char);
void repr_binary_data(char *bin, int len) {
  if (len > 1024) {
    len = 1024;
    bin[len] = '\0';
  }
  while (--len > 0) {
    if (!isprint(bin[len])) {
      bin[len] = '.';
    }
  }
}


x86 assembly (clang, -O0):
<repr_binary_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x400,-0xc(%rbp)
jle    113f <repr_binary_data+0x2f>
movl   $0x400,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1144 <repr_binary_data+0x34>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    1181 <repr_binary_data+0x71>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isprint@plt>
cmp    $0x0,%eax
jne    117c <repr_binary_data+0x6c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x2e,(%rax,%rcx,1)
jmp    1144 <repr_binary_data+0x34>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<repr_binary_data>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
cmp    $0x401,%esi
jl     112f <repr_binary_data+0x1f>
movb   $0x0,0x400(%r14)
mov    $0x400,%esi
jmp    1134 <repr_binary_data+0x24>
cmp    $0x2,%esi
jl     1163 <repr_binary_data+0x53>
mov    %esi,%ebx
add    $0x1,%rbx
jmp    114a <repr_binary_data+0x3a>
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rbx
cmp    $0x2,%rbx
jbe    1163 <repr_binary_data+0x53>
lea    -0x2(%rbx),%r15d
movsbl (%r14,%r15,1),%edi
call   1030 <isprint@plt>
test   %eax,%eax
jne    1140 <repr_binary_data+0x30>
movb   $0x2e,(%r14,%r15,1)
jmp    1140 <repr_binary_data+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @repr_binary_data(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1024
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1024
store i8 0, i8* %5
br label %8
6: ; preds = %2
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %22
8: ; preds = %4, %6
%9 = phi i32 [ 1024, %4 ], [ %1, %6 ]
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %20
%12 = phi i64 [ %10, %8 ], [ %13, %20 ]
%13 = add nsw i64 %12, -1
%14 = and i64 %13, 4294967295
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = tail call i32 @isprint(i8 signext %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %11
store i8 46, i8* %15
br label %20
20: ; preds = %19, %11
%21 = icmp ugt i64 %12, 2
br i1 %21, label %11, label %22
22: ; preds = %20, %6
ret void
}