#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  long tv_sec;
  long tv_usec;
};
struct TYPE_4__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct itimerval {
  TYPE_1__ it_value;
  TYPE_2__ it_interval;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double modf(double, double *);
int /*<<< orphan*/ perror(char *);
int setitimer(int /*<<< orphan*/, struct itimerval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void SetTimeout(double timeout_secs) {
  if (timeout_secs <= 0) {
    return;
  }
  double int_val, fraction_val;
  fraction_val = modf(timeout_secs, &int_val);
  struct itimerval timer;
  timer.it_interval.tv_sec = 0;
  timer.it_interval.tv_usec = 0;
  timer.it_value.tv_sec = (long)int_val,
  timer.it_value.tv_usec = (long)(fraction_val * 1e6);
  if ((setitimer(ITIMER_REAL, &timer, NULL)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/"
                    "master/src/main/tools/process-tools.c"
                    ":"
                    "136"
                    ": ");
    perror("setitimer(ITIMER_REAL, &timer, NULL)");
    exit(EXIT_FAILURE);
  };
}


x86 assembly (clang, -O0):
<SetTimeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1170 <SetTimeout+0x20>
jmp    1201 <SetTimeout+0xb1>
movsd  -0x8(%rbp),%xmm0
lea    -0x10(%rbp),%rdi
call   1030 <modf@plt>
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cvttsd2si -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
movsd  0xe5b(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <setitimer@plt>
cmp    $0xffffffff,%eax
jne    1201 <SetTimeout+0xb1>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xeb7(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetTimeout>:
sub    $0x28,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    11a7 <SetTimeout+0x57>
mov    %rsp,%rdi
call   1030 <modf@plt>
xorpd  %xmm1,%xmm1
movupd %xmm1,0x18(%rsp)
cvttsd2si (%rsp),%rax
mulsd  0xe82(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rax,0x8(%rsp)
mov    %rcx,0x10(%rsp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1050 <setitimer@plt>
cmp    $0xffffffff,%eax
je     11ac <SetTimeout+0x5c>
add    $0x28,%rsp
ret
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xedd(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i64, i64 }
%struct.TYPE_4__ = type { i64, i64 }
@ITIMER_REAL = global i32 0
@stderr = global i32 0
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/master/src/main/tools/process-tools.c:136: \00"
@.str.1 = [37 x i8] c"setitimer(ITIMER_REAL, &timer, NULL)\00"
@EXIT_FAILURE = global i32 0
define void @SetTimeout(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca %struct.itimerval
store double %0, double* %2
%6 = load double, double* %2
%7 = fcmp ole double %6, 0.000000e+00
br i1 %7, label %8, label %9
8: ; preds = %1
br label %34
9: ; preds = %1
%10 = load double, double* %2
%11 = call double @modf(double %10, double* %3)
store double %11, double* %4
%12 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 1
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 0
store i64 0, i64* %15
%16 = load double, double* %3
%17 = fptosi double %16 to i64
%18 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
store i64 %17, i64* %19
%20 = load double, double* %4
%21 = fmul double %20, 1.000000e+06
%22 = fptosi double %21 to i64
%23 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 1
store i64 %22, i64* %24
%25 = load i32, i32* @ITIMER_REAL
%26 = call i32 @setitimer(i32 %25, %struct.itimerval* %5, i32* null)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %34
28: ; preds = %9
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %8, %9
ret void
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i64, i64 }
%struct.TYPE_4__ = type { i64, i64 }
@ITIMER_REAL = global i32 0
@stderr = global i32 0
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Asana/bazel/refs/heads/master/src/main/tools/process-tools.c:136: \00"
@.str.1 = [37 x i8] c"setitimer(ITIMER_REAL, &timer, NULL)\00"
@EXIT_FAILURE = global i32 0
define void @SetTimeout(double %0) {
%2 = alloca double
%3 = alloca %struct.itimerval
%4 = fcmp ugt double %0, 0.000000e+00
br i1 %4, label %5, label %27
5: ; preds = %1
%6 = bitcast double* %2 to i8*
%7 = call double @modf(double %0, double* %2)
%8 = bitcast %struct.itimerval* %3 to i8*
%9 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 1, i32 0
%10 = bitcast i64* %9 to i8*
%11 = load double, double* %2
%12 = fptosi double %11 to i64
%13 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 0, i32 0
store i64 %12, i64* %13
%14 = fmul double %7, 1.000000e+06
%15 = fptosi double %14 to i64
%16 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 0, i32 1
store i64 %15, i64* %16
%17 = load i32, i32* @ITIMER_REAL
%18 = call i32 @setitimer(i32 %17, %struct.itimerval* %3, i32* null)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %5
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %5
br label %27
27: ; preds = %1, %26
ret void
}