const char *modifier_string(unsigned long mod) {
  static char buffer[100];
  int len = 0;
  int i;
  struct mod_name {
    unsigned long mod;
    const char *name;
  } * m;
  static struct mod_name mod_names[] = {
      {0x0001, "auto"},
      {0x0002, "register"},
      {0x0004, "static"},
      {0x0008, "extern"},
      {0x0010, "const"},
      {0x0020, "volatile"},
      {0x0040, "[signed]"},
      {0x0080, "[unsigned]"},
      {0x0100, "[char]"},
      {0x0200, "[short]"},
      {0x0400, "[long]"},
      {0x0800, "[long long]"},
      {0x1000, "[long long long]"},
      {0x10000, "[typedef]"},
      {0x20000, "[tls]"},
      {0x40000, "inline"},
      {0x80000, "[addressable]"},
      {0x100000, "[nocast]"},
      {0x200000, "[noderef]"},
      {0x400000, "[accessed]"},
      {0x800000, "[toplevel]"},
      {0x2000000, "[assigned]"},
      {0x4000000, "[type]"},
      {0x8000000, "[safe]"},
      {0x10000000, "[usertype]"},
      {0x20000000, "[noreturn]"},
      {0x40000000, "[explicitly-signed]"},
      {0x80000000, "[bitwise]"},
      {0x2000, "[pure]"},
  };
  for (i = 0; i < (sizeof(mod_names) / sizeof((mod_names)[0])); i++) {
    m = mod_names + i;
    if (mod & m->mod) {
      char c;
      const char *name = m->name;
      while ((c = *name++) != '\0' && len + 2 < sizeof buffer)
        buffer[len++] = c;
      buffer[len++] = ' ';
    }
  }
  buffer[len] = 0;
  return buffer;
}


