#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 /*<<< orphan*/ assert(int);
int first_2_of_4(int value) {
  assert(value >= 0);
  if (value >= 100000)
    return value / 10000;
  if (value >= 10000)
    return value / 1000;
  if (value >= 1000)
    return value / 100;
  if (value >= 100)
    return value / 10;
  return value;
}


x86 assembly (clang, -O0):
<first_2_of_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x186a0,-0x8(%rbp)
jl     114c <first_2_of_4+0x3c>
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11af <first_2_of_4+0x9f>
cmpl   $0x2710,-0x8(%rbp)
jl     116c <first_2_of_4+0x5c>
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11af <first_2_of_4+0x9f>
cmpl   $0x3e8,-0x8(%rbp)
jl     118c <first_2_of_4+0x7c>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11af <first_2_of_4+0x9f>
cmpl   $0x64,-0x8(%rbp)
jl     11a9 <first_2_of_4+0x99>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    11af <first_2_of_4+0x9f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_2_of_4>:
push   %rbx
mov    %edi,%ebx
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
cmp    $0x186a0,%ebx
jl     1136 <first_2_of_4+0x26>
mov    %ebx,%eax
mov    $0xd1b71759,%ebx
imul   %rax,%rbx
shr    $0x2d,%rbx
jmp    1177 <first_2_of_4+0x67>
cmp    $0x2710,%ebx
jl     114d <first_2_of_4+0x3d>
mov    %ebx,%eax
imul   $0x10624dd3,%rax,%rbx
shr    $0x26,%rbx
jmp    1177 <first_2_of_4+0x67>
cmp    $0x3e8,%ebx
jl     1166 <first_2_of_4+0x56>
movzwl %bx,%eax
shr    $0x2,%eax
imul   $0x147b,%eax,%ebx
shr    $0x11,%ebx
jmp    1177 <first_2_of_4+0x67>
cmp    $0x64,%ebx
jl     1177 <first_2_of_4+0x67>
movzwl %bx,%eax
imul   $0xcccd,%eax,%ebx
shr    $0x13,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @first_2_of_4(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32, i32* %3
%9 = icmp sge i32 %8, 100000
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 10000
store i32 %12, i32* %2
br label %33
13: ; preds = %1
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 10000
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 1000
store i32 %18, i32* %2
br label %33
19: ; preds = %13
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 1000
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 100
store i32 %24, i32* %2
br label %33
25: ; preds = %19
%26 = load i32, i32* %3
%27 = icmp sge i32 %26, 100
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %3
%30 = sdiv i32 %29, 10
store i32 %30, i32* %2
br label %33
31: ; preds = %25
%32 = load i32, i32* %3
store i32 %32, i32* %2
br label %33
33: ; preds = %31, %28, %22, %16, %10
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @first_2_of_4(i32 %0) {
%2 = xor i32 %0, -1
%3 = lshr i32 %2, 31
%4 = tail call i32 @assert(i32 %3)
%5 = icmp sgt i32 %0, 99999
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = udiv i32 %0, 10000
br label %24
8: ; preds = %1
%9 = icmp sgt i32 %0, 9999
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = udiv i32 %0, 1000
br label %24
12: ; preds = %8
%13 = icmp sgt i32 %0, 999
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = trunc i32 %0 to i16
%16 = udiv i16 %15, 100
%17 = zext i16 %16 to i32
br label %24
18: ; preds = %12
%19 = icmp sgt i32 %0, 99
br i1 %19, label %20, label %24
20: ; preds = %18
%21 = trunc i32 %0 to i16
%22 = udiv i16 %21, 10
%23 = zext i16 %22 to i32
br label %24
24: ; preds = %18, %20, %14, %10, %6
%25 = phi i32 [ %7, %6 ], [ %11, %10 ], [ %17, %14 ], [ %23, %20 ], [ %0, %18 ]
ret i32 %25
}