unsigned char level2dims(unsigned char level, char **prefix, char **suffix) {
  unsigned int dims, base;
  base = 2;
  dims = (level > 0) ? base + 11 * (level - 1) : base + 11;
  if (dims > 210) {
    *prefix = "";
    *suffix = "+";
  } else {
    *prefix = "~";
    *suffix = "";
  }
  dims = ((210) < (dims) ? (210) : (dims));
  return (unsigned char)dims;
}


x86 assembly (clang, -O0):
<level2dims>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x2,-0x20(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jle    113d <level2dims+0x3d>
mov    -0x20(%rbp),%eax
movzbl -0x1(%rbp),%ecx
sub    $0x1,%ecx
imul   $0xb,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
jmp    1146 <level2dims+0x46>
mov    -0x20(%rbp),%eax
add    $0xb,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xd2,-0x1c(%rbp)
jbe    117a <level2dims+0x7a>
mov    -0x10(%rbp),%rax
lea    0xe9d(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
lea    0xe8e(%rip),%rcx
mov    %rcx,(%rax)
jmp    1196 <level2dims+0x96>
mov    -0x10(%rbp),%rax
lea    0xe7d(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
lea    0xe6e(%rip),%rcx
mov    %rcx,(%rax)
mov    $0xd2,%eax
cmp    -0x1c(%rbp),%eax
jae    11b1 <level2dims+0xb1>
mov    $0xd2,%eax
mov    %eax,-0x28(%rbp)
jmp    11b7 <level2dims+0xb7>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<level2dims>:
test   %edi,%edi
lea    (%rdi,%rdi,4),%eax
lea    -0x9(%rdi,%rax,2),%eax
mov    $0xd,%ecx
cmovne %eax,%ecx
cmp    $0xd3,%ecx
lea    0xee3(%rip),%r8
lea    0xedd(%rip),%rdi
cmovae %r8,%rdi
lea    0xed0(%rip),%rax
cmovb  %r8,%rax
mov    %rdi,(%rsi)
mov    %rax,(%rdx)
cmp    $0xd2,%ecx
mov    $0xd2,%eax
cmovb  %ecx,%eax
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"+\00"
@.str.2 = [2 x i8] c"~\00"
define zeroext i8 @level2dims(i8 zeroext %0, i8** %1, i8** %2) {
%4 = alloca i8
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i8 %0, i8* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 2, i32* %8
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* %8
%14 = load i8, i8* %4
%15 = zext i8 %14 to i32
%16 = sub nsw i32 %15, 1
%17 = mul nsw i32 11, %16
%18 = add i32 %13, %17
br label %22
19: ; preds = %3
%20 = load i32, i32* %8
%21 = add i32 %20, 11
br label %22
22: ; preds = %19, %12
%23 = phi i32 [ %18, %12 ], [ %21, %19 ]
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp ugt i32 %24, 210
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i8**, i8*** %5
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %27
%28 = load i8**, i8*** %6
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %28
br label %32
29: ; preds = %22
%30 = load i8**, i8*** %5
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = load i8**, i8*** %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %31
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %7
%34 = icmp ult i32 210, %33
br i1 %34, label %35, label %36
35: ; preds = %32
br label %38
36: ; preds = %32
%37 = load i32, i32* %7
br label %38
38: ; preds = %36, %35
%39 = phi i32 [ 210, %35 ], [ %37, %36 ]
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = trunc i32 %40 to i8
ret i8 %41
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"+\00"
@.str.2 = [2 x i8] c"~\00"
define zeroext i8 @level2dims(i8 zeroext %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = icmp eq i8 %0, 0
%5 = zext i8 %0 to i32
%6 = mul nuw nsw i32 %5, 11
%7 = add nsw i32 %6, -9
%8 = select i1 %4, i32 13, i32 %7
%9 = icmp ugt i32 %8, 210
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%11 = select i1 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
store i8* %10, i8** %1
store i8* %11, i8** %2
%12 = icmp ult i32 %8, 210
%13 = select i1 %12, i32 %8, i32 210
%14 = trunc i32 %13 to i8
ret i8 %14
}