#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strtoul(char *, char **, int);
unsigned int get_second(char *timestr) {
  unsigned int ui_retval;
  unsigned int ui_timeofs;
  char *timestr_end;
  char *timestr_tmp;
  ui_retval = 0;
  ui_timeofs = 1;
  if ((timestr == NULL) || (*timestr == (char)('\0')))
    return 0;
  timestr_tmp = (char *)malloc(strlen(timestr) * sizeof(char));
  if (timestr_tmp == NULL)
    return 0;
  strcpy(timestr_tmp, timestr);
  timestr_end = timestr_tmp + strlen(timestr_tmp) - 1;
  switch (*timestr_end) {
  case 's':
  case 'S':
    *timestr_end = (char)('\0');
  default:
    ui_timeofs = 1;
    break;
  case 'm':
  case 'M':
    *timestr_end = (char)('\0');
    ui_timeofs = 1 * 60;
    break;
  case 'h':
  case 'H':
    *timestr_end = (char)('\0');
    ui_timeofs = 1 * 60 * 60;
    break;
  case 'd':
  case 'D':
    *timestr_end = (char)('\0');
    ui_timeofs = 1 * 60 * 60 * 24;
    break;
  case 'w':
  case 'W':
    *timestr_end = (char)('\0');
    ui_timeofs = 1 * 60 * 60 * 24 * 7;
    break;
  }
  ui_retval =
      (unsigned int)strtoul(timestr_tmp, (char **)NULL, 10) * ui_timeofs;
  free(timestr_tmp);
  return ui_retval;
}


x86 assembly (clang, -O0):
<get_second>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1185 <get_second+0x35>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1191 <get_second+0x41>
movl   $0x0,-0x4(%rbp)
jmp    129d <get_second+0x14d>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c2 <get_second+0x72>
movl   $0x0,-0x4(%rbp)
jmp    129d <get_second+0x14d>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    %rdi,-0x38(%rbp)
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
lea    -0x1(%rax,%rcx,1),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x33,%eax
ja     1222 <get_second+0xd2>
mov    -0x30(%rbp),%rax
lea    0xdee(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x1,-0x18(%rbp)
jmp    1275 <get_second+0x125>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x3c,-0x18(%rbp)
jmp    1275 <get_second+0x125>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0xe10,-0x18(%rbp)
jmp    1275 <get_second+0x125>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x15180,-0x18(%rbp)
jmp    1275 <get_second+0x125>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x93a80,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtoul@plt>
imul   -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_second>:
push   %r15
push   %r14
push   %rbx
xor    %r15d,%r15d
test   %rdi,%rdi
je     11fa <get_second+0xaa>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11fa <get_second+0xaa>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11fa <get_second+0xaa>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movsbl -0x1(%r14,%rax,1),%ecx
mov    $0x1,%ebx
add    $0xffffffbc,%ecx
cmp    $0x33,%ecx
ja     11dc <get_second+0x8c>
lea    0xe4d(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x15180,%ebx
jmp    11d6 <get_second+0x86>
mov    $0xe10,%ebx
jmp    11d6 <get_second+0x86>
mov    $0x3c,%ebx
jmp    11d6 <get_second+0x86>
mov    $0x93a80,%ebx
movb   $0x0,-0x1(%r14,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtoul@plt>
mov    %rax,%r15
imul   %ebx,%r15d
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @get_second(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 1, i32* %5
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10, %1
store i32 0, i32* %2
br label %60
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i32 @strlen(i8* %17)
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %16
store i32 0, i32* %2
br label %60
27: ; preds = %16
%28 = load i8*, i8** %7
%29 = load i8*, i8** %3
%30 = call i32 @strcpy(i8* %28, i8* %29)
%31 = load i8*, i8** %7
%32 = load i8*, i8** %7
%33 = call i32 @strlen(i8* %32)
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
%36 = getelementptr inbounds i8, i8* %35, i64 -1
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
switch i32 %39, label %42 [
i32 115, label %40
i32 83, label %40
i32 109, label %43
i32 77, label %43
i32 104, label %45
i32 72, label %45
i32 100, label %47
i32 68, label %47
i32 119, label %49
i32 87, label %49
]
40: ; preds = %27, %27
%41 = load i8*, i8** %6
store i8 0, i8* %41
br label %42
42: ; preds = %27, %40
store i32 1, i32* %5
br label %51
43: ; preds = %27, %27
%44 = load i8*, i8** %6
store i8 0, i8* %44
store i32 60, i32* %5
br label %51
45: ; preds = %27, %27
%46 = load i8*, i8** %6
store i8 0, i8* %46
store i32 3600, i32* %5
br label %51
47: ; preds = %27, %27
%48 = load i8*, i8** %6
store i8 0, i8* %48
store i32 86400, i32* %5
br label %51
49: ; preds = %27, %27
%50 = load i8*, i8** %6
store i8 0, i8* %50
store i32 604800, i32* %5
br label %51
51: ; preds = %49, %47, %45, %43, %42
%52 = load i8*, i8** %7
%53 = call i64 @strtoul(i8* %52, i8** null, i32 10)
%54 = trunc i64 %53 to i32
%55 = load i32, i32* %5
%56 = mul i32 %54, %55
store i32 %56, i32* %4
%57 = load i8*, i8** %7
%58 = call i32 @free(i8* %57)
%59 = load i32, i32* %4
store i32 %59, i32* %2
br label %60
60: ; preds = %51, %26, %15
%61 = load i32, i32* %2
ret i32 %61
}

LLVM IR (-O2):
define i32 @get_second(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %31, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %31, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i64 %8, 0
br i1 %10, label %31, label %11
11: ; preds = %6
%12 = tail call i32 @strcpy(i8* %9, i8* %0)
%13 = tail call i32 @strlen(i8* %9)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %9, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %25 [
i32 115, label %23
i32 83, label %23
i32 109, label %19
i32 77, label %19
i32 104, label %20
i32 72, label %20
i32 100, label %21
i32 68, label %21
i32 119, label %22
i32 87, label %22
]
19: ; preds = %11, %11
br label %23
20: ; preds = %11, %11
br label %23
21: ; preds = %11, %11
br label %23
22: ; preds = %11, %11
br label %23
23: ; preds = %11, %11, %19, %20, %21, %22
%24 = phi i32 [ 60, %19 ], [ 3600, %20 ], [ 86400, %21 ], [ 604800, %22 ], [ 1, %11 ], [ 1, %11 ]
store i8 0, i8* %16
br label %25
25: ; preds = %23, %11
%26 = phi i32 [ 1, %11 ], [ %24, %23 ]
%27 = tail call i64 @strtoul(i8* nocapture %9, i8** null, i32 10)
%28 = trunc i64 %27 to i32
%29 = mul i32 %26, %28
%30 = tail call i32 @free(i8* %9)
br label %31
31: ; preds = %6, %1, %3, %25
%32 = phi i32 [ %29, %25 ], [ 0, %3 ], [ 0, %1 ], [ 0, %6 ]
ret i32 %32
}