#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*/ die(char *, char *);
int strtol(char *, char **, int /*<<< orphan*/);
int timer_number(char *num) {
  int number;
  char *end;
  number = strtol(num, &end, 0);
  if (end && *end) {
    switch (*end) {
    case 'h':
    case 'H':
      number *= 60;
    case 'm':
    case 'M':
      number *= 60;
    case 's':
    case 'S':
      number *= 10;
    case 't':
    case 'T':
      break;
    default:
      number = -1;
    }
  }
  if (number < 0 || number > 36000)
    die("Not a valid timer value: \"%s\"", num);
  return number;
}


x86 assembly (clang, -O0):
<timer_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    %eax,-0xc(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ac <timer_number+0x8c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ac <timer_number+0x8c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffb8,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x2c,%eax
ja     11a0 <timer_number+0x80>
mov    -0x20(%rbp),%rax
lea    0xe83(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
imul   $0x3c,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
imul   $0x3c,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11a7 <timer_number+0x87>
movl   $0xffffffff,-0xc(%rbp)
jmp    11ac <timer_number+0x8c>
cmpl   $0x0,-0xc(%rbp)
jl     11c3 <timer_number+0xa3>
cmpl   $0x8ca0,-0xc(%rbp)
jle    11d3 <timer_number+0xb3>
mov    -0x8(%rbp),%rsi
lea    0xee6(%rip),%rdi
call   1040 <die@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timer_number>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <strtol@plt>
mov    (%rsp),%rcx
test   %rcx,%rcx
je     1168 <timer_number+0x48>
movsbl (%rcx),%ecx
test   %ecx,%ecx
je     1168 <timer_number+0x48>
mov    $0xffffffff,%ebp
add    $0xffffffb8,%ecx
cmp    $0x2c,%ecx
ja     1171 <timer_number+0x51>
lea    0xeac(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
imul   $0x3c,%eax,%eax
imul   $0x3c,%eax,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,%ebp
cmp    $0x8ca1,%eax
jb     1182 <timer_number+0x62>
lea    0xf3c(%rip),%rdi
mov    %rbx,%rsi
call   1040 <die@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Not a valid timer value: \22%s\22\00"
define i32 @timer_number(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strtol(i8* %5, i8** %4, i32 0)
store i32 %6, i32* %3
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %30
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %9
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %28 [
i32 104, label %18
i32 72, label %18
i32 109, label %21
i32 77, label %21
i32 115, label %24
i32 83, label %24
i32 116, label %27
i32 84, label %27
]
18: ; preds = %14, %14
%19 = load i32, i32* %3
%20 = mul nsw i32 %19, 60
store i32 %20, i32* %3
br label %21
21: ; preds = %14, %14, %18
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, 60
store i32 %23, i32* %3
br label %24
24: ; preds = %14, %14, %21
%25 = load i32, i32* %3
%26 = mul nsw i32 %25, 10
store i32 %26, i32* %3
br label %27
27: ; preds = %14, %14, %24
br label %29
28: ; preds = %14
store i32 -1, i32* %3
br label %29
29: ; preds = %28, %27
br label %30
30: ; preds = %29, %9, %1
%31 = load i32, i32* %3
%32 = icmp slt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %3
%35 = icmp sgt i32 %34, 36000
br i1 %35, label %36, label %39
36: ; preds = %33, %30
%37 = load i8*, i8** %2
%38 = call i32 @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [30 x i8] c"Not a valid timer value: \22%s\22\00"
define i32 @timer_number(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i32 @strtol(i8* %0, i8** %2, i32 0)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %20, label %7
7: ; preds = %1
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = sext i8 %8 to i32
switch i32 %11, label %23 [
i32 104, label %12
i32 72, label %12
i32 109, label %14
i32 77, label %14
i32 115, label %17
i32 83, label %17
i32 116, label %20
i32 84, label %20
]
12: ; preds = %10, %10
%13 = mul nsw i32 %4, 60
br label %14
14: ; preds = %10, %10, %12
%15 = phi i32 [ %4, %10 ], [ %4, %10 ], [ %13, %12 ]
%16 = mul nsw i32 %15, 60
br label %17
17: ; preds = %10, %10, %14
%18 = phi i32 [ %4, %10 ], [ %4, %10 ], [ %16, %14 ]
%19 = mul nsw i32 %18, 10
br label %20
20: ; preds = %10, %10, %17, %7, %1
%21 = phi i32 [ %4, %10 ], [ %4, %10 ], [ %19, %17 ], [ %4, %7 ], [ %4, %1 ]
%22 = icmp ugt i32 %21, 36000
br i1 %22, label %23, label %26
23: ; preds = %10, %20
%24 = phi i32 [ %21, %20 ], [ -1, %10 ]
%25 = tail call i32 @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %26
26: ; preds = %20, %23
%27 = phi i32 [ %21, %20 ], [ %24, %23 ]
ret i32 %27
}