#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*/ memset(char *, char, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *right(char *string, char *substr, int width) {
  static char line[1024];
  int here;
  strcpy(line, string);
  here = width - strlen(substr);
  memset(line + strlen(string), ' ', here);
  strcpy(line + here, substr);
  return line;
}


x86 assembly (clang, -O0):
<right>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2f02(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cltq
lea    0x2ed2(%rip),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%edx
mov    $0x20,%esi
call   1050 <memset@plt>
movslq -0x18(%rbp),%rax
lea    0x2eb7(%rip),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0x2ea4(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<right>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x2f0a(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
movslq %ebp,%rdi
add    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@right.line = internal global [1024 x i8] zeroinitializer
define i8* @right(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @right.line, i64 0, i64 0), i8* %8)
%10 = load i32, i32* %6
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
%13 = sub nsw i32 %10, %12
store i32 %13, i32* %7
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @right.line, i64 0, i64 0), i64 %16
%18 = load i32, i32* %7
%19 = call i32 @memset(i8* %17, i8 signext 32, i32 %18)
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @right.line, i64 0, i64 0), i64 %21
%23 = load i8*, i8** %5
%24 = call i32 @strcpy(i8* %22, i8* %23)
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @right.line, i64 0, i64 0)
}

LLVM IR (-O2):
@right.line = internal global [1024 x i8] zeroinitializer
define i8* @right(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strcpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @right.line, i64 0, i64 0), i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = sub nsw i32 %2, %5
%7 = tail call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* @right.line, i64 0, i64 %8
%10 = tail call i32 @memset(i8* %9, i8 signext 32, i32 %6)
%11 = sext i32 %6 to i64
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* @right.line, i64 0, i64 %11
%13 = tail call i32 @strcpy(i8* %12, i8* %1)
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @right.line, i64 0, i64 0)
}