#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 */
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
int main(void) {
  double delay_sec = 2;
  int delay_us = delay_sec * 1000000;
  double num_steps = 10;
  double pmax = 35;
  double pmin = 20;
  double step_height = (pmax - pmin) / num_steps;
  int i;
  struct timespec tv;
  char time_buffer[32];
  for (i = 0; i < num_steps + 1; i++) {
    fprintf(stdout, "s%.2f\n", pmin);
    usleep(delay_us);
    fprintf(stdout, "s%.2f\n", (double)i * step_height + pmin);
    usleep(delay_us);
  }
  fprintf(stdout, "quit pwrtest.c\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xee9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed4(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm1
movsd  0xe89(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1216 <main+0xf6>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
movsd  -0x30(%rbp),%xmm0
lea    0xe6d(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1040 <usleep@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xe37(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1040 <usleep@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1192 <main+0x72>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xb,%ebp
mov    0x2ea2(%rip),%r14
lea    0xed3(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14),%edi
mov    %rbx,%rsi
movsd  0xea2(%rip),%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    $0x1e8480,%edi
call   1040 <usleep@plt>
mov    (%r14),%edi
movsd  0x8(%rsp),%xmm0
mulsd  0xe88(%rip),%xmm0
addsd  0xe78(%rip),%xmm0
mov    %rbx,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    $0x1e8480,%edi
call   1040 <usleep@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe66(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0xffffffff,%ebp
jne    1150 <main+0x30>
mov    (%r14),%edi
lea    0xe60(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@stdout = global i32 0
@.str = [7 x i8] c"s%.2f\0A\00"
@.str.1 = [16 x i8] c"quit pwrtest.c\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca %struct.timespec
%10 = alloca [32 x i8]
store i32 0, i32* %1
store double 2.000000e+00, double* %2
%11 = load double, double* %2
%12 = fmul double %11, 1.000000e+06
%13 = fptosi double %12 to i32
store i32 %13, i32* %3
store double 1.000000e+01, double* %4
store double 3.500000e+01, double* %5
store double 2.000000e+01, double* %6
%14 = load double, double* %5
%15 = load double, double* %6
%16 = fsub double %14, %15
%17 = load double, double* %4
%18 = fdiv double %16, %17
store double %18, double* %7
store i32 0, i32* %8
br label %19
19: ; preds = %40, %0
%20 = load i32, i32* %8
%21 = sitofp i32 %20 to double
%22 = load double, double* %4
%23 = fadd double %22, 1.000000e+00
%24 = fcmp olt double %21, %23
br i1 %24, label %25, label %43
25: ; preds = %19
%26 = load i32, i32* @stdout
%27 = load double, double* %6
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %27)
%29 = load i32, i32* %3
%30 = call i32 @usleep(i32 %29)
%31 = load i32, i32* @stdout
%32 = load i32, i32* %8
%33 = sitofp i32 %32 to double
%34 = load double, double* %7
%35 = load double, double* %6
%36 = call double @llvm.fmuladd.f64(double %33, double %34, double %35)
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %36)
%38 = load i32, i32* %3
%39 = call i32 @usleep(i32 %38)
br label %40
40: ; preds = %25
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %19
43: ; preds = %19
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [7 x i8] c"s%.2f\0A\00"
@.str.1 = [16 x i8] c"quit pwrtest.c\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %11, %1 ]
%3 = sitofp i32 %2 to double
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double 2.000000e+01)
%6 = tail call i32 @usleep(i32 2000000)
%7 = load i32, i32* @stdout
%8 = tail call double @llvm.fmuladd.f64(double %3, double 1.500000e+00, double 2.000000e+01)
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %8)
%10 = tail call i32 @usleep(i32 2000000)
%11 = add nuw nsw i32 %2, 1
%12 = icmp eq i32 %11, 11
br i1 %12, label %13, label %1
13: ; preds = %1
%14 = load i32, i32* @stdout
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}