char *cfgxstr(instr)
char *instr;
{
  static char s[400], ds[80];
  char *x;
  memset(s, 0, 400);
  for (x = instr; *x != 0; x++) {
    if (*x != '%')
      s[strlen(s)] = *x;
    else
      switch (*(++x)) {
      case 'n':
        strcat(s, "\n");
        break;
      case 'v':
        strcat(s, "1.0");
        break;
      }
  }
  return (s);
}


x86 assembly (clang, -O0):
<cfgxstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     121c <cfgxstr+0xec>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     11a1 <cfgxstr+0x71>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
lea    0x2ec9(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x11(%rbp),%dl
mov    %rax,%rcx
lea    0x2eb7(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    1206 <cfgxstr+0xd6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x6e,%eax
je     11d6 <cfgxstr+0xa6>
jmp    11c5 <cfgxstr+0x95>
mov    -0x18(%rbp),%eax
sub    $0x76,%eax
je     11ee <cfgxstr+0xbe>
jmp    1201 <cfgxstr+0xd1>
lea    0x2e73(%rip),%rdi
lea    0xe1c(%rip),%rsi
call   1050 <strcat@plt>
jmp    1201 <cfgxstr+0xd1>
lea    0x2e5b(%rip),%rdi
lea    0xe06(%rip),%rsi
call   1050 <strcat@plt>
jmp    1206 <cfgxstr+0xd6>
jmp    120b <cfgxstr+0xdb>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <cfgxstr+0x27>
lea    0x2e2d(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfgxstr>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0x2f11(%rip),%r14
mov    $0x190,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
jmp    1154 <cfgxstr+0x34>
mov    %r14,%rdi
call   1030 <strlen@plt>
movl   $0x302e31,(%rax,%r14,1)
add    $0x1,%r15
movzbl (%r15),%ebx
cmp    $0x25,%bl
je     1180 <cfgxstr+0x60>
test   %bl,%bl
je     11a8 <cfgxstr+0x88>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %bl,(%rax,%r14,1)
add    $0x1,%r15
jmp    1154 <cfgxstr+0x34>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x1(%r15),%eax
add    $0x1,%r15
cmp    $0x76,%eax
je     1140 <cfgxstr+0x20>
cmp    $0x6e,%eax
jne    1150 <cfgxstr+0x30>
mov    %r14,%rdi
call   1030 <strlen@plt>
movw   $0xa,(%rax,%r14,1)
add    $0x1,%r15
jmp    1154 <cfgxstr+0x34>
lea    0x2e91(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@cfgxstr.s = internal global [400 x i8] zeroinitializer
@cfgxstr.ds = internal global [80 x i8] zeroinitializer
@.str = [2 x i8] c"\0A\00"
@.str.1 = [4 x i8] c"1.0\00"
define i8* @cfgxstr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %31, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %34
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 37
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = call i64 @strlen(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0))
%19 = getelementptr inbounds [400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 %18
store i8 %17, i8* %19
br label %30
20: ; preds = %10
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
switch i32 %24, label %29 [
i32 110, label %25
i32 118, label %27
]
25: ; preds = %20
%26 = call i8* @strcat(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %20
%28 = call i8* @strcat(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %20, %27, %25
br label %30
30: ; preds = %29, %15
br label %31
31: ; preds = %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %5
34: ; preds = %5
ret i8* getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0)
}

LLVM IR (-O2):
@cfgxstr.s = internal global [400 x i8] zeroinitializer
define i8* @cfgxstr(i8* nocapture %0) {
tail call void @llvm.memset.p0i8.i64(i8* align 16 dereferenceable(400) getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0), i8 0, i64 400, i1 false)
br label %2
2: ; preds = %20, %1
%3 = phi i8* [ %0, %1 ], [ %22, %20 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %23
i8 37, label %8
]
5: ; preds = %2
%6 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0))
%7 = getelementptr inbounds [400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 %6
store i8 %4, i8* %7
br label %20
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %3, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %20 [
i32 110, label %12
i32 118, label %16
]
12: ; preds = %8
%13 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0))
%14 = getelementptr [400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 %13
%15 = bitcast i8* %14 to i16*
store i16 10, i16* %15
br label %20
16: ; preds = %8
%17 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0))
%18 = getelementptr [400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 %17
%19 = bitcast i8* %18 to i32*
store i32 3157553, i32* %19
br label %20
20: ; preds = %5, %8, %16, %12
%21 = phi i8* [ %3, %5 ], [ %9, %8 ], [ %9, %16 ], [ %9, %12 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
br label %2
23: ; preds = %2
ret i8* getelementptr inbounds ([400 x i8], [400 x i8]* @cfgxstr.s, i64 0, i64 0)
}