int aapatterns(struct raster_struct *rp, int irow, int icol, int gridnum,
               int patternum, int grayscale) {
  int aaval = (-1);
  int iscenter = (gridnum & 1);
  int aapatternnum(), aapattern1124(), aapattern19(), aapattern20(),
      aapattern39();
  if (1) {
    if (patternum < 1)
      patternum = aapatternnum(gridnum);
    switch (patternum) {
    default:
      break;
    case 11:
    case 24:
      aaval = aapattern1124(rp, irow, icol, gridnum, grayscale);
      break;
    case 19:
      aaval = aapattern19(rp, irow, icol, gridnum, grayscale);
      break;
    case 20:
      aaval = aapattern20(rp, irow, icol, gridnum, grayscale);
      break;
    case 39:
      aaval = aapattern39(rp, irow, icol, gridnum, grayscale);
      break;
    case 29:
      aaval = (iscenter ? grayscale - 1 : 0);
      break;
    }
  }
  return (aaval);
}


x86 assembly (clang, -O0):
<aapatterns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x18(%rbp)
jge    1194 <aapatterns+0x44>
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1030 <aapatternnum@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xfffffff5,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x1c,%eax
ja     11bd <aapatterns+0x6d>
mov    -0x30(%rbp),%rax
lea    0xe4c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    126a <aapatterns+0x11a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x0,%al
call   1070 <aapattern1124@plt>
mov    %eax,-0x20(%rbp)
jmp    126a <aapatterns+0x11a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x0,%al
call   1050 <aapattern19@plt>
mov    %eax,-0x20(%rbp)
jmp    126a <aapatterns+0x11a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x0,%al
call   1040 <aapattern20@plt>
mov    %eax,-0x20(%rbp)
jmp    126a <aapatterns+0x11a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x0,%al
call   1060 <aapattern39@plt>
mov    %eax,-0x20(%rbp)
jmp    126a <aapatterns+0x11a>
cmpl   $0x0,-0x24(%rbp)
je     125a <aapatterns+0x10a>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1264 <aapatterns+0x114>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    1264 <aapatterns+0x114>
mov    -0x34(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aapatterns>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r12d
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
test   %r8d,%r8d
jg     1177 <aapatterns+0x27>
mov    %ebp,%edi
xor    %eax,%eax
call   1030 <aapatternnum@plt>
mov    %eax,%r8d
mov    $0xffffffff,%eax
add    $0xfffffff5,%r8d
cmp    $0x1c,%r8d
ja     11fc <aapatterns+0xac>
lea    0xe73(%rip),%rcx
movslq (%rcx,%r8,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <aapattern1124@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <aapattern19@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <aapattern20@plt>
and    $0x1,%ebp
neg    %ebp
add    $0xffffffff,%r12d
and    %ebp,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <aapattern39@plt>

LLVM IR (-O0):
%struct.raster_struct = type opaque
define i32 @aapatterns(%struct.raster_struct* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %struct.raster_struct*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store %struct.raster_struct* %0, %struct.raster_struct** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store i32 -1, i32* %13
%15 = load i32, i32* %10
%16 = and i32 %15, 1
store i32 %16, i32* %14
%17 = load i32, i32* %11
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %6
%20 = load i32, i32* %10
%21 = call i32 (i32, ...) bitcast (i32 (...)* @aapatternnum to i32 (i32, ...)*)(i32 %20)
store i32 %21, i32* %11
br label %22
22: ; preds = %19, %6
%23 = load i32, i32* %11
switch i32 %23, label %24 [
i32 11, label %25
i32 24, label %25
i32 19, label %32
i32 20, label %39
i32 39, label %46
i32 29, label %53
]
24: ; preds = %22
br label %62
25: ; preds = %22, %22
%26 = load %struct.raster_struct*, %struct.raster_struct** %7
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %10
%30 = load i32, i32* %12
%31 = call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern1124 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %26, i32 %27, i32 %28, i32 %29, i32 %30)
store i32 %31, i32* %13
br label %62
32: ; preds = %22
%33 = load %struct.raster_struct*, %struct.raster_struct** %7
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = load i32, i32* %12
%38 = call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern19 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %33, i32 %34, i32 %35, i32 %36, i32 %37)
store i32 %38, i32* %13
br label %62
39: ; preds = %22
%40 = load %struct.raster_struct*, %struct.raster_struct** %7
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = load i32, i32* %10
%44 = load i32, i32* %12
%45 = call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern20 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %40, i32 %41, i32 %42, i32 %43, i32 %44)
store i32 %45, i32* %13
br label %62
46: ; preds = %22
%47 = load %struct.raster_struct*, %struct.raster_struct** %7
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = load i32, i32* %10
%51 = load i32, i32* %12
%52 = call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern39 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %47, i32 %48, i32 %49, i32 %50, i32 %51)
store i32 %52, i32* %13
br label %62
53: ; preds = %22
%54 = load i32, i32* %14
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* %12
%58 = sub nsw i32 %57, 1
br label %60
59: ; preds = %53
br label %60
60: ; preds = %59, %56
%61 = phi i32 [ %58, %56 ], [ 0, %59 ]
store i32 %61, i32* %13
br label %62
62: ; preds = %60, %46, %39, %32, %25, %24
%63 = load i32, i32* %13
ret i32 %63
}

LLVM IR (-O2):
%struct.raster_struct = type opaque
define i32 @aapatterns(%struct.raster_struct* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = and i32 %3, 1
%8 = icmp slt i32 %4, 1
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @aapatternnum to i32 (i32, ...)*)(i32 %3)
br label %11
11: ; preds = %9, %6
%12 = phi i32 [ %10, %9 ], [ %4, %6 ]
switch i32 %12, label %25 [
i32 11, label %13
i32 24, label %13
i32 19, label %15
i32 20, label %17
i32 39, label %19
i32 29, label %21
]
13: ; preds = %11, %11
%14 = tail call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern1124 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %0, i32 %1, i32 %2, i32 %3, i32 %5)
br label %25
15: ; preds = %11
%16 = tail call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern19 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %0, i32 %1, i32 %2, i32 %3, i32 %5)
br label %25
17: ; preds = %11
%18 = tail call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern20 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %0, i32 %1, i32 %2, i32 %3, i32 %5)
br label %25
19: ; preds = %11
%20 = tail call i32 (%struct.raster_struct*, i32, i32, i32, i32, ...) bitcast (i32 (...)* @aapattern39 to i32 (%struct.raster_struct*, i32, i32, i32, i32, ...)*)(%struct.raster_struct* %0, i32 %1, i32 %2, i32 %3, i32 %5)
br label %25
21: ; preds = %11
%22 = icmp eq i32 %7, 0
%23 = add nsw i32 %5, -1
%24 = select i1 %22, i32 0, i32 %23
br label %25
25: ; preds = %11, %21, %19, %17, %15, %13
%26 = phi i32 [ -1, %11 ], [ %24, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ]
ret i32 %26
}