char *right(string, substr, scr_len)
char *string, *substr;
int scr_len;
{
  static char line[200];
  int str_len = strlen(substr);
  int x;
  strcpy(line, string);
  for (x = strlen(string); x < scr_len - str_len; x++)
    line[x] = ' ';
  line[x] = '\0';
  strcat(line, 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    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0x2ef6(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    1199 <right+0x69>
movslq -0x1c(%rbp),%rcx
lea    0x2ec9(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116b <right+0x3b>
movslq -0x1c(%rbp),%rcx
lea    0x2eac(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0x2e9d(%rip),%rdi
call   1050 <strcat@plt>
lea    0x2e91(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<right>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
lea    0x2eea(%rip),%r14
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r12d,%ebp
sub    %ebx,%ebp
cmp    %eax,%ebp
jle    11b9 <right+0x79>
movslq %eax,%r13
lea    (%r14,%r13,1),%rdi
not    %ebx
add    %r12d,%ebx
sub    %eax,%ebx
add    $0x1,%rbx
mov    $0x20,%esi
mov    %rbx,%rdx
call   1050 <memset@plt>
movslq %ebp,%rcx
mov    %r13,%rax
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    %rcx,%rax
jl     11b0 <right+0x70>
cltq
movb   $0x0,(%rax,%r14,1)
mov    %r14,%rdi
mov    %r15,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <strcat@plt>

LLVM IR (-O0):
@right.line = internal global [200 x i8] zeroinitializer
define i8* @right(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %7
%12 = load i8*, i8** %4
%13 = call i8* @strcpy(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @right.line, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %4
%15 = call i64 @strlen(i8* %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %8
br label %17
17: ; preds = %27, %3
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = sub nsw i32 %19, %20
%22 = icmp slt i32 %18, %21
br i1 %22, label %23, label %30
23: ; preds = %17
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [200 x i8], [200 x i8]* @right.line, i64 0, i64 %25
store i8 32, i8* %26
br label %27
27: ; preds = %23
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %17
30: ; preds = %17
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [200 x i8], [200 x i8]* @right.line, i64 0, i64 %32
store i8 0, i8* %33
%34 = load i8*, i8** %5
%35 = call i8* @strcat(i8* getelementptr inbounds ([200 x i8], [200 x i8]* @right.line, i64 0, i64 0), i8* %34)
ret i8* getelementptr inbounds ([200 x i8], [200 x i8]* @right.line, i64 0, i64 0)
}

LLVM IR (-O2):
@right.line = internal global [200 x i8] zeroinitializer
define i8* @right(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = trunc i64 %4 to i32
%6 = tail call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([200 x i8], [200 x i8]* @right.line, i64 0, i64 0), i8* dereferenceable(1) %0)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = trunc i64 %7 to i32
%9 = sub nsw i32 %2, %5
%10 = icmp sgt i32 %9, %8
br i1 %10, label %11, label %25
11: ; preds = %3
%12 = shl i64 %7, 32
%13 = ashr exact i64 %12, 32
%14 = getelementptr [200 x i8], [200 x i8]* @right.line, i64 0, i64 %13
%15 = xor i32 %5, -1
%16 = add i32 %15, %2
%17 = sub i32 %16, %8
%18 = zext i32 %17 to i64
%19 = add nuw nsw i64 %18, 1
%20 = sext i32 %9 to i64
br label %21
21: ; preds = %11, %21
%22 = phi i64 [ %13, %11 ], [ %23, %21 ]
%23 = add nsw i64 %22, 1
%24 = icmp slt i64 %23, %20
br i1 %24, label %21, label %25
25: ; preds = %21, %3
%26 = phi i64 [ %7, %3 ], [ %23, %21 ]
%27 = shl i64 %26, 32
%28 = ashr exact i64 %27, 32
%29 = getelementptr inbounds [200 x i8], [200 x i8]* @right.line, i64 0, i64 %28
store i8 0, i8* %29
%30 = tail call i8* @strcat(i8* dereferenceable(1) getelementptr inbounds ([200 x i8], [200 x i8]* @right.line, i64 0, i64 0), i8* dereferenceable(1) %1)
ret i8* getelementptr inbounds ([200 x i8], [200 x i8]* @right.line, i64 0, i64 0)
}