void imc_fits_mkstrg_val(char *line, char *strg) {
  char tmp[160];
  int i, j;
  j = 0;
  for (i = 0; i < 80; i++) {
    if (strg[i] == '\0') {
      tmp[j] = '\0';
      break;
    }
    if (strg[i] < 0x20)
      tmp[j++] = ' ';
    else if (strg[i] != '\'')
      tmp[j++] = strg[i];
    else {
      tmp[j++] = '\'';
      tmp[j++] = '\'';
    }
  }
  sprintf(line, "%c%-8s%c ", '\'', tmp, '\'');
  return;
}


x86 assembly (clang, -O0):
<imc_fits_mkstrg_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xb8(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x50,-0xb4(%rbp)
jge    1241 <imc_fits_mkstrg_val+0x131>
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1170 <imc_fits_mkstrg_val+0x60>
movslq -0xb8(%rbp),%rax
movb   $0x0,-0xb0(%rbp,%rax,1)
jmp    1241 <imc_fits_mkstrg_val+0x131>
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    11a8 <imc_fits_mkstrg_val+0x98>
mov    -0xb8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xb8(%rbp)
cltq
movb   $0x20,-0xb0(%rbp,%rax,1)
20
jmp    1228 <imc_fits_mkstrg_val+0x118>
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
je     11ed <imc_fits_mkstrg_val+0xdd>
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0xb8(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xb8(%rbp)
cltq
mov    %cl,-0xb0(%rbp,%rax,1)
jmp    1223 <imc_fits_mkstrg_val+0x113>
mov    -0xb8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xb8(%rbp)
cltq
movb   $0x27,-0xb0(%rbp,%rax,1)
27
mov    -0xb8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xb8(%rbp)
cltq
movb   $0x27,-0xb0(%rbp,%rax,1)
27
jmp    1228 <imc_fits_mkstrg_val+0x118>
jmp    122d <imc_fits_mkstrg_val+0x11d>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1137 <imc_fits_mkstrg_val+0x27>
mov    -0x8(%rbp),%rdi
lea    -0xb0(%rbp),%rcx
lea    0xdad(%rip),%rsi
mov    $0x27,%r8d
mov    %r8d,%edx
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imc_fits_mkstrg_val>:
sub    $0xa8,%rsp
xor    %eax,%eax
xor    %r8d,%r8d
jmp    1132 <imc_fits_mkstrg_val+0x22>
xchg   %ax,%ax
lea    0x1(%rdx),%r8d
movb   $0x20,(%rsp,%rdx,1)
add    $0x1,%rax
cmp    $0x50,%rax
je     1169 <imc_fits_mkstrg_val+0x59>
movzbl (%rsi,%rax,1),%ecx
movslq %r8d,%rdx
test   %cl,%cl
je     1165 <imc_fits_mkstrg_val+0x55>
cmp    $0x1f,%cl
jle    1120 <imc_fits_mkstrg_val+0x10>
lea    0x1(%rdx),%r8
cmp    $0x27,%cl
jne    1160 <imc_fits_mkstrg_val+0x50>
movb   $0x27,(%rsp,%rdx,1)
add    $0x2,%edx
movb   $0x27,(%rsp,%r8,1)
mov    %edx,%r8d
jmp    1128 <imc_fits_mkstrg_val+0x18>
nopl   0x0(%rax)
mov    %cl,(%rsp,%rdx,1)
jmp    1128 <imc_fits_mkstrg_val+0x18>
movb   $0x0,(%rsp,%rdx,1)
lea    0xe90(%rip),%rsi
mov    %rsp,%rcx
mov    $0x27,%edx
mov    $0x27,%r8d
xor    %eax,%eax
call   1030 <sprintf@plt>
add    $0xa8,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%c%-8s%c \00"
define void @imc_fits_mkstrg_val(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [160 x i8]
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
store i32 0, i32* %6
br label %8
8: ; preds = %65, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 80
br i1 %10, label %11, label %68
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %11
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 %21
store i8 0, i8* %22
br label %68
23: ; preds = %11
%24 = load i8*, i8** %4
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp slt i32 %29, 32
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 %34
store i8 32, i8* %35
br label %64
36: ; preds = %23
%37 = load i8*, i8** %4
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 39
br i1 %43, label %44, label %54
44: ; preds = %36
%45 = load i8*, i8** %4
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 %52
store i8 %49, i8* %53
br label %63
54: ; preds = %36
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 %57
store i8 39, i8* %58
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
%61 = sext i32 %59 to i64
%62 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 %61
store i8 39, i8* %62
br label %63
63: ; preds = %54, %44
br label %64
64: ; preds = %63, %31
br label %65
65: ; preds = %64
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %8
68: ; preds = %19, %8
%69 = load i8*, i8** %3
%70 = getelementptr inbounds [160 x i8], [160 x i8]* %5, i64 0, i64 0
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* %69, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 39, i8* %70, i32 39)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%c%-8s%c \00"
define void @imc_fits_mkstrg_val(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = alloca [160 x i8]
%4 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %2, %30
%6 = phi i64 [ 0, %2 ], [ %32, %30 ]
%7 = phi i32 [ 0, %2 ], [ %31, %30 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %6
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = sext i32 %7 to i64
%13 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 %12
store i8 0, i8* %13
br label %34
14: ; preds = %5
%15 = icmp slt i8 %9, 32
br i1 %15, label %16, label %20
16: ; preds = %14
%17 = add nsw i32 %7, 1
%18 = sext i32 %7 to i64
%19 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 %18
store i8 32, i8* %19
br label %30
20: ; preds = %14
%21 = icmp eq i8 %9, 39
%22 = add nsw i32 %7, 1
%23 = sext i32 %7 to i64
%24 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 %23
br i1 %21, label %26, label %25
25: ; preds = %20
store i8 %9, i8* %24
br label %30
26: ; preds = %20
store i8 39, i8* %24
%27 = add nsw i32 %7, 2
%28 = sext i32 %22 to i64
%29 = getelementptr inbounds [160 x i8], [160 x i8]* %3, i64 0, i64 %28
store i8 39, i8* %29
br label %30
30: ; preds = %16, %26, %25
%31 = phi i32 [ %17, %16 ], [ %22, %25 ], [ %27, %26 ]
%32 = add nuw nsw i64 %6, 1
%33 = icmp eq i64 %32, 80
br i1 %33, label %34, label %5
34: ; preds = %30, %11
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 39, i8* %4, i32 39)
ret void
}