int icost(int dd) {
  static int t[256] = {
      1024,  1023,  1022,  1021,  1019,  1016,  1012,  1008,  1004,  999,
      993,   986,   979,   972,   964,   955,   946,   936,   925,   914,
      903,   890,   878,   865,   851,   837,   822,   807,   791,   775,
      758,   741,   724,   706,   687,   668,   649,   629,   609,   589,
      568,   547,   526,   504,   482,   460,   437,   414,   391,   368,
      344,   321,   297,   273,   248,   224,   199,   175,   150,   125,
      100,   75,    50,    25,    0,     -25,   -50,   -75,   -100,  -125,
      -150,  -175,  -199,  -224,  -248,  -273,  -297,  -321,  -344,  -368,
      -391,  -414,  -437,  -460,  -482,  -504,  -526,  -547,  -568,  -589,
      -609,  -629,  -649,  -668,  -687,  -706,  -724,  -741,  -758,  -775,
      -791,  -807,  -822,  -837,  -851,  -865,  -878,  -890,  -903,  -914,
      -925,  -936,  -946,  -955,  -964,  -972,  -979,  -986,  -993,  -999,
      -1004, -1008, -1012, -1016, -1019, -1021, -1022, -1023, -1024, -1023,
      -1022, -1021, -1019, -1016, -1012, -1008, -1004, -999,  -993,  -986,
      -979,  -972,  -964,  -955,  -946,  -936,  -925,  -914,  -903,  -890,
      -878,  -865,  -851,  -837,  -822,  -807,  -791,  -775,  -758,  -741,
      -724,  -706,  -687,  -668,  -649,  -629,  -609,  -589,  -568,  -547,
      -526,  -504,  -482,  -460,  -437,  -414,  -391,  -368,  -344,  -321,
      -297,  -273,  -248,  -224,  -199,  -175,  -150,  -125,  -100,  -75,
      -50,   -25,   0,     25,    50,    75,    100,   125,   150,   175,
      199,   224,   248,   273,   297,   321,   344,   368,   391,   414,
      437,   460,   482,   504,   526,   547,   568,   589,   609,   629,
      649,   668,   687,   706,   724,   741,   758,   775,   791,   807,
      822,   837,   851,   865,   878,   890,   903,   914,   925,   936,
      946,   955,   964,   972,   979,   986,   993,   999,   1004,  1008,
      1012,  1016,  1019,  1021,  1022,  1023,
  };
  dd = dd & 0xff;
  return t[dd];
}


