void get_limits(int N, int *count_out, int *start_at_out) {
  int count = 0;
  int start_at = 0;
  if (N >= 100) {
    count += 20;
    start_at = 100;
  }
  if (N >= 1000) {
    count += 5 * 20;
    start_at = 1000;
  }
  if (N >= 10000) {
    count += 20 * 30;
    start_at = 10000;
  }
  if (N >= 100000) {
    start_at = 100000;
  }
  if (N >= 1000000) {
    count += 20 * 30 * 30;
    start_at = 1000000;
  }
  if (N >= 10000000) {
    count += 5 * 20 * 20 * 25;
    start_at = 10000000;
  }
  if (N >= 100000000) {
    count += 20 * 30 * 30 * 30;
    start_at = 100000000;
  }
  if (N >= 1000000000) {
    start_at = 1000000000;
  }
  *count_out = count;
  *start_at_out = start_at;
}


x86 assembly (clang, -O0):
<get_limits>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x64,-0x4(%rbp)
jl     1137 <get_limits+0x37>
mov    -0x1c(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x64,-0x20(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jl     1154 <get_limits+0x54>
mov    -0x1c(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x3e8,-0x20(%rbp)
cmpl   $0x2710,-0x4(%rbp)
jl     1173 <get_limits+0x73>
mov    -0x1c(%rbp),%eax
add    $0x258,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x2710,-0x20(%rbp)
cmpl   $0x186a0,-0x4(%rbp)
jl     1187 <get_limits+0x87>
movl   $0x186a0,-0x20(%rbp)
cmpl   $0xf4240,-0x4(%rbp)
jl     11a6 <get_limits+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x4650,%eax
mov    %eax,-0x1c(%rbp)
movl   $0xf4240,-0x20(%rbp)
cmpl   $0x989680,-0x4(%rbp)
jl     11c5 <get_limits+0xc5>
mov    -0x1c(%rbp),%eax
add    $0xc350,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x989680,-0x20(%rbp)
cmpl   $0x5f5e100,-0x4(%rbp)
jl     11e4 <get_limits+0xe4>
mov    -0x1c(%rbp),%eax
add    $0x83d60,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x5f5e100,-0x20(%rbp)
cmpl   $0x3b9aca00,-0x4(%rbp)
jl     11f8 <get_limits+0xf8>
movl   $0x3b9aca00,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_limits>:
xor    %r8d,%r8d
cmp    $0x64,%edi
mov    $0x14,%ecx
cmovl  %r8d,%ecx
mov    $0x64,%r9d
cmovl  %r8d,%r9d
lea    0x64(%rcx),%eax
cmp    $0x3e8,%edi
cmovl  %ecx,%eax
mov    $0x3e8,%r8d
cmovl  %r9d,%r8d
lea    0x258(%rax),%ecx
cmp    $0x2710,%edi
cmovl  %eax,%ecx
mov    $0x2710,%eax
cmovl  %r8d,%eax
cmp    $0x186a0,%edi
mov    $0x186a0,%r8d
cmovl  %eax,%r8d
lea    0x4650(%rcx),%eax
cmp    $0xf4240,%edi
cmovl  %ecx,%eax
mov    $0xf4240,%r9d
cmovl  %r8d,%r9d
lea    0xc350(%rax),%ecx
cmp    $0x989680,%edi
cmovl  %eax,%ecx
mov    $0x989680,%eax
cmovl  %r9d,%eax
lea    0x83d60(%rcx),%r8d
cmp    $0x5f5e100,%edi
cmovl  %ecx,%r8d
mov    $0x5f5e100,%ecx
cmovl  %eax,%ecx
cmp    $0x3b9aca00,%edi
mov    $0x3b9aca00,%eax
cmovl  %ecx,%eax
mov    %r8d,(%rsi)
mov    %eax,(%rdx)
ret

LLVM IR (-O0):
define void @get_limits(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 100
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32, i32* %7
%13 = add nsw i32 %12, 20
store i32 %13, i32* %7
store i32 100, i32* %8
br label %14
14: ; preds = %11, %3
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 1000
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 100
store i32 %19, i32* %7
store i32 1000, i32* %8
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %4
%22 = icmp sge i32 %21, 10000
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 600
store i32 %25, i32* %7
store i32 10000, i32* %8
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %4
%28 = icmp sge i32 %27, 100000
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 100000, i32* %8
br label %30
30: ; preds = %29, %26
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 1000000
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 18000
store i32 %35, i32* %7
store i32 1000000, i32* %8
br label %36
36: ; preds = %33, %30
%37 = load i32, i32* %4
%38 = icmp sge i32 %37, 10000000
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 50000
store i32 %41, i32* %7
store i32 10000000, i32* %8
br label %42
42: ; preds = %39, %36
%43 = load i32, i32* %4
%44 = icmp sge i32 %43, 100000000
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 540000
store i32 %47, i32* %7
store i32 100000000, i32* %8
br label %48
48: ; preds = %45, %42
%49 = load i32, i32* %4
%50 = icmp sge i32 %49, 1000000000
br i1 %50, label %51, label %52
51: ; preds = %48
store i32 1000000000, i32* %8
br label %52
52: ; preds = %51, %48
%53 = load i32, i32* %7
%54 = load i32*, i32** %5
store i32 %53, i32* %54
%55 = load i32, i32* %8
%56 = load i32*, i32** %6
store i32 %55, i32* %56
ret void
}

LLVM IR (-O2):
define void @get_limits(i32 %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = icmp sgt i32 %0, 99
%5 = select i1 %4, i32 20, i32 0
%6 = select i1 %4, i32 100, i32 0
%7 = icmp sgt i32 %0, 999
%8 = add nuw nsw i32 %5, 100
%9 = select i1 %7, i32 %8, i32 %5
%10 = select i1 %7, i32 1000, i32 %6
%11 = icmp sgt i32 %0, 9999
%12 = add nuw nsw i32 %9, 600
%13 = select i1 %11, i32 %12, i32 %9
%14 = select i1 %11, i32 10000, i32 %10
%15 = icmp slt i32 %0, 100000
%16 = select i1 %15, i32 %14, i32 100000
%17 = icmp sgt i32 %0, 999999
%18 = add nuw nsw i32 %13, 18000
%19 = select i1 %17, i32 %18, i32 %13
%20 = select i1 %17, i32 1000000, i32 %16
%21 = icmp sgt i32 %0, 9999999
%22 = add nuw nsw i32 %19, 50000
%23 = select i1 %21, i32 %22, i32 %19
%24 = select i1 %21, i32 10000000, i32 %20
%25 = icmp sgt i32 %0, 99999999
%26 = add nuw nsw i32 %23, 540000
%27 = select i1 %25, i32 %26, i32 %23
%28 = select i1 %25, i32 100000000, i32 %24
%29 = icmp slt i32 %0, 1000000000
%30 = select i1 %29, i32 %28, i32 1000000000
store i32 %27, i32* %1
store i32 %30, i32* %2
ret void
}