#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 */
unsigned int atoi(char *);
scalar_t__ strstr(char *, char *);
unsigned int convert_timespec(char *string) {
  unsigned int base;
  base = atoi(string);
  if (strstr(string, "m")) {
    base *= 1000;
  } else if (strstr(string, "u")) {
    base *= (1);
  } else if (strstr(string, "s")) {
    base *= (1000 * 1000);
  } else {
    base *= (1000);
  }
  return (base);
}


x86 assembly (clang, -O0):
<convert_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1161 <convert_timespec+0x41>
imul   $0x3e8,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11c6 <convert_timespec+0xa6>
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1189 <convert_timespec+0x69>
mov    -0xc(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <convert_timespec+0xa1>
mov    -0x8(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11b2 <convert_timespec+0x92>
imul   $0xf4240,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11bc <convert_timespec+0x9c>
imul   $0x3e8,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11c1 <convert_timespec+0xa1>
jmp    11c6 <convert_timespec+0xa6>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_timespec>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <atoi@plt>
mov    %eax,%ebp
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1149 <convert_timespec+0x29>
imul   $0x3e8,%ebp,%ebp
jmp    1177 <convert_timespec+0x57>
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
jne    1177 <convert_timespec+0x57>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
je     1141 <convert_timespec+0x21>
imul   $0xf4240,%ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"m\00"
@.str.1 = [2 x i8] c"u\00"
@.str.2 = [2 x i8] c"s\00"
define i32 @convert_timespec(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @atoi(i8* %4)
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = mul i32 %10, 1000
store i32 %11, i32* %3
br label %31
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i64 @strstr(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %3
%18 = mul i32 %17, 1
store i32 %18, i32* %3
br label %30
19: ; preds = %12
%20 = load i8*, i8** %2
%21 = call i64 @strstr(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = mul i32 %24, 1000000
store i32 %25, i32* %3
br label %29
26: ; preds = %19
%27 = load i32, i32* %3
%28 = mul i32 %27, 1000
store i32 %28, i32* %3
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %16
br label %31
31: ; preds = %30, %9
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [2 x i8] c"m\00"
@.str.1 = [2 x i8] c"u\00"
@.str.2 = [2 x i8] c"s\00"
define i32 @convert_timespec(i8* %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = mul i32 %2, 1000
br label %17
7: ; preds = %1
%8 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = mul i32 %2, 1000000
br label %17
15: ; preds = %10
%16 = mul i32 %2, 1000
br label %17
17: ; preds = %7, %15, %13, %5
%18 = phi i32 [ %6, %5 ], [ %14, %13 ], [ %16, %15 ], [ %2, %7 ]
ret i32 %18
}