x86 assembly (clang, -O0):
<icost>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2f13(%rip),%rax
mov    (%rax,%rcx,4),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<icost>:
movzbl %dil,%eax
lea    0xef5(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
@icost.t = internal global [256 x i32] [i32 1024, i32 1023, i32 1022, i32 1021, i32 1019, i32 1016, i32 1012, i32 1008, i32 1004, i32 999, i32 993, i32 986, i32 979, i32 972, i32 964, i32 955, i32 946, i32 936, i32 925, i32 914, i32 903, i32 890, i32 878, i32 865, i32 851, i32 837, i32 822, i32 807, i32 791, i32 775, i32 758, i32 741, i32 724, i32 706, i32 687, i32 668, i32 649, i32 629, i32 609, i32 589, i32 568, i32 547, i32 526, i32 504, i32 482, i32 460, i32 437, i32 414, i32 391, i32 368, i32 344, i32 321, i32 297, i32 273, i32 248, i32 224, i32 199, i32 175, i32 150, i32 125, i32 100, i32 75, i32 50, i32 25, i32 0, i32 -25, i32 -50, i32 -75, i32 -100, i32 -125, i32 -150, i32 -175, i32 -199, i32 -224, i32 -248, i32 -273, i32 -297, i32 -321, i32 -344, i32 -368, i32 -391, i32 -414, i32 -437, i32 -460, i32 -482, i32 -504, i32 -526, i32 -547, i32 -568, i32 -589, i32 -609, i32 -629, i32 -649, i32 -668, i32 -687, i32 -706, i32 -724, i32 -741, i32 -758, i32 -775, i32 -791, i32 -807, i32 -822, i32 -837, i32 -851, i32 -865, i32 -878, i32 -890, i32 -903, i32 -914, i32 -925, i32 -936, i32 -946, i32 -955, i32 -964, i32 -972, i32 -979, i32 -986, i32 -993, i32 -999, i32 -1004, i32 -1008, i32 -1012, i32 -1016, i32 -1019, i32 -1021, i32 -1022, i32 -1023, i32 -1024, i32 -1023, i32 -1022, i32 -1021, i32 -1019, i32 -1016, i32 -1012, i32 -1008, i32 -1004, i32 -999, i32 -993, i32 -986, i32 -979, i32 -972, i32 -964, i32 -955, i32 -946, i32 -936, i32 -925, i32 -914, i32 -903, i32 -890, i32 -878, i32 -865, i32 -851, i32 -837, i32 -822, i32 -807, i32 -791, i32 -775, i32 -758, i32 -741, i32 -724, i32 -706, i32 -687, i32 -668, i32 -649, i32 -629, i32 -609, i32 -589, i32 -568, i32 -547, i32 -526, i32 -504, i32 -482, i32 -460, i32 -437, i32 -414, i32 -391, i32 -368, i32 -344, i32 -321, i32 -297, i32 -273, i32 -248, i32 -224, i32 -199, i32 -175, i32 -150, i32 -125, i32 -100, i32 -75, i32 -50, i32 -25, i32 0, i32 25, i32 50, i32 75, i32 100, i32 125, i32 150, i32 175, i32 199, i32 224, i32 248, i32 273, i32 297, i32 321, i32 344, i32 368, i32 391, i32 414, i32 437, i32 460, i32 482, i32 504, i32 526, i32 547, i32 568, i32 589, i32 609, i32 629, i32 649, i32 668, i32 687, i32 706, i32 724, i32 741, i32 758, i32 775, i32 791, i32 807, i32 822, i32 837, i32 851, i32 865, i32 878, i32 890, i32 903, i32 914, i32 925, i32 936, i32 946, i32 955, i32 964, i32 972, i32 979, i32 986, i32 993, i32 999, i32 1004, i32 1008, i32 1012, i32 1016, i32 1019, i32 1021, i32 1022, i32 1023]
define i32 @icost(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 255
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [256 x i32], [256 x i32]* @icost.t, i64 0, i64 %6
%8 = load i32, i32* %7
ret i32 %8
}

LLVM IR (-O2):
@icost.t = internal unnamed_addr constant [256 x i32] [i32 1024, i32 1023, i32 1022, i32 1021, i32 1019, i32 1016, i32 1012, i32 1008, i32 1004, i32 999, i32 993, i32 986, i32 979, i32 972, i32 964, i32 955, i32 946, i32 936, i32 925, i32 914, i32 903, i32 890, i32 878, i32 865, i32 851, i32 837, i32 822, i32 807, i32 791, i32 775, i32 758, i32 741, i32 724, i32 706, i32 687, i32 668, i32 649, i32 629, i32 609, i32 589, i32 568, i32 547, i32 526, i32 504, i32 482, i32 460, i32 437, i32 414, i32 391, i32 368, i32 344, i32 321, i32 297, i32 273, i32 248, i32 224, i32 199, i32 175, i32 150, i32 125, i32 100, i32 75, i32 50, i32 25, i32 0, i32 -25, i32 -50, i32 -75, i32 -100, i32 -125, i32 -150, i32 -175, i32 -199, i32 -224, i32 -248, i32 -273, i32 -297, i32 -321, i32 -344, i32 -368, i32 -391, i32 -414, i32 -437, i32 -460, i32 -482, i32 -504, i32 -526, i32 -547, i32 -568, i32 -589, i32 -609, i32 -629, i32 -649, i32 -668, i32 -687, i32 -706, i32 -724, i32 -741, i32 -758, i32 -775, i32 -791, i32 -807, i32 -822, i32 -837, i32 -851, i32 -865, i32 -878, i32 -890, i32 -903, i32 -914, i32 -925, i32 -936, i32 -946, i32 -955, i32 -964, i32 -972, i32 -979, i32 -986, i32 -993, i32 -999, i32 -1004, i32 -1008, i32 -1012, i32 -1016, i32 -1019, i32 -1021, i32 -1022, i32 -1023, i32 -1024, i32 -1023, i32 -1022, i32 -1021, i32 -1019, i32 -1016, i32 -1012, i32 -1008, i32 -1004, i32 -999, i32 -993, i32 -986, i32 -979, i32 -972, i32 -964, i32 -955, i32 -946, i32 -936, i32 -925, i32 -914, i32 -903, i32 -890, i32 -878, i32 -865, i32 -851, i32 -837, i32 -822, i32 -807, i32 -791, i32 -775, i32 -758, i32 -741, i32 -724, i32 -706, i32 -687, i32 -668, i32 -649, i32 -629, i32 -609, i32 -589, i32 -568, i32 -547, i32 -526, i32 -504, i32 -482, i32 -460, i32 -437, i32 -414, i32 -391, i32 -368, i32 -344, i32 -321, i32 -297, i32 -273, i32 -248, i32 -224, i32 -199, i32 -175, i32 -150, i32 -125, i32 -100, i32 -75, i32 -50, i32 -25, i32 0, i32 25, i32 50, i32 75, i32 100, i32 125, i32 150, i32 175, i32 199, i32 224, i32 248, i32 273, i32 297, i32 321, i32 344, i32 368, i32 391, i32 414, i32 437, i32 460, i32 482, i32 504, i32 526, i32 547, i32 568, i32 589, i32 609, i32 629, i32 649, i32 668, i32 687, i32 706, i32 724, i32 741, i32 758, i32 775, i32 791, i32 807, i32 822, i32 837, i32 851, i32 865, i32 878, i32 890, i32 903, i32 914, i32 925, i32 936, i32 946, i32 955, i32 964, i32 972, i32 979, i32 986, i32 993, i32 999, i32 1004, i32 1008, i32 1012, i32 1016, i32 1019, i32 1021, i32 1022, i32 1023]
define i32 @icost(i32 %0) {
%2 = and i32 %0, 255
%3 = zext i32 %2 to i64
%4 = getelementptr inbounds [256 x i32], [256 x i32]* @icost.t, i64 0, i64 %3
%5 = load i32, i32* %4
ret i32 %5
}