#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__ strcmp(char *, char *);
long strtol(char *, char **, int);
long int make_seconds(char *int_string) {
  long val;
  char *endptr;
  val = strtol(int_string, &endptr, 10);
  if (*endptr != '\0') {
    if (strcmp(endptr, "s") == 0)
      return val;
    if (strcmp(endptr, "m") == 0)
      return (val * 60);
    if (strcmp(endptr, "h") == 0)
      return (val * 3600);
    if (strcmp(endptr, "d") == 0)
      return (val * 86400);
  }
  return val;
}


x86 assembly (clang, -O0):
<make_seconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11fc <make_seconds+0xdc>
mov    -0x20(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1179 <make_seconds+0x59>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <make_seconds+0xe4>
mov    -0x20(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a1 <make_seconds+0x81>
imul   $0x3c,-0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <make_seconds+0xe4>
mov    -0x20(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11cc <make_seconds+0xac>
imul   $0xe10,-0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <make_seconds+0xe4>
mov    -0x20(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f7 <make_seconds+0xd7>
imul   $0x15180,-0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1204 <make_seconds+0xe4>
jmp    11fc <make_seconds+0xdc>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_seconds>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%r14
mov    (%rsp),%rbx
cmpb   $0x0,(%rbx)
je     11a5 <make_seconds+0x85>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a5 <make_seconds+0x85>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1198 <make_seconds+0x78>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     119e <make_seconds+0x7e>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
imul   $0x15180,%r14,%rcx
test   %rax,%rax
cmove  %rcx,%r14
jmp    11a5 <make_seconds+0x85>
imul   $0x3c,%r14,%r14
jmp    11a5 <make_seconds+0x85>
imul   $0xe10,%r14,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"s\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [2 x i8] c"h\00"
@.str.3 = [2 x i8] c"d\00"
define i64 @make_seconds(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strtol(i8* %6, i8** %5, i32 10)
store i64 %7, i64* %4
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %40
12: ; preds = %1
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i64, i64* %4
store i64 %17, i64* %2
br label %42
18: ; preds = %12
%19 = load i8*, i8** %5
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i64, i64* %4
%24 = mul nsw i64 %23, 60
store i64 %24, i64* %2
br label %42
25: ; preds = %18
%26 = load i8*, i8** %5
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i64, i64* %4
%31 = mul nsw i64 %30, 3600
store i64 %31, i64* %2
br label %42
32: ; preds = %25
%33 = load i8*, i8** %5
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i64, i64* %4
%38 = mul nsw i64 %37, 86400
store i64 %38, i64* %2
br label %42
39: ; preds = %32
br label %40
40: ; preds = %39, %1
%41 = load i64, i64* %4
store i64 %41, i64* %2
br label %42
42: ; preds = %40, %36, %29, %22, %16
%43 = load i64, i64* %2
ret i64 %43
}

LLVM IR (-O2):
@.str = [2 x i8] c"s\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [2 x i8] c"h\00"
@.str.3 = [2 x i8] c"d\00"
define i64 @make_seconds(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %1
%9 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %5, 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 %14, label %16
14: ; preds = %11
%15 = mul nsw i64 %4, 60
br label %26
16: ; preds = %11
%17 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = mul nsw i64 %4, 3600
br label %26
21: ; preds = %16
%22 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = mul nsw i64 %4, 86400
%25 = select i1 %23, i64 %24, i64 %4
br label %26
26: ; preds = %21, %1, %8, %19, %14
%27 = phi i64 [ %15, %14 ], [ %20, %19 ], [ %4, %8 ], [ %4, %1 ], [ %25, %21 ]
ret i64 %27
}