#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*/ scanf(char *, int *);
int main(void) {
  int input;
  int bai = 0;
  int shi = 0;
  int ge = 0;
  scanf("%d", &input);
  ge = input % 10;
  input /= 10;
  shi = input % 10;
  input /= 10;
  bai = input % 10;
  for (int i = 0; i < bai; i++) {
    printf("B");
  }
  for (int i = 0; i < shi; i++) {
    printf("S");
  }
  for (int i = 1; i <= ge; i++) {
    printf("%d", i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <main+0xa9>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a1 <main+0x81>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f8 <main+0xd8>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d0 <main+0xb0>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     122a <main+0x10a>
mov    -0x20(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ff <main+0xdf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
movslq 0x4(%rsp),%r15
imul   $0x66666667,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%r14d
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
imul   $0x51eb851f,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x4(%rsp)
movslq %eax,%rbp
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
test   %ebp,%ebp
jle    11cf <main+0x9f>
mov    $0x42,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11c0 <main+0x90>
sub    %r14d,%r15d
test   %ebx,%ebx
jle    11ef <main+0xbf>
cs nopw 0x0(%rax,%rax,1)
mov    $0x53,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0xb0>
test   %r15d,%r15d
jle    122f <main+0xff>
neg    %r15d
mov    $0x1,%ebx
lea    0xdfd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1210 <main+0xe0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"B\00"
@.str.2 = [2 x i8] c"S\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
store i32 %11, i32* %5
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 10
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = srem i32 %14, 10
store i32 %15, i32* %4
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 10
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = srem i32 %18, 10
store i32 %19, i32* %3
store i32 0, i32* %6
br label %20
20: ; preds = %26, %0
%21 = load i32, i32* %6
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %20
29: ; preds = %20
store i32 0, i32* %7
br label %30
30: ; preds = %36, %29
%31 = load i32, i32* %7
%32 = load i32, i32* %4
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %30
39: ; preds = %30
store i32 1, i32* %8
br label %40
40: ; preds = %47, %39
%41 = load i32, i32* %8
%42 = load i32, i32* %5
%43 = icmp sle i32 %41, %42
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = load i32, i32* %8
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %40
50: ; preds = %40
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = srem i32 %4, 10
%6 = sdiv i32 %4, 10
%7 = srem i32 %6, 10
%8 = sdiv i32 %4, 100
store i32 %8, i32* %1
%9 = srem i32 %8, 10
%10 = icmp sgt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %13, %0
%12 = icmp sgt i32 %7, 0
br i1 %12, label %20, label %18
13: ; preds = %0, %13
%14 = phi i32 [ %16, %13 ], [ 0, %0 ]
%15 = call i32 @putchar(i32 66)
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %9
br i1 %17, label %11, label %13
18: ; preds = %20, %11
%19 = icmp slt i32 %5, 1
br i1 %19, label %25, label %26
20: ; preds = %11, %20
%21 = phi i32 [ %23, %20 ], [ 0, %11 ]
%22 = call i32 @putchar(i32 83)
%23 = add nuw nsw i32 %21, 1
%24 = icmp eq i32 %23, %7
br i1 %24, label %18, label %20
25: ; preds = %26, %18
ret i32 0
26: ; preds = %18, %26
%27 = phi i32 [ %29, %26 ], [ 1, %18 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i32 %27, 1
%30 = icmp eq i32 %27, %5
br i1 %30, label %25, label %26
}