x86 assembly (clang, -O0):
<modifier_string>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x1d,%rax
jae    11ee <modifier_string+0xee>
movslq -0x10(%rbp),%rcx
lea    0x2f01(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
and    (%rcx),%rax
cmp    $0x0,%rax
je     11db <modifier_string+0xdb>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     1192 <modifier_string+0x92>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
cltq
cmp    $0x64,%rax
setb   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a2 <modifier_string+0xa2>
jmp    11c2 <modifier_string+0xc2>
mov    -0x19(%rbp),%dl
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x3056(%rip),%rax
mov    %dl,(%rax,%rcx,1)
jmp    115b <modifier_string+0x5b>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x3039(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
jmp    11e0 <modifier_string+0xe0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1116 <modifier_string+0x16>
movslq -0xc(%rbp),%rcx
lea    0x3017(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x300c(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<modifier_string>:
push   %rbx
xor    %r9d,%r9d
lea    0x2b75(%rip),%r8
lea    0x2f1e(%rip),%rax
xor    %esi,%esi
jmp    1138 <modifier_string+0x38>
cs nopw 0x0(%rax,%rax,1)
mov    %esi,%edx
movslq %edx,%rcx
add    $0x1,%edx
movb   $0x20,(%rcx,%rax,1)
mov    %edx,%esi
add    $0x1,%r9
cmp    $0x1d,%r9
je     1184 <modifier_string+0x84>
mov    %r9,%rcx
shl    $0x4,%rcx
test   %rdi,(%rcx,%r8,1)
je     112e <modifier_string+0x2e>
mov    0x8(%rcx,%r8,1),%r10
mov    (%r10),%cl
test   %cl,%cl
je     1120 <modifier_string+0x20>
lea    0x2(%rsi),%edx
cmp    $0x63,%edx
ja     1120 <modifier_string+0x20>
movslq %esi,%r11
xor    %ebx,%ebx
xchg   %ax,%ax
lea    (%r11,%rbx,1),%rdx
mov    %cl,(%rax,%rdx,1)
movzbl 0x1(%r10,%rbx,1),%ecx
lea    0x1(%rsi),%edx
test   %cl,%cl
je     1122 <modifier_string+0x22>
add    $0x3,%esi
add    $0x1,%rbx
cmp    $0x64,%esi
mov    %edx,%esi
jb     1160 <modifier_string+0x60>
jmp    1122 <modifier_string+0x22>
movslq %esi,%rcx
movb   $0x0,(%rcx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
%struct.mod_name = type { i64, i8* }
@modifier_string.buffer = internal global [100 x i8] zeroinitializer
@modifier_string.mod_names = internal global [29 x %struct.mod_name] [%struct.mod_name { i64 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0) }, %struct.mod_name { i64 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0) }, %struct.mod_name { i64 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0) }, %struct.mod_name { i64 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0) }, %struct.mod_name { i64 16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0) }, %struct.mod_name { i64 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0) }, %struct.mod_name { i64 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0) }, %struct.mod_name { i64 128, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0) }, %struct.mod_name { i64 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0) }, %struct.mod_name { i64 512, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0) }, %struct.mod_name { i64 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0) }, %struct.mod_name { i64 2048, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i32 0, i32 0) }, %struct.mod_name { i64 4096, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i32 0, i32 0) }, %struct.mod_name { i64 65536, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i32 0, i32 0) }, %struct.mod_name { i64 131072, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0) }, %struct.mod_name { i64 262144, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i32 0, i32 0) }, %struct.mod_name { i64 524288, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i32 0, i32 0) }, %struct.mod_name { i64 1048576, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0) }, %struct.mod_name { i64 2097152, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i32 0, i32 0) }, %struct.mod_name { i64 4194304, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i32 0, i32 0) }, %struct.mod_name { i64 8388608, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i32 0, i32 0) }, %struct.mod_name { i64 33554432, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i32 0, i32 0) }, %struct.mod_name { i64 67108864, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i32 0, i32 0) }, %struct.mod_name { i64 134217728, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i32 0, i32 0) }, %struct.mod_name { i64 268435456, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i32 0, i32 0) }, %struct.mod_name { i64 536870912, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.25, i32 0, i32 0) }, %struct.mod_name { i64 1073741824, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.26, i32 0, i32 0) }, %struct.mod_name { i64 2147483648, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.27, i32 0, i32 0) }, %struct.mod_name { i64 8192, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.28, i32 0, i32 0) }]
@.str = [5 x i8] c"auto\00"
@.str.1 = [9 x i8] c"register\00"
@.str.2 = [7 x i8] c"static\00"
@.str.3 = [7 x i8] c"extern\00"
@.str.4 = [6 x i8] c"const\00"
@.str.5 = [9 x i8] c"volatile\00"
@.str.6 = [9 x i8] c"[signed]\00"
@.str.7 = [11 x i8] c"[unsigned]\00"
@.str.8 = [7 x i8] c"[char]\00"
@.str.9 = [8 x i8] c"[short]\00"
@.str.10 = [7 x i8] c"[long]\00"
@.str.11 = [12 x i8] c"[long long]\00"
@.str.12 = [17 x i8] c"[long long long]\00"
@.str.13 = [10 x i8] c"[typedef]\00"
@.str.14 = [6 x i8] c"[tls]\00"
@.str.15 = [7 x i8] c"inline\00"
@.str.16 = [14 x i8] c"[addressable]\00"
@.str.17 = [9 x i8] c"[nocast]\00"
@.str.18 = [10 x i8] c"[noderef]\00"
@.str.19 = [11 x i8] c"[accessed]\00"
@.str.20 = [11 x i8] c"[toplevel]\00"
@.str.21 = [11 x i8] c"[assigned]\00"
@.str.22 = [7 x i8] c"[type]\00"
@.str.23 = [7 x i8] c"[safe]\00"
@.str.24 = [11 x i8] c"[usertype]\00"
@.str.25 = [11 x i8] c"[noreturn]\00"
@.str.26 = [20 x i8] c"[explicitly-signed]\00"
@.str.27 = [10 x i8] c"[bitwise]\00"
@.str.28 = [7 x i8] c"[pure]\00"
define i8* @modifier_string(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.mod_name*
%6 = alloca i8
%7 = alloca i8*
store i64 %0, i64* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %51, %1
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = icmp ult i64 %10, 29
br i1 %11, label %12, label %54
12: ; preds = %8
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds %struct.mod_name, %struct.mod_name* getelementptr inbounds ([29 x %struct.mod_name], [29 x %struct.mod_name]* @modifier_string.mod_names, i64 0, i64 0), i64 %14
store %struct.mod_name* %15, %struct.mod_name** %5
%16 = load i64, i64* %2
%17 = load %struct.mod_name*, %struct.mod_name** %5
%18 = getelementptr inbounds %struct.mod_name, %struct.mod_name* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = and i64 %16, %19
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %50
22: ; preds = %12
%23 = load %struct.mod_name*, %struct.mod_name** %5
%24 = getelementptr inbounds %struct.mod_name, %struct.mod_name* %23, i32 0, i32 1
%25 = load i8*, i8** %24
store i8* %25, i8** %7
br label %26
26: ; preds = %39, %22
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
%29 = load i8, i8* %27
store i8 %29, i8* %6
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %26
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 2
%35 = sext i32 %34 to i64
%36 = icmp ult i64 %35, 100
br label %37
37: ; preds = %32, %26
%38 = phi i1 [ false, %26 ], [ %36, %32 ]
br i1 %38, label %39, label %45
39: ; preds = %37
%40 = load i8, i8* %6
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 %43
store i8 %40, i8* %44
br label %26
45: ; preds = %37
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 %48
store i8 32, i8* %49
br label %50
50: ; preds = %45, %12
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %8
54: ; preds = %8
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 %56
store i8 0, i8* %57
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.mod_name = type { i64, i8* }
@modifier_string.buffer = internal global [100 x i8] zeroinitializer
@modifier_string.mod_names = internal unnamed_addr constant [29 x %struct.mod_name] [%struct.mod_name { i64 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0) }, %struct.mod_name { i64 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0) }, %struct.mod_name { i64 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0) }, %struct.mod_name { i64 8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0) }, %struct.mod_name { i64 16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0) }, %struct.mod_name { i64 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0) }, %struct.mod_name { i64 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0) }, %struct.mod_name { i64 128, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i32 0, i32 0) }, %struct.mod_name { i64 256, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0) }, %struct.mod_name { i64 512, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0) }, %struct.mod_name { i64 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i32 0, i32 0) }, %struct.mod_name { i64 2048, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i32 0, i32 0) }, %struct.mod_name { i64 4096, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i32 0, i32 0) }, %struct.mod_name { i64 65536, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i32 0, i32 0) }, %struct.mod_name { i64 131072, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i32 0, i32 0) }, %struct.mod_name { i64 262144, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i32 0, i32 0) }, %struct.mod_name { i64 524288, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i32 0, i32 0) }, %struct.mod_name { i64 1048576, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i32 0, i32 0) }, %struct.mod_name { i64 2097152, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i32 0, i32 0) }, %struct.mod_name { i64 4194304, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i32 0, i32 0) }, %struct.mod_name { i64 8388608, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i32 0, i32 0) }, %struct.mod_name { i64 33554432, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i32 0, i32 0) }, %struct.mod_name { i64 67108864, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i32 0, i32 0) }, %struct.mod_name { i64 134217728, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i32 0, i32 0) }, %struct.mod_name { i64 268435456, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i32 0, i32 0) }, %struct.mod_name { i64 536870912, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.25, i32 0, i32 0) }, %struct.mod_name { i64 1073741824, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.26, i32 0, i32 0) }, %struct.mod_name { i64 2147483648, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.27, i32 0, i32 0) }, %struct.mod_name { i64 8192, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.28, i32 0, i32 0) }]
@.str = [5 x i8] c"auto\00"
@.str.1 = [9 x i8] c"register\00"
@.str.2 = [7 x i8] c"static\00"
@.str.3 = [7 x i8] c"extern\00"
@.str.4 = [6 x i8] c"const\00"
@.str.5 = [9 x i8] c"volatile\00"
@.str.6 = [9 x i8] c"[signed]\00"
@.str.7 = [11 x i8] c"[unsigned]\00"
@.str.8 = [7 x i8] c"[char]\00"
@.str.9 = [8 x i8] c"[short]\00"
@.str.10 = [7 x i8] c"[long]\00"
@.str.11 = [12 x i8] c"[long long]\00"
@.str.12 = [17 x i8] c"[long long long]\00"
@.str.13 = [10 x i8] c"[typedef]\00"
@.str.14 = [6 x i8] c"[tls]\00"
@.str.15 = [7 x i8] c"inline\00"
@.str.16 = [14 x i8] c"[addressable]\00"
@.str.17 = [9 x i8] c"[nocast]\00"
@.str.18 = [10 x i8] c"[noderef]\00"
@.str.19 = [11 x i8] c"[accessed]\00"
@.str.20 = [11 x i8] c"[toplevel]\00"
@.str.21 = [11 x i8] c"[assigned]\00"
@.str.22 = [7 x i8] c"[type]\00"
@.str.23 = [7 x i8] c"[safe]\00"
@.str.24 = [11 x i8] c"[usertype]\00"
@.str.25 = [11 x i8] c"[noreturn]\00"
@.str.26 = [20 x i8] c"[explicitly-signed]\00"
@.str.27 = [10 x i8] c"[bitwise]\00"
@.str.28 = [7 x i8] c"[pure]\00"
define i8* @modifier_string(i64 %0) {
br label %2
2: ; preds = %1, %39
%3 = phi i64 [ 0, %1 ], [ %41, %39 ]
%4 = phi i32 [ 0, %1 ], [ %40, %39 ]
%5 = getelementptr inbounds [29 x %struct.mod_name], [29 x %struct.mod_name]* @modifier_string.mod_names, i64 0, i64 %3, i32 0
%6 = load i64, i64* %5
%7 = and i64 %6, %0
%8 = icmp eq i64 %7, 0
br i1 %8, label %39, label %9
9: ; preds = %2
%10 = getelementptr inbounds [29 x %struct.mod_name], [29 x %struct.mod_name]* @modifier_string.mod_names, i64 0, i64 %3, i32 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
%14 = add nsw i32 %4, 2
%15 = icmp ult i32 %14, 100
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %34
17: ; preds = %9
%18 = sext i32 %4 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ %18, %17 ], [ %24, %19 ]
%21 = phi i8 [ %12, %17 ], [ %26, %19 ]
%22 = phi i8* [ %11, %17 ], [ %23, %19 ]
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = add nsw i64 %20, 1
%25 = getelementptr inbounds [100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 %20
store i8 %21, i8* %25
%26 = load i8, i8* %23
%27 = icmp ne i8 %26, 0
%28 = trunc i64 %20 to i32
%29 = add i32 %28, 3
%30 = icmp ult i32 %29, 100
%31 = select i1 %27, i1 %30, i1 false
br i1 %31, label %19, label %32
32: ; preds = %19
%33 = trunc i64 %24 to i32
br label %34
34: ; preds = %32, %9
%35 = phi i32 [ %4, %9 ], [ %33, %32 ]
%36 = add nsw i32 %35, 1
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 %37
store i8 32, i8* %38
br label %39
39: ; preds = %2, %34
%40 = phi i32 [ %36, %34 ], [ %4, %2 ]
%41 = add nuw nsw i64 %3, 1
%42 = icmp eq i64 %41, 29
br i1 %42, label %43, label %2
43: ; preds = %39
%44 = sext i32 %40 to i64
%45 = getelementptr inbounds [100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 %44
store i8 0, i8* %45
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @modifier_string.buffer, i64 0, i64 0)
}