#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 pattern(char *cp, int cnt) {
  register char c;
  register int cnt1;
  cnt1 = cnt;
  c = 0;
  while (cnt1-- > 0) {
    while (!isprint((c & 0x7F)))
      c++;
    *cp++ = (c++ & 0x7F);
  }
}


x86 assembly (clang, -O0):
<pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
movb   $0x0,-0xd(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    119c <pattern+0x8c>
jmp    1142 <pattern+0x32>
movsbl -0xd(%rbp),%eax
and    $0x7f,%eax
movsbl %al,%edi
call   1030 <isprint@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1166 <pattern+0x56>
jmp    1173 <pattern+0x63>
mov    -0xd(%rbp),%al
add    $0x1,%al
mov    %al,-0xd(%rbp)
jmp    1142 <pattern+0x32>
mov    -0xd(%rbp),%al
mov    %al,%cl
add    $0x1,%cl
mov    %cl,-0xd(%rbp)
movsbl %al,%eax
and    $0x7f,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1129 <pattern+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1159 <pattern+0x49>
mov    %esi,%r14d
mov    %rdi,%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%ebx
and    $0x7f,%bl
movzbl %bl,%edi
call   1030 <isprint@plt>
add    $0x1,%bpl
test   %eax,%eax
je     1130 <pattern+0x20>
lea    -0x1(%r14),%eax
mov    %bl,(%r15)
add    $0x1,%r15
cmp    $0x1,%r14d
mov    %eax,%r14d
jg     1130 <pattern+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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