#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 {
  float tv_sec;
  float tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, float);
int sched_rr_get_interval(int /*<<< orphan*/, struct timespec *);
int main(void) {
  struct timespec tp;
  int interval;
  interval = sched_rr_get_interval(0, &tp);
  if (interval == -1) {
    perror("sched_rr_get_interval");
    return 1;
  }
  printf("Our time quantum is %.2lf milliseconds\n",
         (tp.tv_sec * 1000.0f) + (tp.tv_nsec / 1000000.0f));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
lea    -0x10(%rbp),%rsi
call   1040 <sched_rr_get_interval@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    116f <main+0x3f>
lea    0xeaa(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <main+0x71>
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  0xe83(%rip),%xmm2
divss  %xmm2,%xmm1
movss  0xe73(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1040 <sched_rr_get_interval@plt>
cmp    $0xffffffff,%eax
je     117c <main+0x4c>
movss  0xc(%rsp),%xmm1
divss  0xeaa(%rip),%xmm1
movss  0x8(%rsp),%xmm0
mulss  0xea0(%rip),%xmm0
addss  %xmm1,%xmm0
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe85(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%ebx
jmp    1174 <main+0x44>

LLVM IR (-O0):
%struct.timespec = type { float, float }
@.str = [22 x i8] c"sched_rr_get_interval\00"
@.str.1 = [40 x i8] c"Our time quantum is %.2lf milliseconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @sched_rr_get_interval(i32 0, %struct.timespec* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %17
9: ; preds = %0
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%11 = load float, float* %10
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%13 = load float, float* %12
%14 = fdiv float %13, 1.000000e+06
%15 = call float @llvm.fmuladd.f32(float %11, float 1.000000e+03, float %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), float %15)
br label %17
17: ; preds = %9, %7
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
%struct.timespec = type { float, float }
@.str = [22 x i8] c"sched_rr_get_interval\00"
@.str.1 = [40 x i8] c"Our time quantum is %.2lf milliseconds\0A\00"
define i32 @main() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = call i32 @sched_rr_get_interval(i32 0, %struct.timespec* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %15
7: ; preds = %0
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%9 = load float, float* %8
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%11 = load float, float* %10
%12 = fdiv float %11, 1.000000e+06
%13 = call float @llvm.fmuladd.f32(float %9, float 1.000000e+03, float %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), float %13)
br label %15
15: ; preds = %7, %5
%16 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %16
}