char *mklong(str, ch)
register char *str;
int ch;
{
  static char copy[64];
  register int len;
  if (ch == 'X')
    ch = 'x';
  len = strlen(str) + 2;
  bcopy(str, copy, len - 3);
  copy[len - 3] = 'l';
  copy[len - 2] = ch;
  copy[len - 1] = '\0';
  return (copy);
}


x86 assembly (clang, -O0):
<mklong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x58,-0xc(%rbp)
jne    1140 <mklong+0x20>
movl   $0x78,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x2,%rax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
sub    $0x3,%edx
lea    0x2edf(%rip),%rsi
mov    $0x0,%al
call   1040 <bcopy@plt>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
movslq %eax,%rcx
lea    0x2ec8(%rip),%rax
movb   $0x6c,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
movslq %eax,%rcx
lea    0x2eaf(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2e9c(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e91(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mklong>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r15
lea    -0x1(%rax),%ebp
lea    0x2f00(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <bcopy@plt>
cmp    $0x58,%r14d
movslq %ebp,%rax
movb   $0x6c,(%rax,%r12,1)
mov    $0x78,%eax
cmovne %r14d,%eax
movslq %r15d,%rcx
mov    %al,(%rcx,%r12,1)
add    $0x1,%ecx
movslq %ecx,%rax
movb   $0x0,(%rax,%r12,1)
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@mklong.copy = internal global [64 x i8] zeroinitializer
define i8* @mklong(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 88
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = trunc i64 %4 to i32
%6 = add i32 %5, -1
%7 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @bcopy to i32 (i8*, i8*, i32, ...)*)(i8* %0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @mklong.copy, i64 0, i64 0), i32 %6)
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds [64 x i8], [64 x i8]* @mklong.copy, i64 0, i64 %8
store i8 108, i8* %9
%10 = trunc i32 %1 to i8
%11 = select i1 %3, i8 120, i8 %10
%12 = shl i64 %4, 32
%13 = ashr exact i64 %12, 32
%14 = getelementptr inbounds [64 x i8], [64 x i8]* @mklong.copy, i64 0, i64 %13
store i8 %11, i8* %14
%15 = add i64 %12, 4294967296
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds [64 x i8], [64 x i8]* @mklong.copy, i64 0, i64 %16
store i8 0, i8* %17
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @mklong.copy, i64 0, i64 0)
}