#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 */
double parse_timespec(char const *);
int /*<<< orphan*/ usage(char *);
double parse_signed_timespec(const char *string) {
  char op;
  double timespec;
  if (!string || !string[0])
    return 0;
  op = string[0];
  timespec = parse_timespec(&string[1]);
  switch (op) {
  case '+':
    break;
  case '-':
    timespec *= -1;
    break;
  default:
    usage("No sign given for delay\n");
  }
  return timespec;
}


x86 assembly (clang, -O0):
<parse_signed_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <parse_signed_timespec+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1151 <parse_signed_timespec+0x31>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <parse_signed_timespec+0xa4>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1030 <parse_timespec@plt>
movsd  %xmm0,-0x20(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2b,%eax
je     1192 <parse_signed_timespec+0x72>
jmp    1181 <parse_signed_timespec+0x61>
mov    -0x24(%rbp),%eax
sub    $0x2d,%eax
je     1197 <parse_signed_timespec+0x77>
jmp    11ae <parse_signed_timespec+0x8e>
jmp    11ba <parse_signed_timespec+0x9a>
movsd  0xe61(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ba <parse_signed_timespec+0x9a>
lea    0xe53(%rip),%rdi
call   1040 <usage@plt>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_signed_timespec>:
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
test   %rdi,%rdi
je     1164 <parse_signed_timespec+0x44>
movsbl (%rdi),%ebx
test   %ebx,%ebx
je     1164 <parse_signed_timespec+0x44>
add    $0x1,%rdi
call   1030 <parse_timespec@plt>
cmp    $0x2b,%ebx
je     1164 <parse_signed_timespec+0x44>
cmp    $0x2d,%ebx
jne    1150 <parse_signed_timespec+0x30>
xorps  0xeb2(%rip),%xmm0
jmp    1164 <parse_signed_timespec+0x44>
lea    0xeb9(%rip),%rdi
movaps %xmm0,(%rsp)
call   1040 <usage@plt>
movaps (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"No sign given for delay\0A\00"
define double @parse_signed_timespec(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i8
%5 = alloca double
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %8, %1
store double 0.000000e+00, double* %2
br label %31
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
store i8 %17, i8* %4
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call double @parse_timespec(i8* %19)
store double %20, double* %5
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
switch i32 %22, label %27 [
i32 43, label %23
i32 45, label %24
]
23: ; preds = %14
br label %29
24: ; preds = %14
%25 = load double, double* %5
%26 = fmul double %25, -1.000000e+00
store double %26, double* %5
br label %29
27: ; preds = %14
%28 = call i32 @usage(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %24, %23
%30 = load double, double* %5
store double %30, double* %2
br label %31
31: ; preds = %29, %13
%32 = load double, double* %2
ret double %32
}

LLVM IR (-O2):
@.str = [25 x i8] c"No sign given for delay\0A\00"
define double @parse_signed_timespec(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = tail call double @parse_timespec(i8* %7)
%9 = sext i8 %4 to i32
switch i32 %9, label %12 [
i32 43, label %14
i32 45, label %10
]
10: ; preds = %6
%11 = fneg double %8
br label %14
12: ; preds = %6
%13 = tail call i32 @usage(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %6, %10, %12, %1, %3
%15 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %1 ], [ %8, %12 ], [ %11, %10 ], [ %8, %6 ]
ret double %15
}