#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*/ sscanf(char const *, char *, ...);
scalar_t__ strcmp(char const *, char *);
void print_letter_line(const char *line) {
  int lines;
  const char *ptr;
  char current;
  int num_current;
  sscanf(line, "%dL", &lines);
  for (int i = 0; i < lines; i++) {
    ptr = line + 2;
    while (ptr && strcmp(ptr, "")) {
      sscanf(ptr++, "%d", &num_current);
      sscanf(ptr++, "%c", &current);
      for (int j = 0; j < num_current; j++) {
        if (current == 'B')
          printf(" ");
        else
          printf("X");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_letter_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    125c <print_letter_line+0x12c>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x29(%rbp)
je     119b <print_letter_line+0x6b>
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11ab <print_letter_line+0x7b>
jmp    1242 <print_letter_line+0x112>
mov    -0x18(%rbp),%rdi
mov    %rdi,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    0xe43(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%rdi
mov    %rdi,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    0xe25(%rip),%rsi
lea    -0x19(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    123d <print_letter_line+0x10d>
movsbl -0x19(%rbp),%eax
cmp    $0x42,%eax
jne    121e <print_letter_line+0xee>
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
jmp    122a <print_letter_line+0xfa>
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
jmp    122f <print_letter_line+0xff>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f4 <print_letter_line+0xc4>
jmp    1171 <print_letter_line+0x41>
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1159 <print_letter_line+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_letter_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rdi,0x18(%rsp)
xor    %eax,%eax
call   1050 <sscanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1241 <print_letter_line+0x111>
mov    0x18(%rsp),%rax
add    $0x2,%rax
mov    %rax,0x20(%rsp)
lea    0xe8d(%rip),%rbx
lea    0xb(%rsp),%r14
xor    %eax,%eax
jmp    119b <print_letter_line+0x6b>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x14(%rsp),%eax
add    $0x1,%eax
cmp    0x10(%rsp),%eax
jge    1241 <print_letter_line+0x111>
mov    %eax,0x14(%rsp)
mov    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
mov    0x18(%rsp),%r13
jmp    11cf <print_letter_line+0x9f>
cs nopw 0x0(%rax,%rax,1)
lea    0x2(%r13),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1180 <print_letter_line+0x50>
mov    %r13,%r12
mov    %r15,%r13
add    $0x3,%r12
mov    %r15,%rdi
lea    0xe1c(%rip),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
mov    %r12,%rdi
lea    0xe09(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c0 <print_letter_line+0x90>
xor    %ebp,%ebp
jmp    122e <print_letter_line+0xfe>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11c0 <print_letter_line+0x90>
cmpb   $0x42,0xb(%rsp)
mov    $0x20,%edi
je     1220 <print_letter_line+0xf0>
mov    $0x58,%edi
jmp    1220 <print_letter_line+0xf0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%dL\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"X\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @print_letter_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 (i8*, i8*, ...) @sscanf(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %7
br label %11
11: ; preds = %53, %1
%12 = load i32, i32* %7
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %56
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 2
store i8* %17, i8** %4
br label %18
18: ; preds = %50, %15
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br label %25
25: ; preds = %21, %18
%26 = phi i1 [ false, %18 ], [ %24, %21 ]
br i1 %26, label %27, label %51
27: ; preds = %25
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
%30 = call i32 (i8*, i8*, ...) @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
%33 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
store i32 0, i32* %8
br label %34
34: ; preds = %47, %27
%35 = load i32, i32* %8
%36 = load i32, i32* %6
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %50
38: ; preds = %34
%39 = load i8, i8* %5
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 66
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %46
44: ; preds = %38
%45 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %34
50: ; preds = %34
br label %18
51: ; preds = %25
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %53
53: ; preds = %51
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %11
56: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%dL\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%c\00"
define void @print_letter_line(i8* %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = getelementptr inbounds i8, i8* %0, i64 2
br label %12
12: ; preds = %10, %38
%13 = phi i32 [ 0, %10 ], [ %40, %38 ]
%14 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %38, label %21
16: ; preds = %38, %1
ret void
17: ; preds = %29, %21
%18 = getelementptr inbounds i8, i8* %22, i64 2
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %38, label %21
21: ; preds = %12, %17
%22 = phi i8* [ %18, %17 ], [ %11, %12 ]
%23 = phi i8* [ %22, %17 ], [ %0, %12 ]
%24 = getelementptr inbounds i8, i8* %23, i64 3
%25 = call i32 (i8*, i8*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%26 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %17
29: ; preds = %21, %29
%30 = phi i32 [ %35, %29 ], [ 0, %21 ]
%31 = load i8, i8* %3
%32 = icmp eq i8 %31, 66
%33 = select i1 %32, i32 32, i32 88
%34 = call i32 @putchar(i32 %33)
%35 = add nuw nsw i32 %30, 1
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %29, label %17
38: ; preds = %17, %12
%39 = call i32 @putchar(i32 10)
%40 = add nuw nsw i32 %13, 1
%41 = load i32, i32* %2
%42 = icmp slt i32 %40, %41
br i1 %42, label %12, label %16
}