#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(unsigned int);
double strtod(char *, char **);
int /*<<< orphan*/ usleep(double);
int main(int argc, char *argv[]) {
  double duration = 0.0;
  if (argc <= 1)
    goto error;
  for (argv++; argc > 1; argc--, argv++) {
    char *suffix;
    double value = strtod(*argv, &suffix);
    if (suffix == *argv)
      goto error;
    switch (*suffix) {
    case 'd':
      value *= 24.0;
    case 'h':
      value *= 60.0;
    case 'm':
      value *= 60.0;
    case 's':
      if (*(suffix + 1) != '\0')
        goto error;
    case '\0':
      break;
    default:
      goto error;
    }
    duration += value;
  }
  if (duration >= 1.0) {
    unsigned int seconds = (unsigned int)duration;
    sleep(seconds);
    duration -= (double)seconds;
  }
  if (duration > 0.0)
    usleep(duration * 1e6);
  return 0;
error:
  printf("Usage: sleep NUMBER[smhd] ...\n"
         "\n"
         "Pause for an amount of time specified by the sum of the arguments' "
         "values.\n"
         "Each argument is made up by a NUMBER which may be any arbitrary "
         "floating point\n"
         "number, followed by an optional suffix which may be 's' for seconds "
         "(the\n"
         "default), 'm' for minutes, 'h' for hours or 'd' for days.\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     116d <main+0x2d>
jmp    12fb <main+0x1bb>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    128d <main+0x14d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    11ae <main+0x6e>
jmp    12fb <main+0x1bb>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     125a <main+0x11a>
jmp    11c5 <main+0x85>
mov    -0x30(%rbp),%eax
sub    $0x64,%eax
je     1209 <main+0xc9>
jmp    11d6 <main+0x96>
mov    -0x30(%rbp),%eax
sub    $0x68,%eax
je     121b <main+0xdb>
jmp    11e7 <main+0xa7>
mov    -0x30(%rbp),%eax
sub    $0x6d,%eax
je     122d <main+0xed>
jmp    11f8 <main+0xb8>
mov    -0x30(%rbp),%eax
sub    $0x73,%eax
je     123f <main+0xff>
jmp    125f <main+0x11f>
movsd  0xdff(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdf5(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xde3(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1255 <main+0x115>
jmp    12fb <main+0x1bb>
jmp    125a <main+0x11a>
jmp    1264 <main+0x124>
jmp    12fb <main+0x1bb>
movsd  -0x28(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1179 <main+0x39>
movsd  -0x18(%rbp),%xmm0
movsd  0xd66(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12cb <main+0x18b>
cvttsd2si -0x18(%rbp),%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <sleep@plt>
mov    -0x2c(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12ef <main+0x1af>
movsd  0xd23(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <usleep@plt>
movl   $0x0,-0x4(%rbp)
jmp    130e <main+0x1ce>
lea    0xd1e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     11e7 <main+0xa7>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x8,%rbx
add    $0x1,%ebp
xorpd  %xmm0,%xmm0
lea    0x10(%rsp),%r14
lea    0xeb1(%rip),%r15
jmp    119a <main+0x5a>
test   %ecx,%ecx
jne    11e7 <main+0xa7>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rbx
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
jle    1205 <main+0xc5>
movsd  %xmm0,0x8(%rsp)
mov    (%rbx),%rdi
mov    %r14,%rsi
call   1040 <strtod@plt>
mov    0x10(%rsp),%rax
cmp    (%rbx),%rax
je     11e7 <main+0xa7>
movsbl (%rax),%ecx
lea    -0x64(%rcx),%edx
cmp    $0xf,%edx
ja     1171 <main+0x31>
movslq (%r15,%rdx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mulsd  0xe2f(%rip),%xmm0
mulsd  0xe2f(%rip),%xmm0
mulsd  0xe27(%rip),%xmm0
cmpb   $0x0,0x1(%rax)
je     1180 <main+0x40>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
ucomisd 0xe03(%rip),%xmm0
jae    1215 <main+0xd5>
movapd %xmm0,%xmm1
jmp    123b <main+0xfb>
cvttsd2si %xmm0,%rbx
mov    %ebx,%edi
movsd  %xmm0,0x8(%rsp)
call   1050 <sleep@plt>
movsd  0x8(%rsp),%xmm1
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
subsd  %xmm0,%xmm1
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    11f8 <main+0xb8>
movapd %xmm1,%xmm0
mulsd  0xdc5(%rip),%xmm0
call   1060 <usleep@plt>
jmp    11f8 <main+0xb8>

LLVM IR (-O0):
@.str = [317 x i8] c"Usage: sleep NUMBER[smhd] ...\0A\0APause for an amount of time specified by the sum of the arguments' values.\0AEach argument is made up by a NUMBER which may be any arbitrary floating point\0Anumber, followed by an optional suffix which may be 's' for seconds (the\0Adefault), 'm' for minutes, 'h' for hours or 'd' for days.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i8*
%8 = alloca double
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %6
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
br label %80
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %5
br label %16
16: ; preds = %55, %13
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %60
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = call double @strtod(i8* %21, i8** %7)
store double %22, double* %8
%23 = load i8*, i8** %7
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = icmp eq i8* %23, %25
br i1 %26, label %27, label %28
27: ; preds = %19
br label %80
28: ; preds = %19
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %50 [
i32 100, label %32
i32 104, label %35
i32 109, label %38
i32 115, label %41
i32 0, label %49
]
32: ; preds = %28
%33 = load double, double* %8
%34 = fmul double %33, 2.400000e+01
store double %34, double* %8
br label %35
35: ; preds = %28, %32
%36 = load double, double* %8
%37 = fmul double %36, 6.000000e+01
store double %37, double* %8
br label %38
38: ; preds = %28, %35
%39 = load double, double* %8
%40 = fmul double %39, 6.000000e+01
store double %40, double* %8
br label %41
41: ; preds = %28, %38
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 1
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %41
br label %80
48: ; preds = %41
br label %49
49: ; preds = %28, %48
br label %51
50: ; preds = %28
br label %80
51: ; preds = %49
%52 = load double, double* %8
%53 = load double, double* %6
%54 = fadd double %53, %52
store double %54, double* %6
br label %55
55: ; preds = %51
%56 = load i32, i32* %4
%57 = add nsw i32 %56, -1
store i32 %57, i32* %4
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i32 1
store i8** %59, i8*** %5
br label %16
60: ; preds = %16
%61 = load double, double* %6
%62 = fcmp oge double %61, 1.000000e+00
br i1 %62, label %63, label %72
63: ; preds = %60
%64 = load double, double* %6
%65 = fptoui double %64 to i32
store i32 %65, i32* %9
%66 = load i32, i32* %9
%67 = call i32 @sleep(i32 %66)
%68 = load i32, i32* %9
%69 = uitofp i32 %68 to double
%70 = load double, double* %6
%71 = fsub double %70, %69
store double %71, double* %6
br label %72
72: ; preds = %63, %60
%73 = load double, double* %6
%74 = fcmp ogt double %73, 0.000000e+00
br i1 %74, label %75, label %79
75: ; preds = %72
%76 = load double, double* %6
%77 = fmul double %76, 1.000000e+06
%78 = call i32 @usleep(double %77)
br label %79
79: ; preds = %75, %72
store i32 0, i32* %3
br label %82
80: ; preds = %50, %47, %27, %12
%81 = call i32 @printf(i8* getelementptr inbounds ([317 x i8], [317 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %82
82: ; preds = %80, %79
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@str = [316 x i8] c"Usage: sleep NUMBER[smhd] ...\0A\0APause for an amount of time specified by the sum of the arguments' values.\0AEach argument is made up by a NUMBER which may be any arbitrary floating point\0Anumber, followed by an optional suffix which may be 's' for seconds (the\0Adefault), 'm' for minutes, 'h' for hours or 'd' for days.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp slt i32 %0, 2
br i1 %4, label %52, label %5
5: ; preds = %2
%6 = bitcast i8** %3 to i8*
br label %7
7: ; preds = %5, %34
%8 = phi i8** [ %1, %5 ], [ %11, %34 ]
%9 = phi double [ 0.000000e+00, %5 ], [ %36, %34 ]
%10 = phi i32 [ %0, %5 ], [ %37, %34 ]
%11 = getelementptr inbounds i8*, i8** %8, i64 1
%12 = load i8*, i8** %11
%13 = call double @strtod(i8* %12, i8** %3)
%14 = load i8*, i8** %3
%15 = load i8*, i8** %11
%16 = icmp eq i8* %14, %15
br i1 %16, label %33, label %17
17: ; preds = %7
%18 = load i8, i8* %14
%19 = sext i8 %18 to i32
switch i32 %19, label %33 [
i32 100, label %20
i32 104, label %22
i32 109, label %25
i32 115, label %28
i32 0, label %34
]
20: ; preds = %17
%21 = fmul double %13, 2.400000e+01
br label %22
22: ; preds = %17, %20
%23 = phi double [ %13, %17 ], [ %21, %20 ]
%24 = fmul double %23, 6.000000e+01
br label %25
25: ; preds = %17, %22
%26 = phi double [ %13, %17 ], [ %24, %22 ]
%27 = fmul double %26, 6.000000e+01
br label %28
28: ; preds = %17, %25
%29 = phi double [ %13, %17 ], [ %27, %25 ]
%30 = getelementptr inbounds i8, i8* %14, i64 1
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %7, %28, %17
br label %52
34: ; preds = %28, %17
%35 = phi double [ %13, %17 ], [ %29, %28 ]
%36 = fadd double %9, %35
%37 = add nsw i32 %10, -1
%38 = icmp sgt i32 %10, 2
br i1 %38, label %7, label %39
39: ; preds = %34
%40 = fcmp ult double %36, 1.000000e+00
br i1 %40, label %46, label %41
41: ; preds = %39
%42 = fptoui double %36 to i32
%43 = tail call i32 @sleep(i32 %42)
%44 = uitofp i32 %42 to double
%45 = fsub double %36, %44
br label %46
46: ; preds = %41, %39
%47 = phi double [ %45, %41 ], [ %36, %39 ]
%48 = fcmp ogt double %47, 0.000000e+00
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = fmul double %47, 1.000000e+06
%51 = tail call i32 @usleep(double %50)
br label %54
52: ; preds = %33, %2
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([316 x i8], [316 x i8]* @str, i64 0, i64 0))
br label %54
54: ; preds = %46, %49, %52
%55 = phi i32 [ 1, %52 ], [ 0, %49 ], [ 0, %46 ]
ret i32 %55
}