#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 */
int /*<<< orphan*/ printf(char *, long);
int main(void) {
  int i, values[50000];
  for (i = 0; i < 50000; i++) {
    values[i] = i + 32;
  }
  long result = 0;
#pragma simd reduction(+ : result)
  for (i = 0; i < 50000; i++) {
    result += values[i] * 2;
  }
  printf("%ld\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30d60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xc350,-0x8(%rbp)
jge    1155 <main+0x45>
mov    -0x8(%rbp),%ecx
add    $0x20,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30d50(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <main+0x19>
movq   $0x0,-0x30d58(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xc350,-0x8(%rbp)
jge    11a0 <main+0x90>
movslq -0x8(%rbp),%rax
mov    -0x30d50(%rbp,%rax,4),%eax
shl    $0x1,%eax
cltq
add    -0x30d58(%rbp),%rax
mov    %rax,-0x30d58(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <main+0x57>
mov    -0x30d58(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30d60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x30d48,%rsp
movdqa 0xee1(%rip),%xmm0
mov    $0xc,%eax
movdqa 0xee4(%rip),%xmm1
movdqa 0xeec(%rip),%xmm2
movdqa 0xef4(%rip),%xmm3
movdqa 0xefc(%rip),%xmm4
movdqa 0xf04(%rip),%xmm5
nopl   0x0(%rax)
movdqa %xmm0,%xmm6
paddd  %xmm1,%xmm6
movdqa %xmm0,%xmm7
paddd  %xmm2,%xmm7
movdqa %xmm6,-0x30(%rsp,%rax,4)
movdqa %xmm7,-0x20(%rsp,%rax,4)
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
movdqa %xmm0,%xmm7
paddd  %xmm4,%xmm7
movdqa %xmm6,-0x10(%rsp,%rax,4)
movdqa %xmm7,(%rsp,%rax,4)
paddd  %xmm5,%xmm0
add    $0x10,%rax
cmp    $0xc35c,%rax
jne    1150 <main+0x40>
pxor   %xmm1,%xmm1
mov    $0x6,%eax
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movq   -0x18(%rsp,%rax,4),%xmm3
movq   -0x10(%rsp,%rax,4),%xmm2
paddd  %xmm3,%xmm3
paddd  %xmm2,%xmm2
pxor   %xmm4,%xmm4
pcmpgtd %xmm3,%xmm4
punpckldq %xmm4,%xmm3
paddq  %xmm1,%xmm3
pxor   %xmm1,%xmm1
pcmpgtd %xmm2,%xmm1
punpckldq %xmm1,%xmm2
paddq  %xmm0,%xmm2
movq   -0x8(%rsp,%rax,4),%xmm1
movq   (%rsp,%rax,4),%xmm0
paddd  %xmm1,%xmm1
paddd  %xmm0,%xmm0
pxor   %xmm4,%xmm4
pcmpgtd %xmm1,%xmm4
punpckldq %xmm4,%xmm1
paddq  %xmm3,%xmm1
pxor   %xmm3,%xmm3
pcmpgtd %xmm0,%xmm3
punpckldq %xmm3,%xmm0
paddq  %xmm2,%xmm0
add    $0x8,%rax
cmp    $0xc356,%rax
jne    11b0 <main+0xa0>
paddq  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddq  %xmm0,%xmm1
movq   %xmm1,%rsi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30d48,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50000 x i32]
%4 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 50000
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 32
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [50000 x i32], [50000 x i32]* %3, i64 0, i64 %12
store i32 %10, i32* %13
br label %14
14: ; preds = %8
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %5
17: ; preds = %5
store i64 0, i64* %4
store i32 0, i32* %2
br label %18
18: ; preds = %30, %17
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 50000
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50000 x i32], [50000 x i32]* %3, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = mul nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = load i64, i64* %4
%29 = add nsw i64 %28, %27
store i64 %29, i64* %4
br label %30
30: ; preds = %21
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %18
33: ; preds = %18
%34 = load i64, i64* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca [50000 x i32]
%2 = bitcast [50000 x i32]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %19, %3 ]
%5 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %20, %3 ]
%6 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %4
%7 = add <4 x i32> %5, <i32 32, i32 32, i32 32, i32 32>
%8 = add <4 x i32> %5, <i32 36, i32 36, i32 36, i32 36>
%9 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %6, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> %8, <4 x i32>* %11
%12 = or i64 %4, 8
%13 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %12
%14 = add <4 x i32> %5, <i32 40, i32 40, i32 40, i32 40>
%15 = add <4 x i32> %5, <i32 44, i32 44, i32 44, i32 44>
%16 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %13, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %18
%19 = add nuw nsw i64 %4, 16
%20 = add <4 x i32> %5, <i32 16, i32 16, i32 16, i32 16>
%21 = icmp eq i64 %19, 50000
br i1 %21, label %22, label %3
22: ; preds = %3, %22
%23 = phi i64 [ %51, %22 ], [ 0, %3 ]
%24 = phi <2 x i64> [ %49, %22 ], [ zeroinitializer, %3 ]
%25 = phi <2 x i64> [ %50, %22 ], [ zeroinitializer, %3 ]
%26 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %23
%27 = bitcast i32* %26 to <2 x i32>*
%28 = load <2 x i32>, <2 x i32>* %27
%29 = getelementptr inbounds i32, i32* %26, i64 2
%30 = bitcast i32* %29 to <2 x i32>*
%31 = load <2 x i32>, <2 x i32>* %30
%32 = shl nsw <2 x i32> %28, <i32 1, i32 1>
%33 = shl nsw <2 x i32> %31, <i32 1, i32 1>
%34 = sext <2 x i32> %32 to <2 x i64>
%35 = sext <2 x i32> %33 to <2 x i64>
%36 = add <2 x i64> %24, %34
%37 = add <2 x i64> %25, %35
%38 = or i64 %23, 4
%39 = getelementptr inbounds [50000 x i32], [50000 x i32]* %1, i64 0, i64 %38
%40 = bitcast i32* %39 to <2 x i32>*
%41 = load <2 x i32>, <2 x i32>* %40
%42 = getelementptr inbounds i32, i32* %39, i64 2
%43 = bitcast i32* %42 to <2 x i32>*
%44 = load <2 x i32>, <2 x i32>* %43
%45 = shl nsw <2 x i32> %41, <i32 1, i32 1>
%46 = shl nsw <2 x i32> %44, <i32 1, i32 1>
%47 = sext <2 x i32> %45 to <2 x i64>
%48 = sext <2 x i32> %46 to <2 x i64>
%49 = add <2 x i64> %36, %47
%50 = add <2 x i64> %37, %48
%51 = add nuw nsw i64 %23, 8
%52 = icmp eq i64 %51, 50000
br i1 %52, label %53, label %22
53: ; preds = %22
%54 = add <2 x i64> %50, %49
%55 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %54)
%56 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %55)
ret i32 0
}