void adjust_print_opt_line(char *n_opt_line, char *opt_line, int hdr_len) {
  char pad[128] = {0};
  int pad_len;
  if (hdr_len > strlen(opt_line)) {
    pad_len = (hdr_len - strlen(opt_line)) / 2;
    memset(pad, '-', pad_len);
    strcat(n_opt_line, pad);
    strcat(n_opt_line, opt_line);
    memset(&pad, '-', hdr_len - pad_len - strlen(opt_line));
    strcat(n_opt_line, pad);
  } else
    strncat(n_opt_line, opt_line, hdr_len);
}


x86 assembly (clang, -O0):
<adjust_print_opt_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
movslq -0x14(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
cmp    %rcx,%rax
jbe    1249 <adjust_print_opt_line+0x109>
movslq -0x14(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0xc8(%rbp),%rax
sub    %rcx,%rax
shr    $0x1,%rax
mov    %eax,-0xa4(%rbp)
lea    -0xa0(%rbp),%rdi
movslq -0xa4(%rbp),%rdx
mov    $0x2d,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x14(%rbp),%eax
sub    -0xa4(%rbp),%eax
cltq
mov    %rax,-0xc0(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xc0(%rbp),%rdx
mov    -0xb8(%rbp),%rdi
sub    %rax,%rdx
mov    $0x2d,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1060 <strcat@plt>
jmp    125a <adjust_print_opt_line+0x11a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rdx
call   1050 <strncat@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_print_opt_line>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movslq %edx,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
cmp    %rbx,%rax
jae    1202 <adjust_print_opt_line+0xc2>
mov    %rbx,%rcx
sub    %rax,%rcx
shr    %rcx
movslq %ecx,%r13
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x2d,%esi
mov    %r13,%rdx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
sub    %r13d,%ebx
movslq %ebx,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
sub    %rax,%rbx
mov    %r12,%rdi
mov    $0x2d,%esi
mov    %rbx,%rdx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <strncat@plt>

LLVM IR (-O0):
define void @adjust_print_opt_line(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = bitcast [128 x i8]* %7 to i8*
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = load i8*, i8** %5
%13 = call i64 @strlen(i8* %12)
%14 = icmp ugt i64 %11, %13
br i1 %14, label %15, label %43
15: ; preds = %3
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = load i8*, i8** %5
%19 = call i64 @strlen(i8* %18)
%20 = sub i64 %17, %19
%21 = udiv i64 %20, 2
%22 = trunc i64 %21 to i32
store i32 %22, i32* %8
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = load i8*, i8** %4
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%28 = call i8* @strcat(i8* %26, i8* %27)
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = call i8* @strcat(i8* %29, i8* %30)
%32 = bitcast [128 x i8]* %7 to i8*
%33 = load i32, i32* %6
%34 = load i32, i32* %8
%35 = sub nsw i32 %33, %34
%36 = sext i32 %35 to i64
%37 = load i8*, i8** %5
%38 = call i64 @strlen(i8* %37)
%39 = sub i64 %36, %38
%40 = load i8*, i8** %4
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%42 = call i8* @strcat(i8* %40, i8* %41)
br label %49
43: ; preds = %3
%44 = load i8*, i8** %4
%45 = load i8*, i8** %5
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = call i8* @strncat(i8* %44, i8* %45, i64 %47)
br label %49
49: ; preds = %43, %15
ret void
}

LLVM IR (-O2):
define void @adjust_print_opt_line(i8* %0, i8* nocapture %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = sext i32 %2 to i64
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = icmp ult i64 %7, %6
br i1 %8, label %9, label %22
9: ; preds = %3
%10 = sub i64 %6, %7
%11 = lshr i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = shl i64 %11, 32
%14 = ashr exact i64 %13, 32
%15 = call i8* @strcat(i8* dereferenceable(1) %0, i8* %5)
%16 = tail call i8* @strcat(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%17 = sub nsw i32 %2, %12
%18 = sext i32 %17 to i64
%19 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%20 = sub i64 %18, %19
%21 = call i8* @strcat(i8* dereferenceable(1) %0, i8* %5)
br label %24
22: ; preds = %3
%23 = tail call i8* @strncat(i8* dereferenceable(1) %0, i8* %1, i64 %6)
br label %24
24: ; preds = %22, %9
ret void
}