#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__ count_white_spaces(char const *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
scalar_t__ strcmp(char *, char *);
size_t copy_return_type_name(char *dst, const char *src, size_t namepos) {
  size_t dst_pos = 0;
  size_t pos = 0;
  memcpy(dst, src, namepos);
  dst_pos = pos = namepos;
  dst[dst_pos] = 0;
  pos += count_white_spaces(&src[pos]);
  while ('*' == src[pos]) {
    dst[dst_pos++] = src[pos++];
  }
  pos += count_white_spaces(&src[pos]);
  dst[dst_pos] = 0;
  if (0 == strcmp("", dst)) {
    return 0;
  }
  return pos;
}


x86 assembly (clang, -O0):
<copy_return_type_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
add    -0x30(%rbp),%rdi
call   1030 <count_white_spaces@plt>
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x2a,%eax
cmp    %ecx,%eax
jne    11dc <copy_return_type_name+0xac>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x28(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    1192 <copy_return_type_name+0x62>
mov    -0x18(%rbp),%rdi
add    -0x30(%rbp),%rdi
call   1030 <count_white_spaces@plt>
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1228 <copy_return_type_name+0xf8>
movq   $0x0,-0x8(%rbp)
jmp    1230 <copy_return_type_name+0x100>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_return_type_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1050 <memcpy@plt>
movb   $0x0,(%r14,%rbx,1)
lea    (%r15,%rbx,1),%rdi
call   1030 <count_white_spaces@plt>
add    %rbx,%rax
cmpb   $0x2a,(%r15,%rax,1)
jne    117a <copy_return_type_name+0x4a>
xchg   %ax,%ax
lea    0x1(%rax),%r12
movb   $0x2a,(%r14,%rbx,1)
add    $0x1,%rbx
cmpb   $0x2a,0x1(%r15,%rax,1)
mov    %r12,%rax
je     1160 <copy_return_type_name+0x30>
jmp    117d <copy_return_type_name+0x4d>
mov    %rax,%r12
add    %r12,%r15
mov    %r15,%rdi
call   1030 <count_white_spaces@plt>
mov    %rax,%r15
movb   $0x0,(%r14,%rbx,1)
lea    0xe69(%rip),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
add    %r12,%r15
test   %rax,%rax
cmovne %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i64 @copy_return_type_name(i8* %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 0, i64* %8
store i64 0, i64* %9
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = load i64, i64* %7
%13 = call i32 @memcpy(i8* %10, i8* %11, i64 %12)
%14 = load i64, i64* %7
store i64 %14, i64* %9
store i64 %14, i64* %8
%15 = load i8*, i8** %5
%16 = load i64, i64* %8
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8 0, i8* %17
%18 = load i8*, i8** %6
%19 = load i64, i64* %9
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = call i64 @count_white_spaces(i8* %20)
%22 = load i64, i64* %9
%23 = add i64 %22, %21
store i64 %23, i64* %9
br label %24
24: ; preds = %31, %3
%25 = load i8*, i8** %6
%26 = load i64, i64* %9
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 42, %29
br i1 %30, label %31, label %41
31: ; preds = %24
%32 = load i8*, i8** %6
%33 = load i64, i64* %9
%34 = add i64 %33, 1
store i64 %34, i64* %9
%35 = getelementptr inbounds i8, i8* %32, i64 %33
%36 = load i8, i8* %35
%37 = load i8*, i8** %5
%38 = load i64, i64* %8
%39 = add i64 %38, 1
store i64 %39, i64* %8
%40 = getelementptr inbounds i8, i8* %37, i64 %38
store i8 %36, i8* %40
br label %24
41: ; preds = %24
%42 = load i8*, i8** %6
%43 = load i64, i64* %9
%44 = getelementptr inbounds i8, i8* %42, i64 %43
%45 = call i64 @count_white_spaces(i8* %44)
%46 = load i64, i64* %9
%47 = add i64 %46, %45
store i64 %47, i64* %9
%48 = load i8*, i8** %5
%49 = load i64, i64* %8
%50 = getelementptr inbounds i8, i8* %48, i64 %49
store i8 0, i8* %50
%51 = load i8*, i8** %5
%52 = call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %51)
%53 = icmp eq i64 0, %52
br i1 %53, label %54, label %55
54: ; preds = %41
store i64 0, i64* %4
br label %57
55: ; preds = %41
%56 = load i64, i64* %9
store i64 %56, i64* %4
br label %57
57: ; preds = %55, %54
%58 = load i64, i64* %4
ret i64 %58
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i64 @copy_return_type_name(i8* %0, i8* %1, i64 %2) {
%4 = tail call i32 @memcpy(i8* %0, i8* %1, i64 %2)
%5 = getelementptr inbounds i8, i8* %0, i64 %2
store i8 0, i8* %5
%6 = getelementptr inbounds i8, i8* %1, i64 %2
%7 = tail call i64 @count_white_spaces(i8* %6)
%8 = add i64 %7, %2
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 42
br i1 %11, label %12, label %21
12: ; preds = %3, %12
%13 = phi i64 [ %15, %12 ], [ %8, %3 ]
%14 = phi i64 [ %16, %12 ], [ %2, %3 ]
%15 = add i64 %13, 1
%16 = add i64 %14, 1
%17 = getelementptr inbounds i8, i8* %0, i64 %14
store i8 42, i8* %17
%18 = getelementptr inbounds i8, i8* %1, i64 %15
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 42
br i1 %20, label %12, label %21
21: ; preds = %12, %3
%22 = phi i64 [ %8, %3 ], [ %15, %12 ]
%23 = phi i64 [ %2, %3 ], [ %16, %12 ]
%24 = getelementptr inbounds i8, i8* %1, i64 %22
%25 = tail call i64 @count_white_spaces(i8* %24)
%26 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* %26
%27 = tail call i64 @strcmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %0)
%28 = icmp eq i64 %27, 0
%29 = add i64 %25, %22
%30 = select i1 %28, i64 0, i64 %29
ret i64 %30
}