int foo(int x) {
  int b[] = {
      400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413,
      414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427,
      428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441,
      442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455,
      456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469,
      470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483,
      484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497,
      498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511,
      512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525,
      526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539,
      540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553,
      554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567,
      568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581,
      582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595,
      596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609,
      610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623,
      624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637,
      638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651,
      652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665,
      666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679,
      680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693,
      694, 695, 696, 697, 698, 699};
  return b[x];
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4c0(%rbp),%rdi
lea    0xed4(%rip),%rsi
mov    $0x4b0,%edx
call   1030 <memcpy@plt>
movslq -0x4(%rbp),%rax
mov    -0x4c0(%rbp,%rax,4),%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
movslq %edi,%rax
lea    0xef6(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
@__const.foo.b = [300 x i32] [i32 400, i32 401, i32 402, i32 403, i32 404, i32 405, i32 406, i32 407, i32 408, i32 409, i32 410, i32 411, i32 412, i32 413, i32 414, i32 415, i32 416, i32 417, i32 418, i32 419, i32 420, i32 421, i32 422, i32 423, i32 424, i32 425, i32 426, i32 427, i32 428, i32 429, i32 430, i32 431, i32 432, i32 433, i32 434, i32 435, i32 436, i32 437, i32 438, i32 439, i32 440, i32 441, i32 442, i32 443, i32 444, i32 445, i32 446, i32 447, i32 448, i32 449, i32 450, i32 451, i32 452, i32 453, i32 454, i32 455, i32 456, i32 457, i32 458, i32 459, i32 460, i32 461, i32 462, i32 463, i32 464, i32 465, i32 466, i32 467, i32 468, i32 469, i32 470, i32 471, i32 472, i32 473, i32 474, i32 475, i32 476, i32 477, i32 478, i32 479, i32 480, i32 481, i32 482, i32 483, i32 484, i32 485, i32 486, i32 487, i32 488, i32 489, i32 490, i32 491, i32 492, i32 493, i32 494, i32 495, i32 496, i32 497, i32 498, i32 499, i32 500, i32 501, i32 502, i32 503, i32 504, i32 505, i32 506, i32 507, i32 508, i32 509, i32 510, i32 511, i32 512, i32 513, i32 514, i32 515, i32 516, i32 517, i32 518, i32 519, i32 520, i32 521, i32 522, i32 523, i32 524, i32 525, i32 526, i32 527, i32 528, i32 529, i32 530, i32 531, i32 532, i32 533, i32 534, i32 535, i32 536, i32 537, i32 538, i32 539, i32 540, i32 541, i32 542, i32 543, i32 544, i32 545, i32 546, i32 547, i32 548, i32 549, i32 550, i32 551, i32 552, i32 553, i32 554, i32 555, i32 556, i32 557, i32 558, i32 559, i32 560, i32 561, i32 562, i32 563, i32 564, i32 565, i32 566, i32 567, i32 568, i32 569, i32 570, i32 571, i32 572, i32 573, i32 574, i32 575, i32 576, i32 577, i32 578, i32 579, i32 580, i32 581, i32 582, i32 583, i32 584, i32 585, i32 586, i32 587, i32 588, i32 589, i32 590, i32 591, i32 592, i32 593, i32 594, i32 595, i32 596, i32 597, i32 598, i32 599, i32 600, i32 601, i32 602, i32 603, i32 604, i32 605, i32 606, i32 607, i32 608, i32 609, i32 610, i32 611, i32 612, i32 613, i32 614, i32 615, i32 616, i32 617, i32 618, i32 619, i32 620, i32 621, i32 622, i32 623, i32 624, i32 625, i32 626, i32 627, i32 628, i32 629, i32 630, i32 631, i32 632, i32 633, i32 634, i32 635, i32 636, i32 637, i32 638, i32 639, i32 640, i32 641, i32 642, i32 643, i32 644, i32 645, i32 646, i32 647, i32 648, i32 649, i32 650, i32 651, i32 652, i32 653, i32 654, i32 655, i32 656, i32 657, i32 658, i32 659, i32 660, i32 661, i32 662, i32 663, i32 664, i32 665, i32 666, i32 667, i32 668, i32 669, i32 670, i32 671, i32 672, i32 673, i32 674, i32 675, i32 676, i32 677, i32 678, i32 679, i32 680, i32 681, i32 682, i32 683, i32 684, i32 685, i32 686, i32 687, i32 688, i32 689, i32 690, i32 691, i32 692, i32 693, i32 694, i32 695, i32 696, i32 697, i32 698, i32 699]
define i32 @foo(i32 %0) {
%2 = alloca i32
%3 = alloca [300 x i32]
store i32 %0, i32* %2
%4 = bitcast [300 x i32]* %3 to i8*
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [300 x i32], [300 x i32]* %3, i64 0, i64 %6
%8 = load i32, i32* %7
ret i32 %8
}

LLVM IR (-O2):
@__const.foo.b = [300 x i32] [i32 400, i32 401, i32 402, i32 403, i32 404, i32 405, i32 406, i32 407, i32 408, i32 409, i32 410, i32 411, i32 412, i32 413, i32 414, i32 415, i32 416, i32 417, i32 418, i32 419, i32 420, i32 421, i32 422, i32 423, i32 424, i32 425, i32 426, i32 427, i32 428, i32 429, i32 430, i32 431, i32 432, i32 433, i32 434, i32 435, i32 436, i32 437, i32 438, i32 439, i32 440, i32 441, i32 442, i32 443, i32 444, i32 445, i32 446, i32 447, i32 448, i32 449, i32 450, i32 451, i32 452, i32 453, i32 454, i32 455, i32 456, i32 457, i32 458, i32 459, i32 460, i32 461, i32 462, i32 463, i32 464, i32 465, i32 466, i32 467, i32 468, i32 469, i32 470, i32 471, i32 472, i32 473, i32 474, i32 475, i32 476, i32 477, i32 478, i32 479, i32 480, i32 481, i32 482, i32 483, i32 484, i32 485, i32 486, i32 487, i32 488, i32 489, i32 490, i32 491, i32 492, i32 493, i32 494, i32 495, i32 496, i32 497, i32 498, i32 499, i32 500, i32 501, i32 502, i32 503, i32 504, i32 505, i32 506, i32 507, i32 508, i32 509, i32 510, i32 511, i32 512, i32 513, i32 514, i32 515, i32 516, i32 517, i32 518, i32 519, i32 520, i32 521, i32 522, i32 523, i32 524, i32 525, i32 526, i32 527, i32 528, i32 529, i32 530, i32 531, i32 532, i32 533, i32 534, i32 535, i32 536, i32 537, i32 538, i32 539, i32 540, i32 541, i32 542, i32 543, i32 544, i32 545, i32 546, i32 547, i32 548, i32 549, i32 550, i32 551, i32 552, i32 553, i32 554, i32 555, i32 556, i32 557, i32 558, i32 559, i32 560, i32 561, i32 562, i32 563, i32 564, i32 565, i32 566, i32 567, i32 568, i32 569, i32 570, i32 571, i32 572, i32 573, i32 574, i32 575, i32 576, i32 577, i32 578, i32 579, i32 580, i32 581, i32 582, i32 583, i32 584, i32 585, i32 586, i32 587, i32 588, i32 589, i32 590, i32 591, i32 592, i32 593, i32 594, i32 595, i32 596, i32 597, i32 598, i32 599, i32 600, i32 601, i32 602, i32 603, i32 604, i32 605, i32 606, i32 607, i32 608, i32 609, i32 610, i32 611, i32 612, i32 613, i32 614, i32 615, i32 616, i32 617, i32 618, i32 619, i32 620, i32 621, i32 622, i32 623, i32 624, i32 625, i32 626, i32 627, i32 628, i32 629, i32 630, i32 631, i32 632, i32 633, i32 634, i32 635, i32 636, i32 637, i32 638, i32 639, i32 640, i32 641, i32 642, i32 643, i32 644, i32 645, i32 646, i32 647, i32 648, i32 649, i32 650, i32 651, i32 652, i32 653, i32 654, i32 655, i32 656, i32 657, i32 658, i32 659, i32 660, i32 661, i32 662, i32 663, i32 664, i32 665, i32 666, i32 667, i32 668, i32 669, i32 670, i32 671, i32 672, i32 673, i32 674, i32 675, i32 676, i32 677, i32 678, i32 679, i32 680, i32 681, i32 682, i32 683, i32 684, i32 685, i32 686, i32 687, i32 688, i32 689, i32 690, i32 691, i32 692, i32 693, i32 694, i32 695, i32 696, i32 697, i32 698, i32 699]
define i32 @foo(i32 %0) {
%2 = sext i32 %0 to i64
%3 = getelementptr inbounds [300 x i32], [300 x i32]* @__const.foo.b, i64 0, i64 %2
%4 = load i32, i32* %3
ret i32 %4
}