#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*/ memmove(char *, char *, int);
int /*<<< orphan*/ memset(char *, int, int);
void s_copy(char *s1, char *s2, int l1, int l2) {
  register int len;
  len = l1 - l2;
  if (len <= 0)
    (void)memmove(s1, s2, l1);
  else {
    (void)memmove(s1, s2, l2);
    memset(s1 + l2, ((int)' '), len);
  }
  return;
}


x86 assembly (clang, -O0):
<s_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     115e <s_copy+0x3e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <memmove@plt>
jmp    1186 <s_copy+0x66>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <memmove@plt>
mov    -0x8(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
mov    -0x1c(%rbp),%edx
mov    $0x20,%esi
call   1030 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_copy>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %edx,%ebx
sub    %ecx,%ebx
jle    114f <s_copy+0x2f>
mov    %ecx,%ebp
mov    %r14,%rdi
mov    %ecx,%edx
call   1040 <memmove@plt>
movslq %ebp,%rdi
add    %r14,%rdi
mov    $0x20,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <memset@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <memmove@plt>

LLVM IR (-O0):
define void @s_copy(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = sub nsw i32 %10, %11
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @memmove(i8* %16, i8* %17, i32 %18)
br label %31
20: ; preds = %4
%21 = load i8*, i8** %5
%22 = load i8*, i8** %6
%23 = load i32, i32* %8
%24 = call i32 @memmove(i8* %21, i8* %22, i32 %23)
%25 = load i8*, i8** %5
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i32, i32* %9
%30 = call i32 @memset(i8* %28, i32 32, i32 %29)
br label %31
31: ; preds = %20, %15
ret void
}

LLVM IR (-O2):
define void @s_copy(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %2, %3
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @memmove(i8* %0, i8* %1, i32 %2)
br label %14
9: ; preds = %4
%10 = tail call i32 @memmove(i8* %0, i8* %1, i32 %3)
%11 = sext i32 %3 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @memset(i8* %12, i32 32, i32 %5)
br label %14
14: ; preds = %9, %7
ret void
}