#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 sscanf(char const *, char *, double *, char *);
int capture_duration(const char *carg, void *pvar) {
  double *pf = pvar;
  char mult = 's';
  int r = sscanf(carg, "%lf%c", pf, &mult);
  if (r != 1 && r != 2)
    return 1;
  switch (mult) {
  case 'h':
    *pf *= 60.;
  case 'm':
    *pf *= 60.;
  case 's':
    return 0;
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<capture_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movb   $0x73,-0x21(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xecd(%rip),%rsi
lea    -0x21(%rbp),%rcx
call   1030 <sscanf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     1167 <capture_duration+0x57>
cmpl   $0x2,-0x28(%rbp)
je     1167 <capture_duration+0x57>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <capture_duration+0xc9>
movsbl -0x21(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x68,%eax
je     119e <capture_duration+0x8e>
jmp    117c <capture_duration+0x6c>
mov    -0x2c(%rbp),%eax
sub    $0x6d,%eax
je     11b2 <capture_duration+0xa2>
jmp    118d <capture_duration+0x7d>
mov    -0x2c(%rbp),%eax
sub    $0x73,%eax
je     11c6 <capture_duration+0xb6>
jmp    11d2 <capture_duration+0xc2>
mov    -0x20(%rbp),%rax
movsd  0xe56(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xe42(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11d9 <capture_duration+0xc9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<capture_duration>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movb   $0x73,0xf(%rsp)
lea    0xee4(%rip),%rsi
lea    0xf(%rsp),%rcx
mov    %rbx,%rdx
call   1030 <sscanf@plt>
mov    %eax,%ecx
add    $0xfffffffd,%ecx
mov    $0x1,%eax
cmp    $0xfffffffe,%ecx
jb     117b <capture_duration+0x6b>
movsbl 0xf(%rsp),%ecx
xor    %eax,%eax
cmp    $0x68,%ecx
je     115c <capture_duration+0x4c>
cmp    $0x73,%ecx
je     117b <capture_duration+0x6b>
cmp    $0x6d,%ecx
jne    1176 <capture_duration+0x66>
movsd  (%rbx),%xmm0
jmp    1168 <capture_duration+0x58>
movsd  (%rbx),%xmm0
mulsd  0xe98(%rip),%xmm0
mulsd  0xe90(%rip),%xmm0
movsd  %xmm0,(%rbx)
jmp    117b <capture_duration+0x6b>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%lf%c\00"
define i32 @capture_duration(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i8
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = bitcast i8* %9 to double*
store double* %10, double** %6
store i8 115, i8* %7
%11 = load i8*, i8** %4
%12 = load double*, double** %6
%13 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %12, i8* %7)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i32, i32* %8
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 1, i32* %3
br label %33
20: ; preds = %16, %2
%21 = load i8, i8* %7
%22 = sext i8 %21 to i32
switch i32 %22, label %32 [
i32 104, label %23
i32 109, label %27
i32 115, label %31
]
23: ; preds = %20
%24 = load double*, double** %6
%25 = load double, double* %24
%26 = fmul double %25, 6.000000e+01
store double %26, double* %24
br label %27
27: ; preds = %20, %23
%28 = load double*, double** %6
%29 = load double, double* %28
%30 = fmul double %29, 6.000000e+01
store double %30, double* %28
br label %31
31: ; preds = %20, %27
store i32 0, i32* %3
br label %33
32: ; preds = %20
store i32 1, i32* %3
br label %33
33: ; preds = %32, %31, %19
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lf%c\00"
define i32 @capture_duration(i8* nocapture %0, i8* %1) {
%3 = alloca i8
%4 = bitcast i8* %1 to double*
store i8 115, i8* %3
%5 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double* %4, i8* %3)
%6 = add i32 %5, -3
%7 = icmp ult i32 %6, -2
br i1 %7, label %20, label %8
8: ; preds = %2
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
switch i32 %10, label %19 [
i32 104, label %13
i32 109, label %11
i32 115, label %20
]
11: ; preds = %8
%12 = load double, double* %4
br label %16
13: ; preds = %8
%14 = load double, double* %4
%15 = fmul double %14, 6.000000e+01
br label %16
16: ; preds = %11, %13
%17 = phi double [ %12, %11 ], [ %15, %13 ]
%18 = fmul double %17, 6.000000e+01
store double %18, double* %4
br label %20
19: ; preds = %8
br label %20
20: ; preds = %16, %8, %2, %19
%21 = phi i32 [ 1, %19 ], [ 1, %2 ], [ 0, %8 ], [ 0, %16 ]
ret i32 %21
}