#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 dolls[10] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};
  char input[5], *count;
  int start = 0, end;
  scanf("%[^\n]", input);
  count = strtok(input, " ");
  while (count != NULL) {
    end = start + atoi(count);
    for (int i = start; i < end; i++)
      printf("%c", dolls[i]);
    puts("");
    start = end;
    count = strtok(NULL, " ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xe90(%rip),%ax
mov    %ax,-0x12(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x1f(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x1f(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     122b <main+0xdb>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1200 <main+0xb0>
movslq -0x34(%rbp),%rax
lea    0xe2a(%rip),%rdi
movsbl -0x1a(%rbp,%rax,1),%esi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d1 <main+0x81>
lea    0xe0a(%rip),%rdi
call   1030 <puts@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf3(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    11a7 <main+0x57>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xea8(%rip),%rdi
lea    0x3(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11f9 <main+0xa9>
xor    %ebp,%ebp
lea    0xe74(%rip),%r15
lea    0xe7f(%rip),%r13
lea    0xe76(%rip),%r14
jmp    11bc <main+0x6c>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1060 <strtok@plt>
mov    %r12d,%ebp
test   %rax,%rax
je     11f9 <main+0xa9>
mov    %rax,%rdi
call   1070 <atoi@plt>
lea    (%rax,%rbp,1),%r12d
test   %eax,%eax
jle    11a0 <main+0x50>
movslq %ebp,%rbp
movslq %r12d,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl 0x0(%rbp,%r15,1),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
jl     11e0 <main+0x90>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.dolls = [10 x i8] c"ABCDEFGHIJ"
@.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 [10 x i8]
%7 = alloca [5 x 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
%12 = bitcast [10 x i8]* %6 to i8*
store i32 0, i32* %9
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %8
br label %17
17: ; preds = %39, %2
%18 = load i8*, i8** %8
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %43
20: ; preds = %17
%21 = load i32, i32* %9
%22 = load i8*, i8** %8
%23 = call i32 @atoi(i8* %22)
%24 = add nsw i32 %21, %23
store i32 %24, i32* %10
%25 = load i32, i32* %9
store i32 %25, i32* %11
br label %26
26: ; preds = %36, %20
%27 = load i32, i32* %11
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %39
30: ; preds = %26
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %26
39: ; preds = %26
%40 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* %10
store i32 %41, i32* %9
%42 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %42, i8** %8
br label %17
43: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@__const.main.dolls = [10 x i8] c"ABCDEFGHIJ"
@.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 [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 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 %28, label %8
8: ; preds = %2, %17
%9 = phi i8* [ %19, %17 ], [ %6, %2 ]
%10 = phi i32 [ %12, %17 ], [ 0, %2 ]
%11 = call i32 @atoi(i8* %9)
%12 = add nsw i32 %11, %10
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = sext i32 %10 to i64
%16 = sext i32 %12 to i64
br label %21
17: ; preds = %21, %8
%18 = call i32 @putchar(i32 10)
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %28, label %8
21: ; preds = %14, %21
%22 = phi i64 [ %15, %14 ], [ %26, %21 ]
%23 = getelementptr inbounds [10 x i8], [10 x i8]* @__const.main.dolls, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %24)
%26 = add nsw i64 %22, 1
%27 = icmp slt i64 %26, %16
br i1 %27, label %21, label %17
28: ; preds = %17, %2
ret i32 0
}