long GPIOGetIntNumber(unsigned long ulPort) {
  unsigned int ulInt;
  switch (ulPort) {
  case 0x40004000:
  case 0x40058000: {
    ulInt = 16;
    break;
  }
  case 0x40005000:
  case 0x40059000: {
    ulInt = 17;
    break;
  }
  case 0x40006000:
  case 0x4005A000: {
    ulInt = 18;
    break;
  }
  case 0x40007000:
  case 0x4005B000: {
    ulInt = 19;
    break;
  }
  case 0x40024000:
  case 0x4005C000: {
    ulInt = 20;
    break;
  }
  case 0x40025000:
  case 0x4005D000: {
    ulInt = 46;
    break;
  }
  case 0x40026000:
  case 0x4005E000: {
    ulInt = 47;
    break;
  }
  case 0x40027000:
  case 0x4005F000: {
    ulInt = 48;
    break;
  }
  default: {
    return (-1);
  }
  }
  return (ulInt);
}


x86 assembly (clang, -O0):
<GPIOGetIntNumber>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
sub    $0x40004000,%rax
je     125c <GPIOGetIntNumber+0x15c>
jmp    1121 <GPIOGetIntNumber+0x21>
mov    -0x20(%rbp),%rax
sub    $0x40005000,%rax
je     1268 <GPIOGetIntNumber+0x168>
jmp    1136 <GPIOGetIntNumber+0x36>
mov    -0x20(%rbp),%rax
sub    $0x40006000,%rax
je     1274 <GPIOGetIntNumber+0x174>
jmp    114b <GPIOGetIntNumber+0x4b>
mov    -0x20(%rbp),%rax
sub    $0x40007000,%rax
je     1280 <GPIOGetIntNumber+0x180>
jmp    1160 <GPIOGetIntNumber+0x60>
mov    -0x20(%rbp),%rax
sub    $0x40024000,%rax
je     128c <GPIOGetIntNumber+0x18c>
jmp    1175 <GPIOGetIntNumber+0x75>
mov    -0x20(%rbp),%rax
sub    $0x40025000,%rax
je     1298 <GPIOGetIntNumber+0x198>
jmp    118a <GPIOGetIntNumber+0x8a>
mov    -0x20(%rbp),%rax
sub    $0x40026000,%rax
je     12a4 <GPIOGetIntNumber+0x1a4>
jmp    119f <GPIOGetIntNumber+0x9f>
mov    -0x20(%rbp),%rax
sub    $0x40027000,%rax
je     12b0 <GPIOGetIntNumber+0x1b0>
jmp    11b4 <GPIOGetIntNumber+0xb4>
mov    -0x20(%rbp),%rax
sub    $0x40058000,%rax
je     125c <GPIOGetIntNumber+0x15c>
jmp    11c9 <GPIOGetIntNumber+0xc9>
mov    -0x20(%rbp),%rax
sub    $0x40059000,%rax
je     1268 <GPIOGetIntNumber+0x168>
jmp    11de <GPIOGetIntNumber+0xde>
mov    -0x20(%rbp),%rax
sub    $0x4005a000,%rax
je     1274 <GPIOGetIntNumber+0x174>
jmp    11f3 <GPIOGetIntNumber+0xf3>
mov    -0x20(%rbp),%rax
sub    $0x4005b000,%rax
je     1280 <GPIOGetIntNumber+0x180>
jmp    1208 <GPIOGetIntNumber+0x108>
mov    -0x20(%rbp),%rax
sub    $0x4005c000,%rax
je     128c <GPIOGetIntNumber+0x18c>
jmp    121d <GPIOGetIntNumber+0x11d>
mov    -0x20(%rbp),%rax
sub    $0x4005d000,%rax
je     1298 <GPIOGetIntNumber+0x198>
jmp    1232 <GPIOGetIntNumber+0x132>
mov    -0x20(%rbp),%rax
sub    $0x4005e000,%rax
je     12a4 <GPIOGetIntNumber+0x1a4>
jmp    1247 <GPIOGetIntNumber+0x147>
mov    -0x20(%rbp),%rax
sub    $0x4005f000,%rax
je     12b0 <GPIOGetIntNumber+0x1b0>
jmp    12bc <GPIOGetIntNumber+0x1bc>
movl   $0x10,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x11,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x12,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x13,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x14,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x2e,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x2f,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movl   $0x30,-0x14(%rbp)
jmp    12c9 <GPIOGetIntNumber+0x1c9>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12d0 <GPIOGetIntNumber+0x1d0>
mov    -0x14(%rbp),%eax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPIOGetIntNumber>:
mov    $0x10,%ecx
mov    $0xffffffffffffffff,%rax
cmp    $0x40057fff,%rdi
jg     1146 <GPIOGetIntNumber+0x46>
cmp    $0x40023fff,%rdi
jg     117c <GPIOGetIntNumber+0x7c>
cmp    $0x40005fff,%rdi
jg     11c2 <GPIOGetIntNumber+0xc2>
cmp    $0x40004000,%rdi
je     122f <GPIOGetIntNumber+0x12f>
cmp    $0x40005000,%rdi
je     1172 <GPIOGetIntNumber+0x72>
jmp    1232 <GPIOGetIntNumber+0x132>
cmp    $0x4005bfff,%rdi
jg     11a0 <GPIOGetIntNumber+0xa0>
cmp    $0x40059fff,%rdi
jg     11d6 <GPIOGetIntNumber+0xd6>
cmp    $0x40058000,%rdi
je     122f <GPIOGetIntNumber+0x12f>
cmp    $0x40059000,%rdi
jne    1232 <GPIOGetIntNumber+0x132>
mov    $0x11,%ecx
jmp    122f <GPIOGetIntNumber+0x12f>
cmp    $0x40025fff,%rdi
jg     11ef <GPIOGetIntNumber+0xef>
cmp    $0x40024000,%rdi
je     121c <GPIOGetIntNumber+0x11c>
cmp    $0x40025000,%rdi
je     11bb <GPIOGetIntNumber+0xbb>
jmp    1232 <GPIOGetIntNumber+0x132>
cmp    $0x4005dfff,%rdi
jg     1203 <GPIOGetIntNumber+0x103>
cmp    $0x4005c000,%rdi
je     121c <GPIOGetIntNumber+0x11c>
cmp    $0x4005d000,%rdi
jne    1232 <GPIOGetIntNumber+0x132>
mov    $0x2e,%ecx
jmp    122f <GPIOGetIntNumber+0x12f>
cmp    $0x40006000,%rdi
je     1223 <GPIOGetIntNumber+0x123>
cmp    $0x40007000,%rdi
je     11e8 <GPIOGetIntNumber+0xe8>
jmp    1232 <GPIOGetIntNumber+0x132>
cmp    $0x4005a000,%rdi
je     1223 <GPIOGetIntNumber+0x123>
cmp    $0x4005b000,%rdi
jne    1232 <GPIOGetIntNumber+0x132>
mov    $0x13,%ecx
jmp    122f <GPIOGetIntNumber+0x12f>
cmp    $0x40026000,%rdi
je     122a <GPIOGetIntNumber+0x12a>
cmp    $0x40027000,%rdi
je     1215 <GPIOGetIntNumber+0x115>
jmp    1232 <GPIOGetIntNumber+0x132>
cmp    $0x4005e000,%rdi
je     122a <GPIOGetIntNumber+0x12a>
cmp    $0x4005f000,%rdi
jne    1232 <GPIOGetIntNumber+0x132>
mov    $0x30,%ecx
jmp    122f <GPIOGetIntNumber+0x12f>
mov    $0x14,%ecx
jmp    122f <GPIOGetIntNumber+0x12f>
mov    $0x12,%ecx
jmp    122f <GPIOGetIntNumber+0x12f>
mov    $0x2f,%ecx
mov    %rcx,%rax
ret

