#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*/ EX_DATAERR;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, char const);
long spec2secs(const int d, const char c) {
  long new_duration = 0;
  switch (c) {
  case 's':
    new_duration = d;
    break;
  case 'm':
    new_duration = d * 60;
    break;
  case 'h':
    new_duration = d * 3600;
    break;
  case 'd':
    new_duration = d * 86400;
    break;
  case 'w':
    new_duration = d * 604800;
    break;
  default:
    err(EX_DATAERR,
        "unknown duration specification '%c', must be one of 'smhdw'", c);
  }
  return new_duration;
}


x86 assembly (clang, -O0):
<spec2secs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
movq   $0x0,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x13,%eax
ja     11a5 <spec2secs+0x95>
mov    -0x18(%rbp),%rax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11be <spec2secs+0xae>
imul   $0x3c,-0x4(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
jmp    11be <spec2secs+0xae>
imul   $0xe10,-0x4(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
jmp    11be <spec2secs+0xae>
imul   $0x15180,-0x4(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
jmp    11be <spec2secs+0xae>
imul   $0x93a80,-0x4(%rbp),%eax
cltq
mov    %rax,-0x10(%rbp)
jmp    11be <spec2secs+0xae>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
movsbl -0x5(%rbp),%edx
call   1030 <err@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spec2secs>:
push   %rax
lea    -0x64(%rsi),%eax
cmp    $0x13,%eax
ja     1131 <spec2secs+0x21>
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
imul   $0x15180,%edi,%eax
jmp    1166 <spec2secs+0x56>
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf0b(%rip),%rsi
call   1030 <err@plt>
xor    %eax,%eax
pop    %rcx
ret
imul   $0xe10,%edi,%eax
jmp    1166 <spec2secs+0x56>
imul   $0x3c,%edi,%eax
jmp    1166 <spec2secs+0x56>
movslq %edi,%rax
pop    %rcx
ret
imul   $0x93a80,%edi,%eax
cltq
pop    %rcx
ret

LLVM IR (-O0):
@EX_DATAERR = global i32 0
@.str = [60 x i8] c"unknown duration specification '%c', must be one of 'smhdw'\00"
define i64 @spec2secs(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i64
store i32 %0, i32* %3
store i8 %1, i8* %4
store i64 0, i64* %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %27 [
i32 115, label %8
i32 109, label %11
i32 104, label %15
i32 100, label %19
i32 119, label %23
]
8: ; preds = %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
store i64 %10, i64* %5
br label %31
11: ; preds = %2
%12 = load i32, i32* %3
%13 = mul nsw i32 %12, 60
%14 = sext i32 %13 to i64
store i64 %14, i64* %5
br label %31
15: ; preds = %2
%16 = load i32, i32* %3
%17 = mul nsw i32 %16, 3600
%18 = sext i32 %17 to i64
store i64 %18, i64* %5
br label %31
19: ; preds = %2
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 86400
%22 = sext i32 %21 to i64
store i64 %22, i64* %5
br label %31
23: ; preds = %2
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, 604800
%26 = sext i32 %25 to i64
store i64 %26, i64* %5
br label %31
27: ; preds = %2
%28 = load i32, i32* @EX_DATAERR
%29 = load i8, i8* %4
%30 = call i32 @err(i32 %28, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8 signext %29)
br label %31
31: ; preds = %27, %23, %19, %15, %11, %8
%32 = load i64, i64* %5
ret i64 %32
}

LLVM IR (-O2):
@EX_DATAERR = global i32 0
@.str = [60 x i8] c"unknown duration specification '%c', must be one of 'smhdw'\00"
define i64 @spec2secs(i32 %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %18 [
i32 115, label %4
i32 109, label %6
i32 104, label %9
i32 100, label %12
i32 119, label %15
]
4: ; preds = %2
%5 = sext i32 %0 to i64
br label %21
6: ; preds = %2
%7 = mul nsw i32 %0, 60
%8 = sext i32 %7 to i64
br label %21
9: ; preds = %2
%10 = mul nsw i32 %0, 3600
%11 = sext i32 %10 to i64
br label %21
12: ; preds = %2
%13 = mul nsw i32 %0, 86400
%14 = sext i32 %13 to i64
br label %21
15: ; preds = %2
%16 = mul nsw i32 %0, 604800
%17 = sext i32 %16 to i64
br label %21
18: ; preds = %2
%19 = load i32, i32* @EX_DATAERR
%20 = tail call i32 @err(i32 %19, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8 signext %1)
br label %21
21: ; preds = %18, %15, %12, %9, %6, %4
%22 = phi i64 [ 0, %18 ], [ %17, %15 ], [ %14, %12 ], [ %11, %9 ], [ %8, %6 ], [ %5, %4 ]
ret i64 %22
}