#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char GetCompositionSymbol(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
void WriteSymbols(FILE *fp, int *indices, int length) {
  int i, index;
  char symbol;
  for (i = 0; i < length; i++) {
    index = indices[i];
    if (index > 1000 || index < 0)
      index = -1;
    symbol = GetCompositionSymbol(index);
    fprintf(fp, "%c", symbol);
  }
  return;
}


x86 assembly (clang, -O0):
<WriteSymbols>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    119f <WriteSymbols+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jg     116b <WriteSymbols+0x4b>
cmpl   $0x0,-0x1c(%rbp)
jge    1172 <WriteSymbols+0x52>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <GetCompositionSymbol@plt>
mov    %al,-0x1d(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
movsbl -0x1d(%rbp),%edx
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <WriteSymbols+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteSymbols>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    1166 <WriteSymbols+0x46>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
mov    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    (%r14,%rbx,4),%edi
cmp    $0x3e9,%edi
cmovae %ebp,%edi
call   1040 <GetCompositionSymbol@plt>
movsbl %al,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <WriteSymbols+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @WriteSymbols(i32* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %16, %7 ]
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = load i32, i32* %9
%11 = icmp ugt i32 %10, 1000
%12 = select i1 %11, i32 -1, i32 %10
%13 = tail call signext i8 @GetCompositionSymbol(i32 %12)
%14 = sext i8 %13 to i32
%15 = tail call i32 @fputc(i32 %14, i32* %0)
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %7, %3
ret void
}