unsigned decode_length(unsigned length) {
  unsigned hour, min, sec;
  unsigned len;
  hour = ((length >> 20) & 0xf) * 10;
  hour += ((length >> 16) & 0xf);
  min = ((length >> 12) & 0xf) * 10;
  min += ((length >> 8) & 0xf);
  sec = ((length >> 4) & 0xf) * 10;
  sec += ((length)&0xf);
  len = hour * 3600 + min * 60 + sec;
  return len;
}


x86 assembly (clang, -O0):
<decode_length>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x14,%eax
and    $0xf,%eax
imul   $0xa,%eax,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x10,%eax
and    $0xf,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shr    $0xc,%eax
and    $0xf,%eax
imul   $0xa,%eax,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
imul   $0xa,%eax,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0xe10,-0x8(%rbp),%eax
imul   $0x3c,-0xc(%rbp),%ecx
add    %ecx,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_length>:
mov    %edi,%eax
shr    $0x14,%eax
and    $0xf,%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%ecx
shr    $0x10,%ecx
and    $0xf,%ecx
lea    (%rcx,%rax,2),%eax
mov    %edi,%ecx
shr    $0xc,%ecx
and    $0xf,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %edi,%edx
shr    $0x8,%edx
and    $0xf,%edx
lea    (%rdx,%rcx,2),%ecx
mov    %edi,%edx
shr    $0x4,%edx
and    $0xf,%edx
lea    (%rdx,%rdx,4),%edx
and    $0xf,%edi
imul   $0xe10,%eax,%esi
imul   $0x3c,%ecx,%ecx
lea    (%rdi,%rdx,2),%eax
add    %ecx,%eax
add    %esi,%eax
ret

LLVM IR (-O0):
define i32 @decode_length(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = lshr i32 %7, 20
%9 = and i32 %8, 15
%10 = mul i32 %9, 10
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = lshr i32 %11, 16
%13 = and i32 %12, 15
%14 = load i32, i32* %3
%15 = add i32 %14, %13
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = lshr i32 %16, 12
%18 = and i32 %17, 15
%19 = mul i32 %18, 10
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = lshr i32 %20, 8
%22 = and i32 %21, 15
%23 = load i32, i32* %4
%24 = add i32 %23, %22
store i32 %24, i32* %4
%25 = load i32, i32* %2
%26 = lshr i32 %25, 4
%27 = and i32 %26, 15
%28 = mul i32 %27, 10
store i32 %28, i32* %5
%29 = load i32, i32* %2
%30 = and i32 %29, 15
%31 = load i32, i32* %5
%32 = add i32 %31, %30
store i32 %32, i32* %5
%33 = load i32, i32* %3
%34 = mul i32 %33, 3600
%35 = load i32, i32* %4
%36 = mul i32 %35, 60
%37 = add i32 %34, %36
%38 = load i32, i32* %5
%39 = add i32 %37, %38
store i32 %39, i32* %6
%40 = load i32, i32* %6
ret i32 %40
}

LLVM IR (-O2):
define i32 @decode_length(i32 %0) {
%2 = lshr i32 %0, 20
%3 = and i32 %2, 15
%4 = mul nuw nsw i32 %3, 10
%5 = lshr i32 %0, 16
%6 = and i32 %5, 15
%7 = add nuw nsw i32 %4, %6
%8 = lshr i32 %0, 12
%9 = and i32 %8, 15
%10 = mul nuw nsw i32 %9, 10
%11 = lshr i32 %0, 8
%12 = and i32 %11, 15
%13 = add nuw nsw i32 %10, %12
%14 = lshr i32 %0, 4
%15 = and i32 %14, 15
%16 = mul nuw nsw i32 %15, 10
%17 = and i32 %0, 15
%18 = mul nuw nsw i32 %7, 3600
%19 = mul nuw nsw i32 %13, 60
%20 = add nuw nsw i32 %16, %17
%21 = add nuw nsw i32 %20, %19
%22 = add nuw nsw i32 %21, %18
ret i32 %22
}