#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 *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
char *PadRight(char *strvalue, int n, char c, char *___PadRight) {
  char ___PadRight1[1024];
  char _______prtmp[255];
  memset(___PadRight1, 0x00, 1024);
  memset(_______prtmp, c, 255);
  sprintf(___PadRight1, "%s%s", strvalue, _______prtmp);
  memcpy(___PadRight, ___PadRight1, n);
  return ___PadRight;
}


x86 assembly (clang, -O0):
<PadRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
lea    -0x520(%rbp),%rdi
mov    -0xd(%rbp),%al
movsbl %al,%esi
mov    $0xff,%edx
call   1030 <memset@plt>
lea    -0x420(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    -0x520(%rbp),%rcx
lea    0xe72(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PadRight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x508,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r15
lea    0x100(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
mov    %rsp,%r13
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0xff,%edx
call   1030 <memset@plt>
lea    0xe84(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1040 <memcpy@plt>
mov    %rbx,%rax
add    $0x508,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%s\00"
define i8* @PadRight(i8* %0, i32 %1, i8 signext %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca [255 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i8 signext 0, i32 1024)
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%14 = load i8, i8* %7
%15 = call i32 @memset(i8* %13, i8 signext %14, i32 255)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%19 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i8*, i8** %8
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%22 = load i32, i32* %6
%23 = call i32 @memcpy(i8* %20, i8* %21, i32 %22)
%24 = load i8*, i8** %8
ret i8* %24
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%s\00"
define i8* @PadRight(i8* %0, i32 %1, i8 signext %2, i8* returned %3) {
%5 = alloca [1024 x i8]
%6 = alloca [255 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %6, i64 0, i64 0
%9 = call i32 @memset(i8* %7, i8 signext 0, i32 1024)
%10 = call i32 @memset(i8* %8, i8 signext %2, i32 255)
%11 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %8)
%12 = call i32 @memcpy(i8* %3, i8* %7, i32 %1)
ret i8* %3
}