LLVM IR (-O0):
define i64 @GPIOGetIntNumber(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
%5 = load i64, i64* %3
switch i64 %5, label %14 [
i64 1073758208, label %6
i64 1074102272, label %6
i64 1073762304, label %7
i64 1074106368, label %7
i64 1073766400, label %8
i64 1074110464, label %8
i64 1073770496, label %9
i64 1074114560, label %9
i64 1073889280, label %10
i64 1074118656, label %10
i64 1073893376, label %11
i64 1074122752, label %11
i64 1073897472, label %12
i64 1074126848, label %12
i64 1073901568, label %13
i64 1074130944, label %13
]
6: ; preds = %1, %1
store i32 16, i32* %4
br label %15
7: ; preds = %1, %1
store i32 17, i32* %4
br label %15
8: ; preds = %1, %1
store i32 18, i32* %4
br label %15
9: ; preds = %1, %1
store i32 19, i32* %4
br label %15
10: ; preds = %1, %1
store i32 20, i32* %4
br label %15
11: ; preds = %1, %1
store i32 46, i32* %4
br label %15
12: ; preds = %1, %1
store i32 47, i32* %4
br label %15
13: ; preds = %1, %1
store i32 48, i32* %4
br label %15
14: ; preds = %1
store i64 -1, i64* %2
br label %18
15: ; preds = %13, %12, %11, %10, %9, %8, %7, %6
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
store i64 %17, i64* %2
br label %18
18: ; preds = %15, %14
%19 = load i64, i64* %2
ret i64 %19
}

LLVM IR (-O2):
define i64 @GPIOGetIntNumber(i64 %0) {
switch i64 %0, label %11 [
i64 1073758208, label %9
i64 1074102272, label %9
i64 1073762304, label %2
i64 1074106368, label %2
i64 1073766400, label %3
i64 1074110464, label %3
i64 1073770496, label %4
i64 1074114560, label %4
i64 1073889280, label %5
i64 1074118656, label %5
i64 1073893376, label %6
i64 1074122752, label %6
i64 1073897472, label %7
i64 1074126848, label %7
i64 1073901568, label %8
i64 1074130944, label %8
]
2: ; preds = %1, %1
br label %9
3: ; preds = %1, %1
br label %9
4: ; preds = %1, %1
br label %9
5: ; preds = %1, %1
br label %9
6: ; preds = %1, %1
br label %9
7: ; preds = %1, %1
br label %9
8: ; preds = %1, %1
br label %9
9: ; preds = %1, %1, %8, %7, %6, %5, %4, %3, %2
%10 = phi i64 [ 48, %8 ], [ 47, %7 ], [ 46, %6 ], [ 20, %5 ], [ 19, %4 ], [ 18, %3 ], [ 17, %2 ], [ 16, %1 ], [ 16, %1 ]
br label %11
11: ; preds = %1, %9
%12 = phi i64 [ %10, %9 ], [ -1, %1 ]
ret i64 %12
}