#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*/ fsleep(float);
int /*<<< orphan*/ is_process_running(int);
int /*<<< orphan*/ kill_process(int);
int start_process(void *);
void run_for(float howLong, void(*funky)) {
  int pid = start_process(funky);
  while (howLong >= 1.0) {
    if (!is_process_running(pid))
      return;
    fsleep(1.0);
    howLong = howLong - 1.0;
  }
  fsleep(howLong);
  kill_process(pid);
  return;
}


x86 assembly (clang, -O0):
<run_for>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <start_process@plt>
mov    %eax,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe92(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11be <run_for+0x7e>
mov    -0x14(%rbp),%edi
call   1060 <is_process_running@plt>
cmp    $0x0,%eax
jne    118e <run_for+0x4e>
jmp    11d0 <run_for+0x90>
movss  0xe72(%rip),%xmm0
call   1050 <fsleep@plt>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe54(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    115d <run_for+0x1d>
movss  -0x4(%rbp),%xmm0
call   1050 <fsleep@plt>
mov    -0x14(%rbp),%edi
call   1040 <kill_process@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_for>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
call   1030 <start_process@plt>
movss  0xc(%rsp),%xmm0
mov    %eax,%ebx
ucomiss 0xea1(%rip),%xmm0
jb     11a5 <run_for+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
call   1060 <is_process_running@plt>
test   %eax,%eax
je     11b6 <run_for+0x76>
movss  0xe77(%rip),%xmm0
call   1050 <fsleep@plt>
movss  0xc(%rsp),%xmm0
addss  0xe68(%rip),%xmm0
ucomiss 0xe5d(%rip),%xmm0
jae    1170 <run_for+0x30>
call   1050 <fsleep@plt>
mov    %ebx,%edi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <kill_process@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @run_for(float %0, i8* %1) {
%3 = alloca float
%4 = alloca i8*
%5 = alloca i32
store float %0, float* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @start_process(i8* %6)
store i32 %7, i32* %5
br label %8
8: ; preds = %17, %2
%9 = load float, float* %3
%10 = fpext float %9 to double
%11 = fcmp oge double %10, 1.000000e+00
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load i32, i32* %5
%14 = call i32 @is_process_running(i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12
br label %28
17: ; preds = %12
%18 = call i32 @fsleep(float 1.000000e+00)
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = fsub double %20, 1.000000e+00
%22 = fptrunc double %21 to float
store float %22, float* %3
br label %8
23: ; preds = %8
%24 = load float, float* %3
%25 = call i32 @fsleep(float %24)
%26 = load i32, i32* %5
%27 = call i32 @kill_process(i32 %26)
br label %28
28: ; preds = %23, %16
ret void
}

LLVM IR (-O2):
define void @run_for(float %0, i8* %1) {
%3 = tail call i32 @start_process(i8* %1)
%4 = fcmp ult float %0, 1.000000e+00
br i1 %4, label %13, label %5
5: ; preds = %2, %9
%6 = phi float [ %11, %9 ], [ %0, %2 ]
%7 = tail call i32 @is_process_running(i32 %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %5
%10 = tail call i32 @fsleep(float 1.000000e+00)
%11 = fadd float %6, -1.000000e+00
%12 = fcmp ult float %11, 1.000000e+00
br i1 %12, label %13, label %5
13: ; preds = %9, %2
%14 = phi float [ %0, %2 ], [ %11, %9 ]
%15 = tail call i32 @fsleep(float %14)
%16 = tail call i32 @kill_process(i32 %3)
br label %17
17: ; preds = %5, %13
ret void
}