#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 */
int /*<<< orphan*/ memcpy(char *, char *, unsigned int);
void _F90_FCD_COPY(char **ret_addr, int *ret_len, char *trg_addr,
                   char *src_addr, int trg_len, int src_len) {
  unsigned int len;
  len = (trg_len > src_len) ? src_len : trg_len;
  if (len > 0) {
    (void)memcpy(trg_addr, src_addr, len);
  }
  *ret_addr = trg_addr + len;
  *ret_len = trg_len - len;
  return;
}


x86 assembly (clang, -O0):
<_F90_FCD_COPY>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    1147 <_F90_FCD_COPY+0x37>
mov    -0x28(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    114d <_F90_FCD_COPY+0x3d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jbe    116d <_F90_FCD_COPY+0x5d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rcx
mov    -0x2c(%rbp),%eax
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_F90_FCD_COPY>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%ebx
mov    %r8d,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
cmp    %r9d,%r8d
cmovle %r8d,%ebx
test   %ebx,%ebx
je     113f <_F90_FCD_COPY+0x2f>
mov    %r15,%rdi
mov    %rcx,%rsi
mov    %ebx,%edx
call   1030 <memcpy@plt>
mov    %ebx,%eax
add    %rax,%r15
mov    %r15,(%r12)
sub    %ebx,%ebp
mov    %ebp,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_F90_FCD_COPY(i8** %0, i32* %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8** %0, i8*** %7
store i32* %1, i32** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%14 = load i32, i32* %11
%15 = load i32, i32* %12
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = load i32, i32* %12
br label %21
19: ; preds = %6
%20 = load i32, i32* %11
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
store i32 %22, i32* %13
%23 = load i32, i32* %13
%24 = icmp ugt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %9
%27 = load i8*, i8** %10
%28 = load i32, i32* %13
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
br label %30
30: ; preds = %25, %21
%31 = load i8*, i8** %9
%32 = load i32, i32* %13
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8**, i8*** %7
store i8* %34, i8** %35
%36 = load i32, i32* %11
%37 = load i32, i32* %13
%38 = sub i32 %36, %37
%39 = load i32*, i32** %8
store i32 %38, i32* %39
ret void
}

LLVM IR (-O2):
define void @_F90_FCD_COPY(i8** nocapture writeonly %0, i32* nocapture writeonly %1, i8* %2, i8* %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %4, %5
%8 = select i1 %7, i32 %5, i32 %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @memcpy(i8* %2, i8* %3, i32 %8)
br label %12
12: ; preds = %10, %6
%13 = zext i32 %8 to i64
%14 = getelementptr inbounds i8, i8* %2, i64 %13
store i8* %14, i8** %0
%15 = sub i32 %4, %8
store i32 %15, i32* %1
ret void
}