int numPlaces(int n) {
  if (n < 10)
    return 1;
  if (n < 100)
    return 2;
  if (n < 1000)
    return 3;
  if (n < 10000)
    return 4;
  if (n < 100000)
    return 5;
  if (n < 1000000)
    return 6;
  if (n < 10000000)
    return 7;
  if (n < 100000000)
    return 8;
  if (n < 1000000000)
    return 9;
  return 10;
}


x86 assembly (clang, -O0):
<numPlaces>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    111d <numPlaces+0x1d>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x64,-0x8(%rbp)
jge    1133 <numPlaces+0x33>
movl   $0x2,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x3e8,-0x8(%rbp)
jge    114c <numPlaces+0x4c>
movl   $0x3,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x2710,-0x8(%rbp)
jge    1165 <numPlaces+0x65>
movl   $0x4,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x186a0,-0x8(%rbp)
jge    117e <numPlaces+0x7e>
movl   $0x5,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0xf4240,-0x8(%rbp)
jge    1197 <numPlaces+0x97>
movl   $0x6,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x989680,-0x8(%rbp)
jge    11b0 <numPlaces+0xb0>
movl   $0x7,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x5f5e100,-0x8(%rbp)
jge    11c9 <numPlaces+0xc9>
movl   $0x8,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
cmpl   $0x3b9aca00,-0x8(%rbp)
jge    11e2 <numPlaces+0xe2>
movl   $0x9,-0x4(%rbp)
jmp    11e9 <numPlaces+0xe9>
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<numPlaces>:
mov    $0x1,%eax
cmp    $0xa,%edi
jl     1170 <numPlaces+0x70>
mov    $0x2,%eax
cmp    $0x64,%edi
jb     1170 <numPlaces+0x70>
mov    $0x3,%eax
cmp    $0x3e8,%edi
jb     1170 <numPlaces+0x70>
mov    $0x4,%eax
cmp    $0x2710,%edi
jb     1170 <numPlaces+0x70>
mov    $0x5,%eax
cmp    $0x186a0,%edi
jb     1170 <numPlaces+0x70>
mov    $0x6,%eax
cmp    $0xf4240,%edi
jb     1170 <numPlaces+0x70>
mov    $0x7,%eax
cmp    $0x989680,%edi
jb     1170 <numPlaces+0x70>
mov    $0x8,%eax
cmp    $0x5f5e100,%edi
jb     1170 <numPlaces+0x70>
cmp    $0x3b9aca00,%edi
mov    $0xa,%eax
sbb    $0x0,%eax
ret

LLVM IR (-O0):
define i32 @numPlaces(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %40
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* %2
br label %40
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 3, i32* %2
br label %40
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 10000
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 4, i32* %2
br label %40
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 100000
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 5, i32* %2
br label %40
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 1000000
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 6, i32* %2
br label %40
27: ; preds = %23
%28 = load i32, i32* %3
%29 = icmp slt i32 %28, 10000000
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 7, i32* %2
br label %40
31: ; preds = %27
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 100000000
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 8, i32* %2
br label %40
35: ; preds = %31
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 1000000000
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 9, i32* %2
br label %40
39: ; preds = %35
store i32 10, i32* %2
br label %40
40: ; preds = %39, %38, %34, %30, %26, %22, %18, %14, %10, %6
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @numPlaces(i32 %0) {
%2 = icmp slt i32 %0, 10
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 100
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 1000
br i1 %6, label %20, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 10000
br i1 %8, label %20, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 100000
br i1 %10, label %20, label %11
11: ; preds = %9
%12 = icmp ult i32 %0, 1000000
br i1 %12, label %20, label %13
13: ; preds = %11
%14 = icmp ult i32 %0, 10000000
br i1 %14, label %20, label %15
15: ; preds = %13
%16 = icmp ult i32 %0, 100000000
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = icmp ult i32 %0, 1000000000
%19 = select i1 %18, i32 9, i32 10
br label %20
20: ; preds = %17, %15, %13, %11, %9, %7, %5, %3, %1
%21 = phi i32 [ 1, %1 ], [ 2, %3 ], [ 3, %5 ], [ 4, %7 ], [ 5, %9 ], [ 6, %11 ], [ 7, %13 ], [ 8, %15 ], [ %19, %17 ]
ret i32 %21
}