#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__ isalnum(char);
void strcpy_VBsafe(char *sout, char *sin) {
  char *sp, *sp2;
  int iw = 0;
  sp = sin;
  sp2 = sout;
  while ((isalnum(*sp) || *sp == ' ' || *sp == '-' || *sp == ',') && iw < 30) {
    *sp2 = *sp;
    sp++;
    sp2++;
    iw++;
  }
  *sp2 = '\0';
}


x86 assembly (clang, -O0):
<strcpy_VBsafe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    1182 <strcpy_VBsafe+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1182 <strcpy_VBsafe+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     1182 <strcpy_VBsafe+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2c,%ecx
mov    %al,-0x25(%rbp)
jne    118c <strcpy_VBsafe+0x7c>
cmpl   $0x1e,-0x24(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    119c <strcpy_VBsafe+0x8c>
jmp    11ce <strcpy_VBsafe+0xbe>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1137 <strcpy_VBsafe+0x27>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcpy_VBsafe>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
jmp    1128 <strcpy_VBsafe+0x18>
nop
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
movsbl (%r15,%rbx,1),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1150 <strcpy_VBsafe+0x40>
cmp    $0x1d,%ebx
ja     1168 <strcpy_VBsafe+0x58>
movzbl (%r15,%rbx,1),%eax
jmp    1120 <strcpy_VBsafe+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r15,%rbx,1),%eax
cmp    $0x20,%al
je     1137 <strcpy_VBsafe+0x27>
cmp    $0x2d,%al
je     1137 <strcpy_VBsafe+0x27>
cmp    $0x2c,%al
jne    1168 <strcpy_VBsafe+0x58>
mov    $0x2c,%al
cmp    $0x1e,%ebx
jb     1120 <strcpy_VBsafe+0x10>
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @strcpy_VBsafe(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
%8 = load i8*, i8** %4
store i8* %8, i8** %5
%9 = load i8*, i8** %3
store i8* %9, i8** %6
br label %10
10: ; preds = %35, %2
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = call i64 @isalnum(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %30, label %15
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 32
br i1 %19, label %30, 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, 45
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 44
br i1 %29, label %30, label %33
30: ; preds = %25, %20, %15, %10
%31 = load i32, i32* %7
%32 = icmp slt i32 %31, 30
br label %33
33: ; preds = %30, %25
%34 = phi i1 [ false, %25 ], [ %32, %30 ]
br i1 %34, label %35, label %45
35: ; preds = %33
%36 = load i8*, i8** %5
%37 = load i8, i8* %36
%38 = load i8*, i8** %6
store i8 %37, i8* %38
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %6
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %10
45: ; preds = %33
%46 = load i8*, i8** %6
store i8 0, i8* %46
ret void
}

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