#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 hexCharToInt(char);
int /*<<< orphan*/ printf(char *, ...);
void hr20ParseTimer(char *timer) {
  int minutes = 0;
  printf("Mode:");
  if (timer[0] == '0')
    printf("frost protection  ");
  else if (timer[0] == '1')
    printf("energy save       ");
  else if (timer[0] == '2')
    printf("comfort           ");
  else if (timer[0] == '3')
    printf("supercomfort      ");
  minutes = 256 * hexCharToInt(timer[1]);
  minutes += 16 * hexCharToInt(timer[2]);
  minutes += hexCharToInt(timer[3]);
  printf("Time: %02d:%02d\n", minutes / 60, minutes % 60);
}


x86 assembly (clang, -O0):
<hr20ParseTimer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1164 <hr20ParseTimer+0x44>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d7 <hr20ParseTimer+0xb7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    1187 <hr20ParseTimer+0x67>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <hr20ParseTimer+0xb2>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
jne    11aa <hr20ParseTimer+0x8a>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <hr20ParseTimer+0xad>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x33,%eax
jne    11c8 <hr20ParseTimer+0xa8>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <hr20ParseTimer+0xad>
jmp    11d2 <hr20ParseTimer+0xb2>
jmp    11d7 <hr20ParseTimer+0xb7>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1040 <hexCharToInt@plt>
shl    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1040 <hexCharToInt@plt>
shl    $0x4,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1040 <hexCharToInt@plt>
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0xc(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hr20ParseTimer>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r14),%al
add    $0xd0,%al
cmp    $0x3,%al
ja     1157 <hr20ParseTimer+0x37>
movsbq %al,%rax
lea    0xf1b(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsbl 0x1(%r14),%edi
call   1040 <hexCharToInt@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
movsbl 0x2(%r14),%edi
call   1040 <hexCharToInt@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
add    %ebp,%ebx
movsbl 0x3(%r14),%edi
call   1040 <hexCharToInt@plt>
add    %ebx,%eax
movslq %eax,%rdx
imul   $0xffffffff88888889,%rdx,%rsi
shr    $0x20,%rsi
add    %edx,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x5,%esi
add    %eax,%esi
imul   $0x3c,%esi,%eax
sub    %eax,%edx
lea    0xea9(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"Mode:\00"
@.str.1 = [19 x i8] c"frost protection \00"
@.str.2 = [19 x i8] c"energy save \00"
@.str.3 = [19 x i8] c"comfort \00"
@.str.4 = [19 x i8] c"supercomfort \00"
@.str.5 = [17 x i8] c"Time: %02d:%02d\0A\00"
define void @hr20ParseTimer(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 48
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %39
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 49
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %38
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 50
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %37
28: ; preds = %20
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 51
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %28
br label %37
37: ; preds = %36, %26
br label %38
38: ; preds = %37, %18
br label %39
39: ; preds = %38, %10
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = call i32 @hexCharToInt(i8 signext %42)
%44 = mul nsw i32 256, %43
store i32 %44, i32* %3
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i64 2
%47 = load i8, i8* %46
%48 = call i32 @hexCharToInt(i8 signext %47)
%49 = mul nsw i32 16, %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, %49
store i32 %51, i32* %3
%52 = load i8*, i8** %2
%53 = getelementptr inbounds i8, i8* %52, i64 3
%54 = load i8, i8* %53
%55 = call i32 @hexCharToInt(i8 signext %54)
%56 = load i32, i32* %3
%57 = add nsw i32 %56, %55
store i32 %57, i32* %3
%58 = load i32, i32* %3
%59 = sdiv i32 %58, 60
%60 = load i32, i32* %3
%61 = srem i32 %60, 60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %59, i32 %61)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"Mode:\00"
@.str.1 = [19 x i8] c"frost protection \00"
@.str.2 = [19 x i8] c"energy save \00"
@.str.3 = [19 x i8] c"comfort \00"
@.str.4 = [19 x i8] c"supercomfort \00"
@.str.5 = [17 x i8] c"Time: %02d:%02d\0A\00"
@reltable.hr20ParseTimer = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.hr20ParseTimer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.hr20ParseTimer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.hr20ParseTimer to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.hr20ParseTimer to i64)) to i32)]
define void @hr20ParseTimer(i8* nocapture %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = load i8, i8* %0
%4 = add i8 %3, -48
%5 = icmp ult i8 %4, 4
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = sext i8 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.hr20ParseTimer to i8*), i64 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %9)
br label %11
11: ; preds = %1, %6
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = tail call i32 @hexCharToInt(i8 signext %13)
%15 = shl nsw i32 %14, 8
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = load i8, i8* %16
%18 = tail call i32 @hexCharToInt(i8 signext %17)
%19 = shl nsw i32 %18, 4
%20 = add nsw i32 %19, %15
%21 = getelementptr inbounds i8, i8* %0, i64 3
%22 = load i8, i8* %21
%23 = tail call i32 @hexCharToInt(i8 signext %22)
%24 = add nsw i32 %20, %23
%25 = sdiv i32 %24, 60
%26 = srem i32 %24, 60
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %25, i32 %26)
ret void
}