#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);
int spec2secs(int d, char c) {
  int 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)
movl   $0x0,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x13,%eax
ja     1196 <spec2secs+0x86>
mov    -0x18(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11af <spec2secs+0x9f>
imul   $0x3c,-0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11af <spec2secs+0x9f>
imul   $0xe10,-0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11af <spec2secs+0x9f>
imul   $0x15180,-0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11af <spec2secs+0x9f>
imul   $0x93a80,-0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11af <spec2secs+0x9f>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
movsbl -0x5(%rbp),%edx
call   1030 <err@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spec2secs>:
push   %rax
lea    -0x64(%rsi),%ecx
cmp    $0x13,%ecx
ja     1133 <spec2secs+0x23>
mov    %edi,%eax
lea    0xede(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
imul   $0x15180,%eax,%eax
pop    %rcx
ret
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
movsbl %sil,%edx
lea    0xf09(%rip),%rsi
call   1030 <err@plt>
xor    %eax,%eax
pop    %rcx
ret
imul   $0xe10,%eax,%eax
pop    %rcx
ret
imul   $0x3c,%eax,%eax
pop    %rcx
ret
imul   $0x93a80,%eax,%eax
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 i32 @spec2secs(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
store i32 0, i32* %5
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %22 [
i32 115, label %8
i32 109, label %10
i32 104, label %13
i32 100, label %16
i32 119, label %19
]
8: ; preds = %2
%9 = load i32, i32* %3
store i32 %9, i32* %5
br label %26
10: ; preds = %2
%11 = load i32, i32* %3
%12 = mul nsw i32 %11, 60
store i32 %12, i32* %5
br label %26
13: ; preds = %2
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 3600
store i32 %15, i32* %5
br label %26
16: ; preds = %2
%17 = load i32, i32* %3
%18 = mul nsw i32 %17, 86400
store i32 %18, i32* %5
br label %26
19: ; preds = %2
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 604800
store i32 %21, i32* %5
br label %26
22: ; preds = %2
%23 = load i32, i32* @EX_DATAERR
%24 = load i8, i8* %4
%25 = call i32 @err(i32 %23, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8 signext %24)
br label %26
26: ; preds = %22, %19, %16, %13, %10, %8
%27 = load i32, i32* %5
ret i32 %27
}

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