#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 *, ...);
int /*<<< orphan*/ sortFlag(char *, int);
int main(int argc, const char *argv[]) {
  char a[15] = {'R', 'B', 'W', 'W', 'B', 'B', 'R', 'W',
                'W', 'R', 'R', 'W', 'R', 'B', 'W'};
  sortFlag(a, 15);
  for (int i = 0; i < 15; i++) {
    printf("%c ", a[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x1f(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xebb(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xeb3(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x1f(%rbp),%rdi
mov    $0xf,%esi
call   1040 <sortFlag@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0xf,-0x24(%rbp)
jge    11a2 <main+0x82>
movslq -0x24(%rbp),%rax
movsbl -0x1f(%rbp,%rax,1),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1173 <main+0x53>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x5742525752525757,%rax
52 42 57
mov    %rax,0x7(%rsp)
movabs $0x5752424257574252,%rax
42 52 57
mov    %rax,(%rsp)
mov    %rsp,%rdi
mov    $0xf,%esi
call   1050 <sortFlag@plt>
movsbl (%rsp),%esi
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x1(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x2(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x3(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x5(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x6(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x7(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x9(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xa(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xb(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xd(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xe(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.a = [15 x i8] c"RBWWBBRWWRRWRBW"
@.str = [4 x i8] c"%c \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [15 x i8]
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%5 = call i32 @sortFlag(i8* %4, i32 15)
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 6
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 7
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 8
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 9
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 10
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 11
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 12
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 13
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 14
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = call i32 @putchar(i32 10)
ret i32 0
}