#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*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char);
char *parseTime(char string[], unsigned short usTime, unsigned char buffer[]) {
  unsigned char hour = 0x00, min = 0x00, sec = 0x00;
  sec = 2 * (buffer[usTime] & 0x1f);
  hour = (buffer[usTime + 1] >> 3);
  min = (buffer[usTime + 1] & 0x07) << 3;
  min = min | ((buffer[usTime] & 0xd0) >> 5);
  sprintf(string, "%02i:%02i:%02i", hour, min, sec);
  return string;
}


x86 assembly (clang, -O0):
<parseTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movb   $0x0,-0x1a(%rbp)
movb   $0x0,-0x1b(%rbp)
mov    -0x18(%rbp),%rax
movzwl -0xa(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
and    $0x1f,%eax
shl    $0x1,%eax
mov    %al,-0x1b(%rbp)
mov    -0x18(%rbp),%rax
movzwl -0xa(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
sar    $0x3,%eax
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movzwl -0xa(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x7,%eax
shl    $0x3,%eax
mov    %al,-0x1a(%rbp)
movzbl -0x1a(%rbp),%eax
mov    -0x18(%rbp),%rcx
movzwl -0xa(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
and    $0xd0,%ecx
sar    $0x5,%ecx
or     %ecx,%eax
mov    %al,-0x1a(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x19(%rbp),%cl
mov    -0x1a(%rbp),%al
lea    0xe56(%rip),%rsi
movzbl %cl,%edx
movzbl %al,%ecx
movzbl -0x1b(%rbp),%r8d
call   1030 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseTime>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%eax
movzbl (%rdx,%rax,1),%ecx
mov    %ecx,%r8d
add    %ecx,%r8d
and    $0x3e,%r8d
mov    0x1(%rdx,%rax,1),%al
mov    %eax,%edx
shr    $0x3,%dl
shl    $0x3,%al
shr    $0x5,%cl
or     %al,%cl
and    $0x3e,%cl
movzbl %cl,%ecx
movzbl %dl,%edx
lea    0xebb(%rip),%rsi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%02i:%02i:%02i\00"
define i8* @parseTime(i8* %0, i16 zeroext %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i8* %0, i8** %4
store i16 %1, i16* %5
store i8* %2, i8** %6
store i8 0, i8* %7
store i8 0, i8* %8
store i8 0, i8* %9
%10 = load i8*, i8** %6
%11 = load i16, i16* %5
%12 = zext i16 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = and i32 %15, 31
%17 = mul nsw i32 2, %16
%18 = trunc i32 %17 to i8
store i8 %18, i8* %9
%19 = load i8*, i8** %6
%20 = load i16, i16* %5
%21 = zext i16 %20 to i32
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = ashr i32 %26, 3
%28 = trunc i32 %27 to i8
store i8 %28, i8* %7
%29 = load i8*, i8** %6
%30 = load i16, i16* %5
%31 = zext i16 %30 to i32
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = and i32 %36, 7
%38 = shl i32 %37, 3
%39 = trunc i32 %38 to i8
store i8 %39, i8* %8
%40 = load i8, i8* %8
%41 = zext i8 %40 to i32
%42 = load i8*, i8** %6
%43 = load i16, i16* %5
%44 = zext i16 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = and i32 %47, 208
%49 = ashr i32 %48, 5
%50 = or i32 %41, %49
%51 = trunc i32 %50 to i8
store i8 %51, i8* %8
%52 = load i8*, i8** %4
%53 = load i8, i8* %7
%54 = load i8, i8* %8
%55 = load i8, i8* %9
%56 = call i32 @sprintf(i8* %52, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8 zeroext %53, i8 zeroext %54, i8 zeroext %55)
%57 = load i8*, i8** %4
ret i8* %57
}

LLVM IR (-O2):
@.str = [15 x i8] c"%02i:%02i:%02i\00"
define i8* @parseTime(i8* returned writeonly %0, i16 zeroext %1, i8* nocapture %2) {
%4 = zext i16 %1 to i64
%5 = getelementptr inbounds i8, i8* %2, i64 %4
%6 = load i8, i8* %5
%7 = shl i8 %6, 1
%8 = and i8 %7, 62
%9 = add nuw nsw i64 %4, 1
%10 = getelementptr inbounds i8, i8* %2, i64 %9
%11 = load i8, i8* %10
%12 = lshr i8 %11, 3
%13 = shl i8 %11, 3
%14 = and i8 %13, 56
%15 = lshr i8 %6, 5
%16 = and i8 %15, 6
%17 = or i8 %14, %16
%18 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8 zeroext %12, i8 zeroext %17, i8 zeroext %8)
ret i8* %0
}