#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 */
struct timespec {
  int dummy;
};

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int nanosleep(struct timespec *, struct timespec *);
int /*<<< orphan*/ stderr;
char *strtotimespec(char *, struct timespec *);
int main(int argc, char *argv[]) {
  struct timespec ts;
  char *p;
  if (argc != 2)
    goto err;
  p = strtotimespec(argv[1], &ts);
  if (*p)
    goto err;
  while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
    ;
  return 0;
err:
  fprintf(stderr, "Usage: %s seconds[.fraction]\n", argv[0]);
  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)
cmpl   $0x2,-0x8(%rbp)
je     1155 <main+0x25>
jmp    11d8 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <strtotimespec@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     117c <main+0x4c>
jmp    11d8 <main+0xa8>
jmp    1181 <main+0x51>
lea    -0x18(%rbp),%rsi
mov    %rsi,%rdi
call   1030 <nanosleep@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x21(%rbp)
jne    11b7 <main+0x87>
mov    0x2e34(%rip),%rax
mov    (%rax),%rax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11c7 <main+0x97>
jmp    11cc <main+0x9c>
jmp    1181 <main+0x51>
movl   $0x0,-0x4(%rbp)
jmp    11fb <main+0xcb>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe11(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1154 <main+0x24>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1050 <strtotimespec@plt>
cmpb   $0x0,(%rax)
je     117b <main+0x4b>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0x8(%rsp),%rbx
mov    0x2e51(%rip),%r14
mov    0x2e42(%rip),%r15
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <nanosleep@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    1171 <main+0x41>
mov    (%r15),%rcx
cmp    %rcx,(%r14)
je     1190 <main+0x60>
jmp    1171 <main+0x41>

LLVM IR (-O0):
%struct.timespec = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s seconds[.fraction]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
br label %32
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i8* @strtotimespec(i8* %14, %struct.timespec* %6)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %11
br label %32
20: ; preds = %11
br label %21
21: ; preds = %30, %20
%22 = call i32 @nanosleep(%struct.timespec* %6, %struct.timespec* %6)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i64, i64* @errno
%26 = load i64, i64* @EINTR
%27 = icmp eq i64 %25, %26
br label %28
28: ; preds = %24, %21
%29 = phi i1 [ false, %21 ], [ %27, %24 ]
br i1 %29, label %30, label %31
30: ; preds = %28
br label %21
31: ; preds = %28
store i32 0, i32* %3
br label %38
32: ; preds = %19, %10
%33 = load i32, i32* @stderr
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %36)
store i32 1, i32* %3
br label %38
38: ; preds = %32, %31
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s seconds[.fraction]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %19
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i8* @strtotimespec(i8* %8, %struct.timespec* %3)
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %6, %12
%13 = call i32 @nanosleep(%struct.timespec* %3, %struct.timespec* %3)
%14 = icmp eq i32 %13, -1
%15 = load i64, i64* @errno
%16 = load i64, i64* @EINTR
%17 = icmp eq i64 %15, %16
%18 = select i1 %14, i1 %17, i1 false
br i1 %18, label %12, label %23
19: ; preds = %6, %2
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %12, %19
%24 = phi i32 [ 1, %19 ], [ 0, %12 ]
ret i32 %24
}