#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
unsigned long compute_something_fast(void) {
  unsigned char s[256], i, j, t;
  int count = 1000, k;
  unsigned long output = 0;
  for (k = 0; k < 256; k++)
    s[k] = k;
  i = 0;
  j = 0;
  while (count--) {
    i++;
    j = j + s[i];
    t = s[i];
    s[i] = s[j];
    s[j] = t;
    output += s[(s[i] + s[j]) & 255];
  }
  return output;
}


x86 assembly (clang, -O0):
<compute_something_fast>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x3e8,-0x108(%rbp)
movq   $0x0,-0x118(%rbp)
movl   $0x0,-0x10c(%rbp)
cmpl   $0x100,-0x10c(%rbp)
jge    1164 <compute_something_fast+0x64>
mov    -0x10c(%rbp),%eax
mov    %al,%cl
movslq -0x10c(%rbp),%rax
mov    %cl,-0x100(%rbp,%rax,1)
mov    -0x10c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10c(%rbp)
jmp    112a <compute_something_fast+0x2a>
movb   $0x0,-0x101(%rbp)
movb   $0x0,-0x102(%rbp)
mov    -0x108(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x108(%rbp)
cmp    $0x0,%eax
je     123e <compute_something_fast+0x13e>
mov    -0x101(%rbp),%al
add    $0x1,%al
mov    %al,-0x101(%rbp)
movzbl -0x102(%rbp),%eax
movzbl -0x101(%rbp),%ecx
movzbl -0x100(%rbp,%rcx,1),%ecx
ff
add    %ecx,%eax
mov    %al,-0x102(%rbp)
movzbl -0x101(%rbp),%eax
mov    -0x100(%rbp,%rax,1),%al
mov    %al,-0x103(%rbp)
movzbl -0x102(%rbp),%eax
mov    -0x100(%rbp,%rax,1),%cl
movzbl -0x101(%rbp),%eax
mov    %cl,-0x100(%rbp,%rax,1)
mov    -0x103(%rbp),%cl
movzbl -0x102(%rbp),%eax
mov    %cl,-0x100(%rbp,%rax,1)
movzbl -0x101(%rbp),%eax
movzbl -0x100(%rbp,%rax,1),%eax
ff
movzbl -0x102(%rbp),%ecx
movzbl -0x100(%rbp,%rcx,1),%ecx
ff
add    %ecx,%eax
and    $0xff,%eax
cltq
movzbl -0x100(%rbp,%rax,1),%eax
ff
add    -0x118(%rbp),%rax
mov    %rax,-0x118(%rbp)
jmp    1172 <compute_something_fast+0x72>
mov    -0x118(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_something_fast>:
sub    $0x88,%rsp
movaps 0xef2(%rip),%xmm0
movaps %xmm0,-0x80(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,-0x70(%rsp)
movaps 0xefa(%rip),%xmm0
movaps %xmm0,-0x60(%rsp)
movaps 0xefe(%rip),%xmm0
movaps %xmm0,-0x50(%rsp)
movaps 0xf02(%rip),%xmm0
movaps %xmm0,-0x40(%rsp)
movaps 0xf06(%rip),%xmm0
movaps %xmm0,-0x30(%rsp)
movaps 0xf0a(%rip),%xmm0
movaps %xmm0,-0x20(%rsp)
movaps 0xf0e(%rip),%xmm0
movaps %xmm0,-0x10(%rsp)
movaps 0xf12(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xf17(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xf1b(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xf1f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xf23(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf27(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf2b(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xf2f(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
xor    %eax,%eax
mov    $0xfffffc18,%r9d
xor    %r8d,%r8d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x3e9(%r9),%esi
movzbl %r8b,%edx
movzbl %sil,%esi
movzbl -0x80(%rsp,%rsi,1),%edi
lea    (%rdi,%rdx,1),%r8
movzbl %r8b,%edx
movzbl -0x80(%rsp,%rdx,1),%ecx
mov    %cl,-0x80(%rsp,%rsi,1)
mov    %dil,-0x80(%rsp,%rdx,1)
movzbl -0x80(%rsp,%rsi,1),%ecx
add    %edi,%ecx
movzbl %cl,%ecx
movzbl -0x80(%rsp,%rcx,1),%ecx
add    %rcx,%rax
inc    %r9d
jne    11e0 <compute_something_fast+0xe0>
add    $0x88,%rsp
ret

LLVM IR (-O0):
define i64 @compute_something_fast() {
%1 = alloca [256 x i8]
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 1000, i32* %5
store i64 0, i64* %7
store i32 0, i32* %6
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %6
%13 = trunc i32 %12 to i8
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %15
store i8 %13, i8* %16
br label %17
17: ; preds = %11
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %8
20: ; preds = %8
store i8 0, i8* %2
store i8 0, i8* %3
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, -1
store i32 %23, i32* %5
%24 = icmp ne i32 %22, 0
br i1 %24, label %25, label %70
25: ; preds = %21
%26 = load i8, i8* %2
%27 = add i8 %26, 1
store i8 %27, i8* %2
%28 = load i8, i8* %3
%29 = zext i8 %28 to i32
%30 = load i8, i8* %2
%31 = zext i8 %30 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = add nsw i32 %29, %34
%36 = trunc i32 %35 to i8
store i8 %36, i8* %3
%37 = load i8, i8* %2
%38 = zext i8 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %38
%40 = load i8, i8* %39
store i8 %40, i8* %4
%41 = load i8, i8* %3
%42 = zext i8 %41 to i64
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = load i8, i8* %2
%46 = zext i8 %45 to i64
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %46
store i8 %44, i8* %47
%48 = load i8, i8* %4
%49 = load i8, i8* %3
%50 = zext i8 %49 to i64
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %50
store i8 %48, i8* %51
%52 = load i8, i8* %2
%53 = zext i8 %52 to i64
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = load i8, i8* %3
%58 = zext i8 %57 to i64
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = add nsw i32 %56, %61
%63 = and i32 %62, 255
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = zext i8 %66 to i64
%68 = load i64, i64* %7
%69 = add i64 %68, %67
store i64 %69, i64* %7
br label %21
70: ; preds = %21
%71 = load i64, i64* %7
ret i64 %71
}

LLVM IR (-O2):
define i64 @compute_something_fast() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = bitcast [256 x i8]* %1 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %3
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 16
%5 = bitcast i8* %4 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %5
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 32
%7 = bitcast i8* %6 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %7
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 48
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %9
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 64
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %11
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 80
%13 = bitcast i8* %12 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %13
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 96
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %15
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 112
%17 = bitcast i8* %16 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %17
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 128
%19 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %19
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 144
%21 = bitcast i8* %20 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %21
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 160
%23 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %23
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 176
%25 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %25
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 192
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %27
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 208
%29 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %29
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 224
%31 = bitcast i8* %30 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %31
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 240
%33 = bitcast i8* %32 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %33
br label %34
34: ; preds = %0, %34
%35 = phi i64 [ %59, %34 ], [ 0, %0 ]
%36 = phi i32 [ %39, %34 ], [ 1000, %0 ]
%37 = phi i8 [ %40, %34 ], [ 0, %0 ]
%38 = phi i32 [ %46, %34 ], [ 0, %0 ]
%39 = add nsw i32 %36, -1
%40 = add i8 %37, 1
%41 = and i32 %38, 255
%42 = zext i8 %40 to i64
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = add nuw nsw i32 %41, %45
%47 = and i32 %46, 255
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %48
%50 = load i8, i8* %49
store i8 %50, i8* %43
store i8 %44, i8* %49
%51 = load i8, i8* %43
%52 = zext i8 %51 to i32
%53 = add nuw nsw i32 %52, %45
%54 = and i32 %53, 255
%55 = zext i32 %54 to i64
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i64
%59 = add i64 %35, %58
%60 = icmp eq i32 %39, 0
br i1 %60, label %61, label %34
61: ; preds = %34
ret i64 %59
}