#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 */
scalar_t__ atoi(char const *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int strspn(char const *, char *);
int convert_time(const char *string) {
  if (strcmp(string, "forever") == 0 || strcmp(string, "-") == 0 ||
      atoi(string) < 0)
    return 0;
  else if (strcmp(string, "none") == 0 || strcmp(string, "0") == 0)
    return -1;
  else {
    char worktime[80 + 1];
    int inttime;
    const char *suffix;
    suffix = string + strspn(string, "0123456789");
    strncpy(worktime, string, suffix - string);
    worktime[suffix - string] = '\0';
    inttime = atoi(worktime);
    switch (*suffix) {
    case 's':
    case '\0':
      break;
    case 'm':
      inttime *= 60;
      break;
    case 'h':
      inttime *= 60 * 60;
      break;
    case 'd':
      inttime *= 24 * 60 * 60;
      break;
    default:
      break;
    }
    return inttime;
  }
}


x86 assembly (clang, -O0):
<convert_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1196 <convert_time+0x56>
mov    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1196 <convert_time+0x56>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
cmp    $0x0,%rax
jge    11a2 <convert_time+0x62>
movl   $0x0,-0x4(%rbp)
jmp    12ea <convert_time+0x1aa>
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11d6 <convert_time+0x96>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11e2 <convert_time+0xa2>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ea <convert_time+0x1aa>
mov    -0x10(%rbp),%rdi
mov    %rdi,-0x98(%rbp)
lea    0xe1d(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x80(%rbp),%edx
mov    %esi,%eax
sub    %eax,%edx
lea    -0x70(%rbp),%rdi
mov    %rdi,-0x90(%rbp)
call   1030 <strncpy@plt>
mov    -0x90(%rbp),%rdi
mov    -0x80(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
movb   $0x0,-0x70(%rbp,%rax,1)
call   1060 <atoi@plt>
mov    %eax,-0x74(%rbp)
mov    -0x80(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x84(%rbp)
test   %eax,%eax
je     12b0 <convert_time+0x170>
jmp    1260 <convert_time+0x120>
mov    -0x84(%rbp),%eax
sub    $0x64,%eax
je     12d0 <convert_time+0x190>
jmp    1274 <convert_time+0x134>
mov    -0x84(%rbp),%eax
sub    $0x68,%eax
je     12c1 <convert_time+0x181>
jmp    1288 <convert_time+0x148>
mov    -0x84(%rbp),%eax
sub    $0x6d,%eax
je     12b5 <convert_time+0x175>
jmp    129c <convert_time+0x15c>
mov    -0x84(%rbp),%eax
sub    $0x73,%eax
jne    12df <convert_time+0x19f>
jmp    12b0 <convert_time+0x170>
jmp    12e4 <convert_time+0x1a4>
imul   $0x3c,-0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    12e4 <convert_time+0x1a4>
imul   $0xe10,-0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    12e4 <convert_time+0x1a4>
imul   $0x15180,-0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    12e4 <convert_time+0x1a4>
jmp    12e4 <convert_time+0x1a4>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_time>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
lea    0xead(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1218 <convert_time+0xd8>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1218 <convert_time+0xd8>
mov    %rbx,%rdi
call   1060 <atoi@plt>
test   %rax,%rax
js     1218 <convert_time+0xd8>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
je     1218 <convert_time+0xd8>
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1218 <convert_time+0xd8>
lea    0xe4f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strspn@plt>
movslq %eax,%r15
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rsp,%r15,1)
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %rax,%r14
movsbl (%rbx,%r15,1),%eax
cmp    $0x64,%eax
je     1208 <convert_time+0xc8>
cmp    $0x68,%eax
je     1211 <convert_time+0xd1>
cmp    $0x6d,%eax
jne    1218 <convert_time+0xd8>
imul   $0x3c,%r14d,%r14d
jmp    1218 <convert_time+0xd8>
imul   $0x15180,%r14d,%r14d
jmp    1218 <convert_time+0xd8>
imul   $0xe10,%r14d,%r14d
mov    %r14d,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"forever\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [5 x i8] c"none\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [11 x i8] c"0123456789\00"
define i32 @convert_time(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [81 x i8]
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = call i64 @atoi(i8* %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14, %10, %1
store i32 0, i32* %2
br label %68
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %19
store i32 -1, i32* %2
br label %68
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i8*, i8** %3
%31 = call i32 @strspn(i8* %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
store i8* %33, i8** %6
%34 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%35 = load i8*, i8** %3
%36 = load i8*, i8** %6
%37 = load i8*, i8** %3
%38 = ptrtoint i8* %36 to i64
%39 = ptrtoint i8* %37 to i64
%40 = sub i64 %38, %39
%41 = trunc i64 %40 to i32
%42 = call i32 @strncpy(i8* %34, i8* %35, i32 %41)
%43 = load i8*, i8** %6
%44 = load i8*, i8** %3
%45 = ptrtoint i8* %43 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 %47
store i8 0, i8* %48
%49 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%50 = call i64 @atoi(i8* %49)
%51 = trunc i64 %50 to i32
store i32 %51, i32* %5
%52 = load i8*, i8** %6
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
switch i32 %54, label %65 [
i32 115, label %55
i32 0, label %55
i32 109, label %56
i32 104, label %59
i32 100, label %62
]
55: ; preds = %28, %28
br label %66
56: ; preds = %28
%57 = load i32, i32* %5
%58 = mul nsw i32 %57, 60
store i32 %58, i32* %5
br label %66
59: ; preds = %28
%60 = load i32, i32* %5
%61 = mul nsw i32 %60, 3600
store i32 %61, i32* %5
br label %66
62: ; preds = %28
%63 = load i32, i32* %5
%64 = mul nsw i32 %63, 86400
store i32 %64, i32* %5
br label %66
65: ; preds = %28
br label %66
66: ; preds = %65, %62, %59, %56, %55
%67 = load i32, i32* %5
store i32 %67, i32* %2
br label %68
68: ; preds = %66, %27, %18
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
@.str = [8 x i8] c"forever\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [5 x i8] c"none\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [11 x i8] c"0123456789\00"
define i32 @convert_time(i8* %0) {
%2 = alloca [81 x i8]
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %36, label %5
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %36, label %8
8: ; preds = %5
%9 = tail call i64 @atoi(i8* %0)
%10 = icmp slt i64 %9, 0
br i1 %10, label %36, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %36, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %36, label %17
17: ; preds = %14
%18 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%19 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = call i32 @strncpy(i8* %18, i8* %0, i32 %19)
%23 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %23
%24 = call i64 @atoi(i8* %18)
%25 = trunc i64 %24 to i32
%26 = load i8, i8* %21
%27 = sext i8 %26 to i32
switch i32 %27, label %34 [
i32 100, label %32
i32 104, label %30
i32 109, label %28
]
28: ; preds = %17
%29 = mul nsw i32 %25, 60
br label %34
30: ; preds = %17
%31 = mul nsw i32 %25, 3600
br label %34
32: ; preds = %17
%33 = mul nsw i32 %25, 86400
br label %34
34: ; preds = %17, %32, %30, %28
%35 = phi i32 [ %25, %17 ], [ %29, %28 ], [ %31, %30 ], [ %33, %32 ]
br label %36
36: ; preds = %11, %14, %1, %5, %8, %34
%37 = phi i32 [ %35, %34 ], [ 0, %8 ], [ 0, %5 ], [ 0, %1 ], [ -1, %14 ], [ -1, %11 ]
ret i32 %37
}