#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;
  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)
movq   $0x0,-0x18(%rbp)
cmpq   $0x29,-0x18(%rbp)
jae    1179 <string_copy_rev+0x59>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1163 <string_copy_rev+0x43>
jmp    1179 <string_copy_rev+0x59>
jmp    1168 <string_copy_rev+0x48>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <string_copy_rev+0x18>
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,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    114e <string_copy_rev+0x2e>
add    $0x1,%rbx
cmp    $0x29,%rbx
jne    1130 <string_copy_rev+0x10>
mov    $0x29,%ebx
mov    %r15,%rdi
mov    $0x29,%esi
mov    %r14,%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
store i64 0, i64* %5
br label %6
6: ; preds = %18, %2
%7 = load i64, i64* %5
%8 = icmp ult i64 %7, 41
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = load i64, i64* %5
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = load i8, i8* %12
%14 = call i64 @isspace(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %9
br label %21
17: ; preds = %9
br label %18
18: ; preds = %17
%19 = load i64, i64* %5
%20 = add i64 %19, 1
store i64 %20, i64* %5
br label %6
21: ; preds = %16, %6
%22 = load i8*, i8** %3
%23 = load i8*, i8** %4
%24 = load i64, i64* %5
%25 = call i32 @string_ncopy_do(i8* %22, i32 41, i8* %23, i64 %24)
ret void
}

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