#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(void) {
  int i;
  int threshold = 19;
  char A[1024];
  char B[1024 * 2];
  for (i = 0; i < 1024; i++) {
    A[i] = i % 100;
  }
  for (i = 0; i < 1024 * 2; i++) {
    B[i] = 0;
  }
#pragma scop
  {
#pragma species kernel A[0 : SIZE - 1] | element->B[0 : 2 * SIZE - 1] |        \
                                                    chunk(0 : 1)
    for (i = 0; i < 1024; i++) {
      B[i * 2] = A[i];
      if (A[i] > threshold) {
        B[i * 2 + 1] = A[i];
      } else {
        B[i * 2 + 1] = 0;
      }
    }
#pragma species endkernel example04_k1
  }
#pragma endscop
  fflush(stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x13,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    1163 <main+0x53>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %dl,%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1130 <main+0x20>
movl   $0x0,-0x8(%rbp)
cmpl   $0x800,-0x8(%rbp)
jge    1191 <main+0x81>
movslq -0x8(%rbp),%rax
movb   $0x0,-0xc10(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x5a>
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    121c <main+0x10c>
movslq -0x8(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
cltq
mov    %cl,-0xc10(%rbp,%rax,1)
movslq -0x8(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    -0xc(%rbp),%eax
jle    11f6 <main+0xe6>
movslq -0x8(%rbp),%rax
mov    -0x410(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
mov    %cl,-0xc10(%rbp,%rax,1)
jmp    1209 <main+0xf9>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
movb   $0x0,-0xc10(%rbp,%rax,1)
jmp    120e <main+0xfe>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <main+0x88>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1030 <fflush@plt>
xor    %eax,%eax
add    $0xc10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ec8(%rip),%rax
mov    (%rax),%edi
call   1030 <fflush@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@stdout = global i32 0
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = tail call i32 @fflush(i32 %1)
ret i32 0
}