int set_pwr(int ndigits) {
  int pwr = 0x7fffffff;
  if (0 == ndigits)
    pwr = 1;
  if (1 == ndigits)
    pwr = 10;
  if (2 == ndigits)
    pwr = 100;
  if (3 == ndigits)
    pwr = 1000;
  if (4 == ndigits)
    pwr = 10000;
  if (5 == ndigits)
    pwr = 100000;
  if (6 == ndigits)
    pwr = 1000000;
  if (7 == ndigits)
    pwr = 10000000;
  if (8 == ndigits)
    pwr = 100000000;
  if (9 == ndigits)
    pwr = 1000000000;
  return pwr;
}


x86 assembly (clang, -O0):
<set_pwr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x7fffffff,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    1120 <set_pwr+0x20>
movl   $0x1,-0x8(%rbp)
mov    $0x1,%eax
cmp    -0x4(%rbp),%eax
jne    1135 <set_pwr+0x35>
movl   $0xa,-0x8(%rbp)
mov    $0x2,%eax
cmp    -0x4(%rbp),%eax
jne    114a <set_pwr+0x4a>
movl   $0x64,-0x8(%rbp)
mov    $0x3,%eax
cmp    -0x4(%rbp),%eax
jne    115f <set_pwr+0x5f>
movl   $0x3e8,-0x8(%rbp)
mov    $0x4,%eax
cmp    -0x4(%rbp),%eax
jne    1174 <set_pwr+0x74>
movl   $0x2710,-0x8(%rbp)
mov    $0x5,%eax
cmp    -0x4(%rbp),%eax
jne    1189 <set_pwr+0x89>
movl   $0x186a0,-0x8(%rbp)
mov    $0x6,%eax
cmp    -0x4(%rbp),%eax
jne    119e <set_pwr+0x9e>
movl   $0xf4240,-0x8(%rbp)
mov    $0x7,%eax
cmp    -0x4(%rbp),%eax
jne    11b3 <set_pwr+0xb3>
movl   $0x989680,-0x8(%rbp)
mov    $0x8,%eax
cmp    -0x4(%rbp),%eax
jne    11c8 <set_pwr+0xc8>
movl   $0x5f5e100,-0x8(%rbp)
mov    $0x9,%eax
cmp    -0x4(%rbp),%eax
jne    11dd <set_pwr+0xdd>
movl   $0x3b9aca00,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_pwr>:
test   %edi,%edi
mov    $0x1,%eax
mov    $0x7fffffff,%ecx
cmove  %eax,%ecx
cmp    $0x1,%edi
mov    $0xa,%eax
cmovne %ecx,%eax
cmp    $0x2,%edi
mov    $0x64,%ecx
cmovne %eax,%ecx
cmp    $0x3,%edi
mov    $0x3e8,%eax
cmovne %ecx,%eax
cmp    $0x4,%edi
mov    $0x2710,%ecx
cmovne %eax,%ecx
cmp    $0x5,%edi
mov    $0x186a0,%eax
cmovne %ecx,%eax
cmp    $0x6,%edi
mov    $0xf4240,%ecx
cmovne %eax,%ecx
cmp    $0x7,%edi
mov    $0x989680,%eax
cmovne %ecx,%eax
cmp    $0x8,%edi
mov    $0x5f5e100,%ecx
cmovne %eax,%ecx
cmp    $0x9,%edi
mov    $0x3b9aca00,%eax
cmovne %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @set_pwr(i32 %0) {
%2 = icmp eq i32 %0, 0
%3 = select i1 %2, i32 1, i32 2147483647
%4 = icmp eq i32 %0, 1
%5 = select i1 %4, i32 10, i32 %3
%6 = icmp eq i32 %0, 2
%7 = select i1 %6, i32 100, i32 %5
%8 = icmp eq i32 %0, 3
%9 = select i1 %8, i32 1000, i32 %7
%10 = icmp eq i32 %0, 4
%11 = select i1 %10, i32 10000, i32 %9
%12 = icmp eq i32 %0, 5
%13 = select i1 %12, i32 100000, i32 %11
%14 = icmp eq i32 %0, 6
%15 = select i1 %14, i32 1000000, i32 %13
%16 = icmp eq i32 %0, 7
%17 = select i1 %16, i32 10000000, i32 %15
%18 = icmp eq i32 %0, 8
%19 = select i1 %18, i32 100000000, i32 %17
%20 = icmp eq i32 %0, 9
%21 = select i1 %20, i32 1000000000, i32 %19
ret i32 %21
}