char *tagname(int tag) {
  static struct tagnamestruct {
    int code;
    char *name;
  } tagnames[] = {{256, "width"},
                  {257, "length"},
                  {258, "bits/sample"},
                  {259, "compresssion(g3=3)"},
                  {262, "photometric(0-min=white)"},
                  {266, "fill order(msb2lsb=1)"},
                  {273, "strip offsets"},
                  {274, "orientation(1=normal)"},
                  {277, "samples/pixel"},
                  {278, "rows/strip"},
                  {279, "strip byte counts"},
                  {282, "xresolution"},
                  {283, "yresolution"},
                  {284, "storage(1=single plane)"},
                  {292, "g3options"},
                  {296, "resolution units(2=in,3=cm)"},
                  {297, "page number"},
                  {327, "clean fax(0=clean/1=regen/2=errors)"},
                  {0, 0}},
    *p;
  for (p = tagnames; p->code; p++)
    if (tag == p->code)
      break;
  return p->code ? p->name : "unknown tag";
}


x86 assembly (clang, -O0):
<tagname>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
lea    0x2f22(%rip),%rax
mov    %rax,0x3053(%rip)
mov    0x304c(%rip),%rax
cmpl   $0x0,(%rax)
je     1158 <tagname+0x58>
mov    -0x4(%rbp),%eax
mov    0x3039(%rip),%rcx
cmp    (%rcx),%eax
jne    113c <tagname+0x3c>
jmp    1158 <tagname+0x58>
jmp    1141 <tagname+0x41>
mov    0x3020(%rip),%rax
add    $0x10,%rax
mov    %rax,0x3015(%rip)
jmp    1115 <tagname+0x15>
mov    0x3009(%rip),%rax
cmpl   $0x0,(%rax)
je     117c <tagname+0x7c>
mov    0x2ff9(%rip),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    118c <tagname+0x8c>
lea    0xfad(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    118c <tagname+0x8c>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tagname>:
lea    0x2f29(%rip),%rax
nopw   0x0(%rax,%rax,1)
mov    (%rax),%ecx
add    $0x10,%rax
test   %ecx,%ecx
je     111e <tagname+0x1e>
cmp    %edi,%ecx
jne    1110 <tagname+0x10>
test   %ecx,%ecx
je     1127 <tagname+0x27>
mov    -0x8(%rax),%rax
ret
lea    0x1002(%rip),%rax
ret

LLVM IR (-O0):
%struct.tagnamestruct = type { i32, i8* }
@tagname.tagnames = internal global [19 x %struct.tagnamestruct] [%struct.tagnamestruct { i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0) }, %struct.tagnamestruct { i32 257, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0) }, %struct.tagnamestruct { i32 258, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0) }, %struct.tagnamestruct { i32 259, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0) }, %struct.tagnamestruct { i32 262, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i32 0, i32 0) }, %struct.tagnamestruct { i32 266, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i32 0, i32 0) }, %struct.tagnamestruct { i32 273, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0) }, %struct.tagnamestruct { i32 274, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0) }, %struct.tagnamestruct { i32 277, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0) }, %struct.tagnamestruct { i32 278, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i32 0, i32 0) }, %struct.tagnamestruct { i32 279, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i32 0, i32 0) }, %struct.tagnamestruct { i32 282, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i32 0, i32 0) }, %struct.tagnamestruct { i32 283, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i32 0, i32 0) }, %struct.tagnamestruct { i32 284, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i32 0, i32 0) }, %struct.tagnamestruct { i32 292, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i32 0, i32 0) }, %struct.tagnamestruct { i32 296, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i32 0, i32 0) }, %struct.tagnamestruct { i32 297, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0) }, %struct.tagnamestruct { i32 327, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i32 0, i32 0) }, %struct.tagnamestruct zeroinitializer]
@.str = [6 x i8] c"width\00"
@.str.1 = [7 x i8] c"length\00"
@.str.2 = [12 x i8] c"bits/sample\00"
@.str.3 = [19 x i8] c"compresssion(g3=3)\00"
@.str.4 = [25 x i8] c"photometric(0-min=white)\00"
@.str.5 = [22 x i8] c"fill order(msb2lsb=1)\00"
@.str.6 = [14 x i8] c"strip offsets\00"
@.str.7 = [22 x i8] c"orientation(1=normal)\00"
@.str.8 = [14 x i8] c"samples/pixel\00"
@.str.9 = [11 x i8] c"rows/strip\00"
@.str.10 = [18 x i8] c"strip byte counts\00"
@.str.11 = [12 x i8] c"xresolution\00"
@.str.12 = [12 x i8] c"yresolution\00"
@.str.13 = [24 x i8] c"storage(1=single plane)\00"
@.str.14 = [10 x i8] c"g3options\00"
@.str.15 = [28 x i8] c"resolution units(2=in,3=cm)\00"
@.str.16 = [12 x i8] c"page number\00"
@.str.17 = [36 x i8] c"clean fax(0=clean/1=regen/2=errors)\00"
@tagname.p = internal global %struct.tagnamestruct* null
@.str.18 = [12 x i8] c"unknown tag\00"
define i8* @tagname(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
store %struct.tagnamestruct* getelementptr inbounds ([19 x %struct.tagnamestruct], [19 x %struct.tagnamestruct]* @tagname.tagnames, i64 0, i64 0), %struct.tagnamestruct** @tagname.p
br label %3
3: ; preds = %16, %1
%4 = load %struct.tagnamestruct*, %struct.tagnamestruct** @tagname.p
%5 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %3
%9 = load i32, i32* %2
%10 = load %struct.tagnamestruct*, %struct.tagnamestruct** @tagname.p
%11 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp eq i32 %9, %12
br i1 %13, label %14, label %15
14: ; preds = %8
br label %19
15: ; preds = %8
br label %16
16: ; preds = %15
%17 = load %struct.tagnamestruct*, %struct.tagnamestruct** @tagname.p
%18 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %17, i32 1
store %struct.tagnamestruct* %18, %struct.tagnamestruct** @tagname.p
br label %3
19: ; preds = %14, %3
%20 = load %struct.tagnamestruct*, %struct.tagnamestruct** @tagname.p
%21 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load %struct.tagnamestruct*, %struct.tagnamestruct** @tagname.p
%26 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %25, i32 0, i32 1
%27 = load i8*, i8** %26
br label %29
28: ; preds = %19
br label %29
29: ; preds = %28, %24
%30 = phi i8* [ %27, %24 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0), %28 ]
ret i8* %30
}

