#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 */
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ putchar(char const);
void printstr(const char *str, int len) {
  for (; len-- > 0; str++)
    putchar(isprint((unsigned char)*str) ? *str : '.');
}


x86 assembly (clang, -O0):
<printstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    1191 <printstr+0x71>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     1168 <printstr+0x48>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
jmp    1175 <printstr+0x55>
mov    $0x2e,%eax
mov    %eax,-0x10(%rbp)
jmp    1175 <printstr+0x55>
mov    -0x10(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112f <printstr+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printstr>:
push   %rbp
push   %rbx
push   %rax
test   %esi,%esi
jle    1168 <printstr+0x48>
mov    %esi,%ebp
mov    %rdi,%rbx
add    $0x1,%ebp
jmp    1157 <printstr+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jbe    1168 <printstr+0x48>
movzbl (%rbx),%edi
call   1040 <isprint@plt>
test   %rax,%rax
jne    1140 <printstr+0x20>
mov    $0x2e,%al
jmp    1143 <printstr+0x23>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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