char *preprocess_arrobas(char *fmt) {
  if (fmt[0] != '@')
    return fmt;
  switch (fmt[1] - '0') {
  case 0:
    return "%w %h\\n";
  case 1:
    return "%wx%h\\n";
  case 2:
    return "%wx%h %c\\n";
  case 3:
    return "%wx%h %c\\n";
  case 4:
    return "%wx%h [%i %v %a] %c [(%I) (%V) (%A)]\\n";
  case 5:
    return "%wx%h [%k] %c [%K]\\n";
  case 9:
    return "width (\\%w):                  %w\n"
           "height (\\%h):                 %h\n"
           "pixeldim (\\%c):               %c\n"
           "numsamples (\\%n):             %n\n"
           "numpixels (\\%N):              %N\n"
           "min sample (\\%i):             %i\n"
           "average sample (\\%v):         %v\n"
           "median sample (\\%m):          %m\n"
           "max sample (\\%a):             %a\n"
           "smallest pixel (\\%I):         %I\n"
           "average pixel (\\%V):          %V\n"
           "median pixel (\\%M):           %M\n"
           "max pixel (\\%A):              %A\n"
           "sample quartiles (\\%q[*]):       %q[0] %q[25] %q[50] %q[75] "
           "%q[100]\n"
           "different samples (\\%k):      %k\n"
           "different pixels (\\%K):       %K\n"
           "root mean square (\\%r):       %r\n"
           "average absolute value (\\%e): %e\n"
           "infinite samples (\\%y):       %y\n"
           "nan samples (\\%Y):            %Y\n"
           "sum of samples (\\%s):         %s\n"
           "Sum of samples (\\%+):         %+\n"
           "sum of pixels (\\%S):          %S\n";
  default:
    return fmt;
  }
}


x86 assembly (clang, -O0):
<preprocess_arrobas>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
je     1125 <preprocess_arrobas+0x25>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     11c3 <preprocess_arrobas+0xc3>
mov    -0x18(%rbp),%rax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
lea    0xec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
lea    0xea9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
lea    0xec0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11cb <preprocess_arrobas+0xcb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<preprocess_arrobas>:
mov    %rdi,%rax
cmpb   $0x40,(%rdi)
jne    112e <preprocess_arrobas+0x2e>
movsbq 0x1(%rax),%rcx
add    $0xffffffffffffffd0,%rcx
cmp    $0x9,%ecx
ja     112e <preprocess_arrobas+0x2e>
mov    $0x23f,%edx
bt     %ecx,%edx
jae    112e <preprocess_arrobas+0x2e>
lea    0x124d(%rip),%rdx
movslq (%rdx,%rcx,4),%rax
add    %rdx,%rax
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%w %h\\n\00"
@.str.1 = [8 x i8] c"%wx%h\\n\00"
@.str.2 = [11 x i8] c"%wx%h %c\\n\00"
@.str.3 = [39 x i8] c"%wx%h [%i %v %a] %c [(%I) (%V) (%A)]\\n\00"
@.str.4 = [21 x i8] c"%wx%h [%k] %c [%K]\\n\00"
@.str.5 = [795 x i8] c"width (\\%w): %w\0Aheight (\\%h): %h\0Apixeldim (\\%c): %c\0Anumsamples (\\%n): %n\0Anumpixels (\\%N): %N\0Amin sample (\\%i): %i\0Aaverage sample (\\%v): %v\0Amedian sample (\\%m): %m\0Amax sample (\\%a): %a\0Asmallest pixel (\\%I): %I\0Aaverage pixel (\\%V): %V\0Amedian pixel (\\%M): %M\0Amax pixel (\\%A): %A\0Asample quartiles (\\%q[*]): %q[0] %q[25] %q[50] %q[75] %q[100]\0Adifferent samples (\\%k): %k\0Adifferent pixels (\\%K): %K\0Aroot mean square (\\%r): %r\0Aaverage absolute value (\\%e): %e\0Ainfinite samples (\\%y): %y\0Anan samples (\\%Y): %Y\0Asum of samples (\\%s): %s\0ASum of samples (\\%+): %+\0Asum of pixels (\\%S): %S\0A\00"
define i8* @preprocess_arrobas(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 64
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %3
store i8* %10, i8** %2
br label %26
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 48
switch i32 %16, label %24 [
i32 0, label %17
i32 1, label %18
i32 2, label %19
i32 3, label %20
i32 4, label %21
i32 5, label %22
i32 9, label %23
]
17: ; preds = %11
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %26
18: ; preds = %11
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %26
19: ; preds = %11
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %26
20: ; preds = %11
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %26
21: ; preds = %11
store i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %26
22: ; preds = %11
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %26
23: ; preds = %11
store i8* getelementptr inbounds ([795 x i8], [795 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %26
24: ; preds = %11
%25 = load i8*, i8** %3
store i8* %25, i8** %2
br label %26
26: ; preds = %24, %23, %22, %21, %20, %19, %18, %17, %9
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@.str = [8 x i8] c"%w %h\\n\00"
@.str.1 = [8 x i8] c"%wx%h\\n\00"
@.str.2 = [11 x i8] c"%wx%h %c\\n\00"
@.str.3 = [39 x i8] c"%wx%h [%i %v %a] %c [(%I) (%V) (%A)]\\n\00"
@.str.4 = [21 x i8] c"%wx%h [%k] %c [%K]\\n\00"
@.str.5 = [795 x i8] c"width (\\%w): %w\0Aheight (\\%h): %h\0Apixeldim (\\%c): %c\0Anumsamples (\\%n): %n\0Anumpixels (\\%N): %N\0Amin sample (\\%i): %i\0Aaverage sample (\\%v): %v\0Amedian sample (\\%m): %m\0Amax sample (\\%a): %a\0Asmallest pixel (\\%I): %I\0Aaverage pixel (\\%V): %V\0Amedian pixel (\\%M): %M\0Amax pixel (\\%A): %A\0Asample quartiles (\\%q[*]): %q[0] %q[25] %q[50] %q[75] %q[100]\0Adifferent samples (\\%k): %k\0Adifferent pixels (\\%K): %K\0Aroot mean square (\\%r): %r\0Aaverage absolute value (\\%e): %e\0Ainfinite samples (\\%y): %y\0Anan samples (\\%Y): %Y\0Asum of samples (\\%s): %s\0ASum of samples (\\%+): %+\0Asum of pixels (\\%S): %S\0A\00"
@reltable.preprocess_arrobas = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([795 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.preprocess_arrobas to i64)) to i32)]
define i8* @preprocess_arrobas(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 64
br i1 %3, label %4, label %19
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = add nsw i32 %7, -48
%9 = icmp ult i32 %8, 10
br i1 %9, label %10, label %19
10: ; preds = %4
%11 = trunc i32 %8 to i16
%12 = lshr i16 575, %11
%13 = and i16 %12, 1
%14 = icmp eq i16 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = sext i32 %8 to i64
%17 = shl i64 %16, 2
%18 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.preprocess_arrobas to i8*), i64 %17)
br label %19
19: ; preds = %4, %10, %15, %1
%20 = phi i8* [ %0, %1 ], [ %18, %15 ], [ %0, %10 ], [ %0, %4 ]
ret i8* %20
}