#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(char);
void strucpy(char *s1, char *s2, int len) {
  if (len > 50)
    len = 50;
  while (len--) {
    if (isprint(*s2) || *s2 == ' ')
      *s1++ = *s2;
    s2++;
  }
  *s1 = '\0';
}


x86 assembly (clang, -O0):
<strucpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x32,-0x14(%rbp)
jle    1134 <strucpy+0x24>
movl   $0x32,-0x14(%rbp)
jmp    1139 <strucpy+0x29>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     119b <strucpy+0x8b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
jne    1173 <strucpy+0x63>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    118a <strucpy+0x7a>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1139 <strucpy+0x29>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strucpy>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
cmp    $0x32,%edx
mov    $0x32,%eax
cmovl  %edx,%eax
test   %eax,%eax
je     116e <strucpy+0x5e>
mov    %rsi,%r14
mov    %eax,%r15d
xor    %ebx,%ebx
jmp    1151 <strucpy+0x41>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %cl,(%r12)
add    $0x1,%r12
add    $0x1,%rbx
cmp    %ebx,%r15d
je     116e <strucpy+0x5e>
movsbl (%r14,%rbx,1),%edi
call   1030 <isprint@plt>
movzbl (%r14,%rbx,1),%ecx
test   %rax,%rax
jne    1140 <strucpy+0x30>
cmp    $0x20,%cl
mov    $0x20,%cl
je     1140 <strucpy+0x30>
jmp    1148 <strucpy+0x38>
movb   $0x0,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @strucpy(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = icmp slt i32 %2, 50
%5 = select i1 %4, i32 %2, i32 50
%6 = icmp eq i32 %5, 0
br i1 %6, label %25, label %7
7: ; preds = %3, %21
%8 = phi i32 [ %11, %21 ], [ %5, %3 ]
%9 = phi i8* [ %23, %21 ], [ %1, %3 ]
%10 = phi i8* [ %22, %21 ], [ %0, %3 ]
%11 = add nsw i32 %8, -1
%12 = load i8, i8* %9
%13 = tail call i64 @isprint(i8 signext %12)
%14 = icmp eq i64 %13, 0
%15 = load i8, i8* %9
br i1 %14, label %16, label %18
16: ; preds = %7
%17 = icmp eq i8 %15, 32
br i1 %17, label %18, label %21
18: ; preds = %7, %16
%19 = phi i8 [ 32, %16 ], [ %15, %7 ]
%20 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %19, i8* %10
br label %21
21: ; preds = %18, %16
%22 = phi i8* [ %20, %18 ], [ %10, %16 ]
%23 = getelementptr inbounds i8, i8* %9, i64 1
%24 = icmp eq i32 %11, 0
br i1 %24, label %25, label %7
25: ; preds = %21, %3
%26 = phi i8* [ %0, %3 ], [ %22, %21 ]
store i8 0, i8* %26
ret void
}