#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 *);
float strtof(char const *, char **);
int parse_duration(const char *duration) {
  float value;
  char *end;
  value = strtof(duration, &end);
  if (*duration != '\0' && *end == '\0')
    return (
        ((-1)) > ((((0xffff)) < (((int)value)) ? ((0xffff)) : (((int)value))))
            ? ((-1))
            : ((((0xffff)) < (((int)value)) ? ((0xffff)) : (((int)value)))));
  if (strcmp(end, "s") == 0)
    return (
        ((-1)) > ((((0xffff)) < ((value * 100)) ? ((0xffff)) : ((value * 100))))
            ? ((-1))
            : ((((0xffff)) < ((value * 100)) ? ((0xffff)) : ((value * 100)))));
  if (strcmp(end, "ms") == 0)
    return (
        ((-1)) > ((((0xffff)) < ((value / 10)) ? ((0xffff)) : ((value / 10))))
            ? ((-1))
            : ((((0xffff)) < ((value / 10)) ? ((0xffff)) : ((value / 10)))));
  return -1;
}


x86 assembly (clang, -O0):
<parse_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtof@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11da <parse_duration+0xba>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11da <parse_duration+0xba>
cvttss2si -0x14(%rbp),%ecx
mov    $0xffff,%eax
cmp    %ecx,%eax
jge    117d <parse_duration+0x5d>
mov    $0xffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1185 <parse_duration+0x65>
cvttss2si -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jle    11a2 <parse_duration+0x82>
mov    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    11cf <parse_duration+0xaf>
cvttss2si -0x14(%rbp),%ecx
mov    $0xffff,%eax
cmp    %ecx,%eax
jge    11c1 <parse_duration+0xa1>
mov    $0xffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c9 <parse_duration+0xa9>
cvttss2si -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13b3 <parse_duration+0x293>
mov    -0x20(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12bb <parse_duration+0x19b>
movss  0xe10(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  0xdf7(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1224 <parse_duration+0x104>
movss  0xde6(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    1236 <parse_duration+0x116>
movss  0xde0(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm1
movss  0xdc5(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    125e <parse_duration+0x13e>
movss  0xdb4(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
jmp    12aa <parse_duration+0x18a>
movss  0xda6(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  0xd8d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    128e <parse_duration+0x16e>
movss  0xd7c(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
jmp    12a0 <parse_duration+0x180>
movss  0xd76(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
jmp    13b3 <parse_duration+0x293>
mov    -0x20(%rbp),%rdi
lea    0xd4a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    13ac <parse_duration+0x28c>
movss  -0x14(%rbp),%xmm0
movss  0xd22(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xd12(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1309 <parse_duration+0x1e9>
movss  0xd01(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
jmp    131f <parse_duration+0x1ff>
movss  -0x14(%rbp),%xmm0
movss  0xcee(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm1
movss  0xcdc(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    1347 <parse_duration+0x227>
movss  0xccb(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
jmp    139b <parse_duration+0x27b>
movss  -0x14(%rbp),%xmm0
movss  0xcb0(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xca0(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    137b <parse_duration+0x25b>
movss  0xc8f(%rip),%xmm0
movss  %xmm0,-0x44(%rbp)
jmp    1391 <parse_duration+0x271>
movss  -0x14(%rbp),%xmm0
movss  0xc7c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x40(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
jmp    13b3 <parse_duration+0x293>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_duration>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <strtof@plt>
cmpb   $0x0,(%rbx)
mov    0x8(%rsp),%rbx
je     1145 <parse_duration+0x25>
cmpb   $0x0,(%rbx)
je     11f4 <parse_duration+0xd4>
movss  %xmm0,0x4(%rsp)
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c8 <parse_duration+0xa8>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    120f <parse_duration+0xef>
movss  0x4(%rsp),%xmm2
divss  0xe73(%rip),%xmm2
movss  0xe6f(%rip),%xmm0
xor    %eax,%eax
ucomiss %xmm0,%xmm2
seta   %al
shl    $0x10,%eax
add    $0xffffffff,%eax
movss  0xe5d(%rip),%xmm1
ucomiss %xmm2,%xmm1
mov    $0xffff,%ecx
cmova  %eax,%ecx
ucomiss %xmm0,%xmm2
cvttss2si %xmm2,%eax
cmova  %ecx,%eax
ucomiss %xmm2,%xmm1
cmova  %ecx,%eax
jmp    120f <parse_duration+0xef>
movss  0x4(%rsp),%xmm1
mulss  0xe36(%rip),%xmm1
movss  0xe26(%rip),%xmm0
minss  %xmm1,%xmm0
movss  0xe1e(%rip),%xmm1
maxss  %xmm0,%xmm1
cvttss2si %xmm1,%eax
jmp    120f <parse_duration+0xef>
cvttss2si %xmm0,%eax
cmp    $0xffff,%eax
mov    $0xffff,%ecx
cmovl  %eax,%ecx
test   %ecx,%ecx
mov    $0xffffffff,%eax
cmovns %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"s\00"
@.str.1 = [3 x i8] c"ms\00"
define i32 @parse_duration(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca float
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call float @strtof(i8* %6, i8** %5)
store float %7, float* %4
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %41
12: ; preds = %1
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %41
17: ; preds = %12
%18 = load float, float* %4
%19 = fptosi float %18 to i32
%20 = icmp slt i32 65535, %19
br i1 %20, label %21, label %22
21: ; preds = %17
br label %25
22: ; preds = %17
%23 = load float, float* %4
%24 = fptosi float %23 to i32
br label %25
25: ; preds = %22, %21
%26 = phi i32 [ 65535, %21 ], [ %24, %22 ]
%27 = icmp sgt i32 -1, %26
br i1 %27, label %28, label %29
28: ; preds = %25
br label %39
29: ; preds = %25
%30 = load float, float* %4
%31 = fptosi float %30 to i32
%32 = icmp slt i32 65535, %31
br i1 %32, label %33, label %34
33: ; preds = %29
br label %37
34: ; preds = %29
%35 = load float, float* %4
%36 = fptosi float %35 to i32
br label %37
37: ; preds = %34, %33
%38 = phi i32 [ 65535, %33 ], [ %36, %34 ]
br label %39
39: ; preds = %37, %28
%40 = phi i32 [ -1, %28 ], [ %38, %37 ]
store i32 %40, i32* %2
br label %100
41: ; preds = %12, %1
%42 = load i8*, i8** %5
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %70
45: ; preds = %41
%46 = load float, float* %4
%47 = fmul float %46, 1.000000e+02
%48 = fcmp olt float 6.553500e+04, %47
br i1 %48, label %49, label %50
49: ; preds = %45
br label %53
50: ; preds = %45
%51 = load float, float* %4
%52 = fmul float %51, 1.000000e+02
br label %53
53: ; preds = %50, %49
%54 = phi float [ 6.553500e+04, %49 ], [ %52, %50 ]
%55 = fcmp ogt float -1.000000e+00, %54
br i1 %55, label %56, label %57
56: ; preds = %53
br label %67
57: ; preds = %53
%58 = load float, float* %4
%59 = fmul float %58, 1.000000e+02
%60 = fcmp olt float 6.553500e+04, %59
br i1 %60, label %61, label %62
61: ; preds = %57
br label %65
62: ; preds = %57
%63 = load float, float* %4
%64 = fmul float %63, 1.000000e+02
br label %65
65: ; preds = %62, %61
%66 = phi float [ 6.553500e+04, %61 ], [ %64, %62 ]
br label %67
67: ; preds = %65, %56
%68 = phi float [ -1.000000e+00, %56 ], [ %66, %65 ]
%69 = fptosi float %68 to i32
store i32 %69, i32* %2
br label %100
70: ; preds = %41
%71 = load i8*, i8** %5
%72 = call i64 @strcmp(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %99
74: ; preds = %70
%75 = load float, float* %4
%76 = fdiv float %75, 1.000000e+01
%77 = fcmp olt float 6.553500e+04, %76
br i1 %77, label %78, label %79
78: ; preds = %74
br label %82
79: ; preds = %74
%80 = load float, float* %4
%81 = fdiv float %80, 1.000000e+01
br label %82
82: ; preds = %79, %78
%83 = phi float [ 6.553500e+04, %78 ], [ %81, %79 ]
%84 = fcmp ogt float -1.000000e+00, %83
br i1 %84, label %85, label %86
85: ; preds = %82
br label %96
86: ; preds = %82
%87 = load float, float* %4
%88 = fdiv float %87, 1.000000e+01
%89 = fcmp olt float 6.553500e+04, %88
br i1 %89, label %90, label %91
90: ; preds = %86
br label %94
91: ; preds = %86
%92 = load float, float* %4
%93 = fdiv float %92, 1.000000e+01
br label %94
94: ; preds = %91, %90
%95 = phi float [ 6.553500e+04, %90 ], [ %93, %91 ]
br label %96
96: ; preds = %94, %85
%97 = phi float [ -1.000000e+00, %85 ], [ %95, %94 ]
%98 = fptosi float %97 to i32
store i32 %98, i32* %2
br label %100
99: ; preds = %70
store i32 -1, i32* %2
br label %100
100: ; preds = %99, %96, %67, %39
%101 = load i32, i32* %2
ret i32 %101
}

LLVM IR (-O2):
@.str = [2 x i8] c"s\00"
@.str.1 = [3 x i8] c"ms\00"
define i32 @parse_duration(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call float @strtof(i8* %0, i8** %2)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
%7 = load i8*, i8** %2
br i1 %6, label %17, label %8
8: ; preds = %1
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = fptosi float %4 to i32
%13 = icmp slt i32 %12, 65535
%14 = select i1 %13, i32 %12, i32 65535
%15 = icmp sgt i32 %14, -1
%16 = select i1 %15, i32 %14, i32 -1
br label %40
17: ; preds = %1, %8
%18 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = fmul float %4, 1.000000e+02
%22 = fcmp ogt float %21, 6.553500e+04
%23 = select i1 %22, float 6.553500e+04, float %21
%24 = fcmp ole float %23, -1.000000e+00
%25 = select i1 %24, float -1.000000e+00, float %23
%26 = fptosi float %25 to i32
br label %40
27: ; preds = %17
%28 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = fdiv float %4, 1.000000e+01
%32 = fcmp ogt float %31, 6.553500e+04
%33 = fcmp olt float %31, -1.000000e+00
%34 = xor i1 %32, true
%35 = and i1 %33, %34
%36 = or i1 %33, %32
%37 = select i1 %35, i32 -1, i32 65535
%38 = fptosi float %31 to i32
%39 = select i1 %36, i32 %37, i32 %38
br label %40
40: ; preds = %27, %30, %20, %11
%41 = phi i32 [ %16, %11 ], [ %26, %20 ], [ %39, %30 ], [ -1, %27 ]
ret i32 %41
}