#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 atoi(char *);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
char *strtok(char *, char *);
int main(int argc, char const *argv[]) {
  char input[63], *data, output;
  int n, isREI = 1;
  scanf("%[^\n]", input);
  data = strtok(input, " ");
  while (data != NULL) {
    output = isREI ? 'A' : 'B';
    for (int i = 0; i < atoi(data); i++)
      printf("%c", output);
    isREI = isREI ? 0 : 1;
    data = strtok(NULL, " ");
  }
  puts("");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x64(%rbp)
lea    -0x50(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     121f <main+0xcf>
mov    -0x64(%rbp),%edx
mov    $0x42,%eax
mov    $0x41,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x59(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x58(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cmp    %ecx,%eax
jge    11f3 <main+0xa3>
lea    0xe2c(%rip),%rdi
movsbl -0x59(%rbp),%esi
call   1040 <printf@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11b9 <main+0x69>
mov    -0x64(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x64(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf5(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x58(%rbp)
jmp    1191 <main+0x41>
lea    0xde1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe9b(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11ec <main+0x9c>
mov    %rax,%r13
mov    $0x1,%r12d
lea    0xe74(%rip),%r14
lea    0xe6b(%rip),%r15
jmp    11b6 <main+0x66>
nopl   (%rax)
xor    $0x1,%r12d
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%r13
test   %rax,%rax
je     11ec <main+0x9c>
cmp    $0x1,%r12d
mov    $0x41,%bl
adc    $0x0,%bl
mov    %r13,%rdi
call   1070 <atoi@plt>
test   %eax,%eax
jle    11a0 <main+0x50>
xor    %ebp,%ebp
nopl   (%rax)
movsbl %bl,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
mov    %r13,%rdi
call   1070 <atoi@plt>
cmp    %eax,%ebp
jl     11d0 <main+0x80>
jmp    11a0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%[^\0A]\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [63 x i8]
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %10
%12 = getelementptr inbounds [63 x i8], [63 x i8]* %6, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [63 x i8], [63 x i8]* %6, i64 0, i64 0
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %7
br label %16
16: ; preds = %36, %2
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = load i32, i32* %10
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 65, i32 66
%24 = trunc i32 %23 to i8
store i8 %24, i8* %8
store i32 0, i32* %11
br label %25
25: ; preds = %33, %19
%26 = load i32, i32* %11
%27 = load i8*, i8** %7
%28 = call i32 @atoi(i8* %27)
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %36
30: ; preds = %25
%31 = load i8, i8* %8
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %31)
br label %33
33: ; preds = %30
%34 = load i32, i32* %11
%35 = add nsw i32 %34, 1
store i32 %35, i32* %11
br label %25
36: ; preds = %25
%37 = load i32, i32* %10
%38 = icmp ne i32 %37, 0
%39 = zext i1 %38 to i64
%40 = select i1 %38, i32 0, i32 1
store i32 %40, i32* %10
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %41, i8** %7
br label %16
42: ; preds = %16
%43 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%[^\0A]\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [63 x i8]
%4 = getelementptr inbounds [63 x i8], [63 x i8]* %3, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %25, label %8
8: ; preds = %2, %15
%9 = phi i32 [ %16, %15 ], [ 1, %2 ]
%10 = phi i8* [ %17, %15 ], [ %6, %2 ]
%11 = icmp eq i32 %9, 0
%12 = select i1 %11, i8 66, i8 65
%13 = call i32 @atoi(i8* %10)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %19, %8
%16 = xor i32 %9, 1
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %25, label %8
19: ; preds = %8, %19
%20 = phi i32 [ %22, %19 ], [ 0, %8 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %12)
%22 = add nuw nsw i32 %20, 1
%23 = call i32 @atoi(i8* %10)
%24 = icmp slt i32 %22, %23
br i1 %24, label %19, label %15
25: ; preds = %15, %2
%26 = call i32 @putchar(i32 10)
ret i32 0
}