LLVM IR (-O2):
%struct.tagnamestruct = type { i32, i8* }
@tagname.tagnames = internal global [19 x %struct.tagnamestruct] [%struct.tagnamestruct { i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0) }, %struct.tagnamestruct { i32 257, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0) }, %struct.tagnamestruct { i32 258, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0) }, %struct.tagnamestruct { i32 259, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0) }, %struct.tagnamestruct { i32 262, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i32 0, i32 0) }, %struct.tagnamestruct { i32 266, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i32 0, i32 0) }, %struct.tagnamestruct { i32 273, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0) }, %struct.tagnamestruct { i32 274, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i32 0, i32 0) }, %struct.tagnamestruct { i32 277, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0) }, %struct.tagnamestruct { i32 278, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i32 0, i32 0) }, %struct.tagnamestruct { i32 279, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i32 0, i32 0) }, %struct.tagnamestruct { i32 282, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i32 0, i32 0) }, %struct.tagnamestruct { i32 283, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i32 0, i32 0) }, %struct.tagnamestruct { i32 284, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i32 0, i32 0) }, %struct.tagnamestruct { i32 292, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i32 0, i32 0) }, %struct.tagnamestruct { i32 296, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i32 0, i32 0) }, %struct.tagnamestruct { i32 297, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0) }, %struct.tagnamestruct { i32 327, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i32 0, i32 0) }, %struct.tagnamestruct zeroinitializer]
@.str = [6 x i8] c"width\00"
@.str.1 = [7 x i8] c"length\00"
@.str.2 = [12 x i8] c"bits/sample\00"
@.str.3 = [19 x i8] c"compresssion(g3=3)\00"
@.str.4 = [25 x i8] c"photometric(0-min=white)\00"
@.str.5 = [22 x i8] c"fill order(msb2lsb=1)\00"
@.str.6 = [14 x i8] c"strip offsets\00"
@.str.7 = [22 x i8] c"orientation(1=normal)\00"
@.str.8 = [14 x i8] c"samples/pixel\00"
@.str.9 = [11 x i8] c"rows/strip\00"
@.str.10 = [18 x i8] c"strip byte counts\00"
@.str.11 = [12 x i8] c"xresolution\00"
@.str.12 = [12 x i8] c"yresolution\00"
@.str.13 = [24 x i8] c"storage(1=single plane)\00"
@.str.14 = [10 x i8] c"g3options\00"
@.str.15 = [28 x i8] c"resolution units(2=in,3=cm)\00"
@.str.16 = [12 x i8] c"page number\00"
@.str.17 = [36 x i8] c"clean fax(0=clean/1=regen/2=errors)\00"
@.str.18 = [12 x i8] c"unknown tag\00"
define i8* @tagname(i32 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi %struct.tagnamestruct* [ getelementptr inbounds ([19 x %struct.tagnamestruct], [19 x %struct.tagnamestruct]* @tagname.tagnames, i64 0, i64 0), %1 ], [ %9, %2 ]
%4 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %3, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
%7 = icmp eq i32 %5, %0
%8 = or i1 %6, %7
%9 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %3, i64 1
br i1 %8, label %10, label %2
10: ; preds = %2
br i1 %6, label %14, label %11
11: ; preds = %10
%12 = getelementptr inbounds %struct.tagnamestruct, %struct.tagnamestruct* %3, i64 0, i32 1
%13 = load i8*, i8** %12
br label %14
14: ; preds = %10, %11
%15 = phi i8* [ %13, %11 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0), %10 ]
ret i8* %15
}