#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 sscanf(char const *, char *, long *, char *, char *);
int /*<<< orphan*/ ztolower(char);
long zstr_to_second(const char *s, long def) {
  char unit, junk;
  long intval;
  switch (sscanf(s, "%ld%c%c", &intval, &unit, &junk)) {
  case 1:
    unit = 's';
  case 2:
    if (intval < 0)
      return 0;
    switch (ztolower(unit)) {
    case 'w':
      return (intval * (7 * 24 * 3600));
    case 'd':
      return (intval * (24 * 3600));
    case 'h':
      return (intval * 3600);
    case 'm':
      return (intval * 60);
    case 's':
    default:
      return (intval);
    }
  }
  return def;
}


x86 assembly (clang, -O0):
<zstr_to_second>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xf15(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x19(%rbp),%rcx
lea    -0x1a(%rbp),%r8
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    %ecx,-0x2c(%rbp)
sub    $0x1,%eax
je     1170 <zstr_to_second+0x50>
jmp    115f <zstr_to_second+0x3f>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     1174 <zstr_to_second+0x54>
jmp    120e <zstr_to_second+0xee>
movb   $0x73,-0x19(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    118c <zstr_to_second+0x6c>
movq   $0x0,-0x8(%rbp)
jmp    1216 <zstr_to_second+0xf6>
movsbl -0x19(%rbp),%edi
call   1040 <ztolower@plt>
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x13,%eax
ja     1201 <zstr_to_second+0xe1>
mov    -0x38(%rbp),%rax
lea    0xe4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
imul   $0x93a80,-0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <zstr_to_second+0xf6>
imul   $0x15180,-0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <zstr_to_second+0xf6>
imul   $0xe10,-0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <zstr_to_second+0xf6>
imul   $0x3c,-0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <zstr_to_second+0xf6>
jmp    1201 <zstr_to_second+0xe1>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <zstr_to_second+0xf6>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zstr_to_second>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xf21(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x6(%rsp),%rcx
lea    0x7(%rsp),%r8
call   1030 <sscanf@plt>
cmp    $0x2,%eax
je     1152 <zstr_to_second+0x32>
cmp    $0x1,%eax
jne    11ae <zstr_to_second+0x8e>
movb   $0x73,0x6(%rsp)
cmpq   $0x0,0x8(%rsp)
js     1187 <zstr_to_second+0x67>
movsbl 0x6(%rsp),%edi
call   1040 <ztolower@plt>
add    $0xffffff9c,%eax
cmp    $0x13,%eax
ja     118b <zstr_to_second+0x6b>
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
imul   $0x15180,0x8(%rsp),%rbx
jmp    11ae <zstr_to_second+0x8e>
xor    %ebx,%ebx
jmp    11ae <zstr_to_second+0x8e>
mov    0x8(%rsp),%rbx
jmp    11ae <zstr_to_second+0x8e>
imul   $0xe10,0x8(%rsp),%rbx
jmp    11ae <zstr_to_second+0x8e>
imul   $0x3c,0x8(%rsp),%rbx
jmp    11ae <zstr_to_second+0x8e>
imul   $0x93a80,0x8(%rsp),%rbx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%ld%c%c\00"
define i64 @zstr_to_second(i8* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8
%7 = alloca i8
%8 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%9 = load i8*, i8** %4
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %8, i8* %6, i8* %7)
switch i32 %10, label %34 [
i32 1, label %11
i32 2, label %12
]
11: ; preds = %2
store i8 115, i8* %6
br label %12
12: ; preds = %2, %11
%13 = load i64, i64* %8
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i64 0, i64* %3
br label %36
16: ; preds = %12
%17 = load i8, i8* %6
%18 = call i32 @ztolower(i8 signext %17)
switch i32 %18, label %32 [
i32 119, label %19
i32 100, label %22
i32 104, label %25
i32 109, label %28
i32 115, label %31
]
19: ; preds = %16
%20 = load i64, i64* %8
%21 = mul nsw i64 %20, 604800
store i64 %21, i64* %3
br label %36
22: ; preds = %16
%23 = load i64, i64* %8
%24 = mul nsw i64 %23, 86400
store i64 %24, i64* %3
br label %36
25: ; preds = %16
%26 = load i64, i64* %8
%27 = mul nsw i64 %26, 3600
store i64 %27, i64* %3
br label %36
28: ; preds = %16
%29 = load i64, i64* %8
%30 = mul nsw i64 %29, 60
store i64 %30, i64* %3
br label %36
31: ; preds = %16
br label %32
32: ; preds = %16, %31
%33 = load i64, i64* %8
store i64 %33, i64* %3
br label %36
34: ; preds = %2
%35 = load i64, i64* %5
store i64 %35, i64* %3
br label %36
36: ; preds = %34, %32, %28, %25, %22, %19, %15
%37 = load i64, i64* %3
ret i64 %37
}

LLVM IR (-O2):
@.str = [8 x i8] c"%ld%c%c\00"
define i64 @zstr_to_second(i8* nocapture %0, i64 %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %5, i8* %3, i8* %4)
switch i32 %7, label %29 [
i32 1, label %8
i32 2, label %9
]
8: ; preds = %2
store i8 115, i8* %3
br label %9
9: ; preds = %2, %8
%10 = load i64, i64* %5
%11 = icmp slt i64 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %9
%13 = load i8, i8* %3
%14 = call i32 @ztolower(i8 signext %13)
switch i32 %14, label %27 [
i32 119, label %15
i32 100, label %18
i32 104, label %21
i32 109, label %24
]
15: ; preds = %12
%16 = load i64, i64* %5
%17 = mul nsw i64 %16, 604800
br label %29
18: ; preds = %12
%19 = load i64, i64* %5
%20 = mul nsw i64 %19, 86400
br label %29
21: ; preds = %12
%22 = load i64, i64* %5
%23 = mul nsw i64 %22, 3600
br label %29
24: ; preds = %12
%25 = load i64, i64* %5
%26 = mul nsw i64 %25, 60
br label %29
27: ; preds = %12
%28 = load i64, i64* %5
br label %29
29: ; preds = %2, %9, %27, %24, %21, %18, %15
%30 = phi i64 [ %28, %27 ], [ %26, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ], [ 0, %9 ], [ %1, %2 ]
ret i64 %30
}