#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__ isspace(char const);
int /*<<< orphan*/ string_ncopy_do(char *, int, char const *, size_t);
void string_copy_rev(char *dst, const char *src) {
  size_t srclen;
  if (!*src)
    return;
  for (srclen = 0; srclen < 41; srclen++)
    if (isspace(src[srclen]))
      break;
  string_ncopy_do(dst, 41, src, srclen);
}


x86 assembly (clang, -O0):
<string_copy_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1142 <string_copy_rev+0x22>
jmp    11a1 <string_copy_rev+0x81>
movq   $0x0,-0x18(%rbp)
cmpq   $0x29,-0x18(%rbp)
jae    118b <string_copy_rev+0x6b>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1175 <string_copy_rev+0x55>
jmp    118b <string_copy_rev+0x6b>
jmp    117a <string_copy_rev+0x5a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114a <string_copy_rev+0x2a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x29,%esi
call   1030 <string_ncopy_do@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_copy_rev>:
push   %r15
push   %r14
push   %rbx
mov    (%rsi),%al
test   %al,%al
je     115c <string_copy_rev+0x3c>
mov    %rsi,%r15
mov    %rdi,%r14
movsbl %al,%edi
call   1040 <isspace@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    1167 <string_copy_rev+0x47>
cmp    $0x28,%rbx
je     1162 <string_copy_rev+0x42>
movsbl 0x1(%r15,%rbx,1),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1140 <string_copy_rev+0x20>
jmp    1167 <string_copy_rev+0x47>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x29,%ebx
mov    %r14,%rdi
mov    $0x29,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <string_ncopy_do@plt>

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

LLVM IR (-O2):
define void @string_copy_rev(i8* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %2
%6 = tail call i64 @isspace(i8 signext %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5, %12
%9 = phi i64 [ %10, %12 ], [ 0, %5 ]
%10 = add nuw nsw i64 %9, 1
%11 = icmp eq i64 %10, 41
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %1, i64 %10
%14 = load i8, i8* %13
%15 = tail call i64 @isspace(i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %8, %12, %5
%18 = phi i64 [ 0, %5 ], [ 41, %8 ], [ %10, %12 ]
%19 = tail call i32 @string_ncopy_do(i8* %0, i32 41, i8* %1, i64 %18)
br label %20
20: ; preds = %2, %17
ret void
}