#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*/ add_task(char *, unsigned int, float);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
float parse_time(char *);
int /*<<< orphan*/ stderr;
char *strtok(char *, char const *);
void parse_sched_entry(char *line) {
  char *name;
  unsigned int period;
  float len;
  const char *delims = " \t\n";
  name = strtok(line, delims);
  if (!name || *name == '#')
    return;
  period = (unsigned int)parse_time(strtok(NULL, delims));
  if (period & (period - 1)) {
    fprintf(stderr,
            "error: invalid period '%d' for '%s' (must be power of 2)\n",
            period, name);
    exit(1);
  }
  len = parse_time(strtok(NULL, delims));
  if (len >= period) {
    fprintf(stderr, "error: '%s' has length greater than its period\n", name);
    exit(1);
  }
  add_task(name, period, len);
}


x86 assembly (clang, -O0):
<parse_sched_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1193 <parse_sched_entry+0x43>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1198 <parse_sched_entry+0x48>
jmp    1257 <parse_sched_entry+0x107>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,%rdi
call   1030 <parse_time@plt>
cvttss2si %xmm0,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11f1 <parse_sched_entry+0xa1>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,%rdi
call   1030 <parse_time@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2ss %rax,%xmm1
ucomiss %xmm1,%xmm0
jb     1246 <parse_sched_entry+0xf6>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movss  -0x18(%rbp),%xmm0
call   1040 <add_task@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_sched_entry>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     116d <parse_sched_entry+0x1d>
mov    %rax,%rbx
cmpb   $0x23,(%rax)
jne    1175 <parse_sched_entry+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe84(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
mov    %rax,%rdi
call   1030 <parse_time@plt>
cvttss2si %xmm0,%r14
lea    -0x1(%r14),%eax
test   %eax,%r14d
jne    11ce <parse_sched_entry+0x7e>
lea    0xe60(%rip),%rsi
xor    %edi,%edi
call   1060 <strtok@plt>
mov    %rax,%rdi
call   1030 <parse_time@plt>
mov    %r14d,%eax
cvtsi2ss %rax,%xmm1
ucomiss %xmm1,%xmm0
jae    11f5 <parse_sched_entry+0xa5>
mov    %rbx,%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <add_task@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
@stderr = global i32 0
@.str.1 = [58 x i8] c"error: invalid period '%d' for '%s' (must be power of 2)\0A\00"
@.str.2 = [48 x i8] c"error: '%s' has length greater than its period\0A\00"
define void @parse_sched_entry(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca float
%6 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %2
%8 = load i8*, i8** %6
%9 = call i8* @strtok(i8* %7, i8* %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 35
br i1 %16, label %17, label %18
17: ; preds = %12, %1
br label %52
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = call i8* @strtok(i8* null, i8* %19)
%21 = call float @parse_time(i8* %20)
%22 = fptoui float %21 to i32
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = load i32, i32* %4
%25 = sub i32 %24, 1
%26 = and i32 %23, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %18
%29 = load i32, i32* @stderr
%30 = load i32, i32* %4
%31 = load i8*, i8** %3
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %18
%35 = load i8*, i8** %6
%36 = call i8* @strtok(i8* null, i8* %35)
%37 = call float @parse_time(i8* %36)
store float %37, float* %5
%38 = load float, float* %5
%39 = load i32, i32* %4
%40 = uitofp i32 %39 to float
%41 = fcmp oge float %38, %40
br i1 %41, label %42, label %47
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %3
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %34
%48 = load i8*, i8** %3
%49 = load i32, i32* %4
%50 = load float, float* %5
%51 = call i32 @add_task(i8* %48, i32 %49, float %50)
br label %52
52: ; preds = %47, %17
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
@stderr = global i32 0
@.str.1 = [58 x i8] c"error: invalid period '%d' for '%s' (must be power of 2)\0A\00"
@.str.2 = [48 x i8] c"error: '%s' has length greater than its period\0A\00"
define void @parse_sched_entry(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %28, label %4
4: ; preds = %1
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 35
br i1 %6, label %28, label %7
7: ; preds = %4
%8 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = tail call float @parse_time(i8* %8)
%10 = fptoui float %9 to i32
%11 = tail call i32 @llvm.ctpop.i32(i32 %10)
%12 = icmp ult i32 %11, 2
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %2)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %7
%18 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = tail call float @parse_time(i8* %18)
%20 = uitofp i32 %10 to float
%21 = fcmp ult float %19, %20
br i1 %21, label %26, label %22
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17
%27 = tail call i32 @add_task(i8* %2, i32 %10, float %19)
br label %28
28: ; preds = %1, %4, %26
ret void
}