#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int main(int argc, char *argv[]) {
  int n;
  if (scanf("%d", &n) != 1) {
    return EXIT_FAILURE;
  }
  int nums[3] = {0};
  for (int i = 2; i >= 0; i--) {
    nums[i] = n % 10;
    n = n / 10;
  }
  for (int i = 0; i < nums[0]; i++) {
    printf("B");
  }
  for (int i = 0; i < nums[1]; i++) {
    printf("S");
  }
  for (int i = 0; i < nums[2]; i++) {
    printf("%d", i + 1);
  }
  return EXIT_SUCCESS;
}


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)
lea    0xeb3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     1170 <main+0x40>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    125f <main+0x12f>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movl   $0x2,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11c0 <main+0x90>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq -0x24(%rbp),%rax
mov    %edx,-0x20(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <main+0x57>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11ef <main+0xbf>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c7 <main+0x97>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    121e <main+0xee>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f6 <main+0xc6>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1253 <main+0x123>
mov    -0x30(%rbp),%esi
add    $0x1,%esi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1225 <main+0xf5>
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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>
cmp    $0x1,%eax
jne    1251 <main+0x121>
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
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
imul   $0x10624dd3,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
mov    %eax,0x4(%rsp)
test   %ebp,%ebp
jle    11ef <main+0xbf>
nopl   (%rax)
mov    $0x42,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0xb0>
sub    %r14d,%r15d
test   %ebx,%ebx
jle    120f <main+0xdf>
cs nopw 0x0(%rax,%rax,1)
mov    $0x53,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1200 <main+0xd0>
mov    0x2dc2(%rip),%rbp
test   %r15d,%r15d
jle    1258 <main+0x128>
neg    %r15d
mov    $0x1,%ebx
lea    0xdd6(%rip),%r14
nopw   0x0(%rax,%rax,1)
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    1230 <main+0x100>
jmp    1258 <main+0x128>
mov    0x2d88(%rip),%rbp
mov    0x0(%rbp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"B\00"
@.str.2 = [2 x i8] c"S\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [3 x i32]
%8 = alloca i32
%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 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %3
br label %69
16: ; preds = %2
%17 = bitcast [3 x i32]* %7 to i8*
store i32 2, i32* %8
br label %18
18: ; preds = %29, %16
%19 = load i32, i32* %8
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i32, i32* %6
%23 = srem i32 %22, 10
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 %25
store i32 %23, i32* %26
%27 = load i32, i32* %6
%28 = sdiv i32 %27, 10
store i32 %28, i32* %6
br label %29
29: ; preds = %21
%30 = load i32, i32* %8
%31 = add nsw i32 %30, -1
store i32 %31, i32* %8
br label %18
32: ; preds = %18
store i32 0, i32* %9
br label %33
33: ; preds = %40, %32
%34 = load i32, i32* %9
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%36 = load i32, i32* %35
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %33
43: ; preds = %33
store i32 0, i32* %10
br label %44
44: ; preds = %51, %43
%45 = load i32, i32* %10
%46 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 1
%47 = load i32, i32* %46
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %44
54: ; preds = %44
store i32 0, i32* %11
br label %55
55: ; preds = %64, %54
%56 = load i32, i32* %11
%57 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%58 = load i32, i32* %57
%59 = icmp slt i32 %56, %58
br i1 %59, label %60, label %67
60: ; preds = %55
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %60
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
store i32 %66, i32* %11
br label %55
67: ; preds = %55
%68 = load i32, i32* @EXIT_SUCCESS
store i32 %68, i32* %3
br label %69
69: ; preds = %67, %14
%70 = load i32, i32* %3
ret i32 %70
}

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