#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*/ assert(int);
double ceil(double);
int /*<<< orphan*/ printf(char *, ...);
double sample(double t0, double t1, double t2, double t3, double s) {
  double t;
  assert(t0 <= t2 && t2 <= t1);
  assert(t0 <= t3 && t3 <= t1);
  printf("[t0, t1]\n");
  for (t = t0; t <= t1; t += s)
    printf("%.3f ", t);
  printf("\n");
  printf("[t2, t3]\n");
  t = ceil((t2 - t0) / s);
  for (t = t0 + s * t; t <= t3; t += s)
    printf("%.3f ", t);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<sample>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x31(%rbp)
jb     117e <sample+0x4e>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x32(%rbp)
jb     11b8 <sample+0x88>
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1218 <sample+0xe8>
movsd  -0x30(%rbp),%xmm0
lea    0xe0d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11dd <sample+0xad>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
call   1030 <ceil@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12a4 <sample+0x174>
movsd  -0x30(%rbp),%xmm0
lea    0xd81(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1269 <sample+0x139>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm0,0x8(%rsp)
ucomisd %xmm0,%xmm2
movsd  %xmm1,0x18(%rsp)
setae  %al
movsd  %xmm2,0x28(%rsp)
ucomisd %xmm2,%xmm1
movsd  %xmm4,0x10(%rsp)
movsd  %xmm3,0x20(%rsp)
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1070 <assert@plt>
movsd  0x20(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
setae  %al
movsd  0x18(%rsp),%xmm0
ucomisd %xmm1,%xmm0
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1070 <assert@plt>
lea    0xe4e(%rip),%rdi
call   1040 <puts@plt>
movsd  0x18(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
jb     1206 <sample+0xb6>
lea    0xe2e(%rip),%rbx
movsd  0x8(%rsp),%xmm0
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  (%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jae    11e0 <sample+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf8(%rip),%rdi
call   1040 <puts@plt>
movsd  0x28(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
call   1050 <ceil@plt>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     1299 <sample+0x149>
lea    0xda6(%rip),%rbx
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,(%rsp)
mov    %rbx,%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x20(%rsp),%xmm1
ucomisd (%rsp),%xmm1
movsd  (%rsp),%xmm1
jae    1260 <sample+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
xorpd  %xmm0,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"[t0, t1]\0A\00"
@.str.1 = [6 x i8] c"%.3f \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [10 x i8] c"[t2, t3]\0A\00"
define double @sample(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%12 = load double, double* %6
%13 = load double, double* %8
%14 = fcmp ole double %12, %13
br i1 %14, label %15, label %19
15: ; preds = %5
%16 = load double, double* %8
%17 = load double, double* %7
%18 = fcmp ole double %16, %17
br label %19
19: ; preds = %15, %5
%20 = phi i1 [ false, %5 ], [ %18, %15 ]
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load double, double* %6
%24 = load double, double* %9
%25 = fcmp ole double %23, %24
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = load double, double* %9
%28 = load double, double* %7
%29 = fcmp ole double %27, %28
br label %30
30: ; preds = %26, %19
%31 = phi i1 [ false, %19 ], [ %29, %26 ]
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%35 = load double, double* %6
store double %35, double* %11
br label %36
36: ; preds = %43, %30
%37 = load double, double* %11
%38 = load double, double* %7
%39 = fcmp ole double %37, %38
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = load double, double* %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %41)
br label %43
43: ; preds = %40
%44 = load double, double* %10
%45 = load double, double* %11
%46 = fadd double %45, %44
store double %46, double* %11
br label %36
47: ; preds = %36
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%50 = load double, double* %8
%51 = load double, double* %6
%52 = fsub double %50, %51
%53 = load double, double* %10
%54 = fdiv double %52, %53
%55 = call double @llvm.ceil.f64(double %54)
store double %55, double* %11
%56 = load double, double* %6
%57 = load double, double* %10
%58 = load double, double* %11
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double %56)
store double %59, double* %11
br label %60
60: ; preds = %67, %47
%61 = load double, double* %11
%62 = load double, double* %9
%63 = fcmp ole double %61, %62
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = load double, double* %11
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %65)
br label %67
67: ; preds = %64
%68 = load double, double* %10
%69 = load double, double* %11
%70 = fadd double %69, %68
store double %70, double* %11
br label %60
71: ; preds = %60
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret double 0.000000e+00
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%.3f \00"
@str = [9 x i8] c"[t0, t1]\00"
@str.4 = [9 x i8] c"[t2, t3]\00"
define double @sample(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp ole double %0, %2
%7 = fcmp ole double %2, %1
%8 = and i1 %6, %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = fcmp ole double %0, %3
%12 = fcmp ole double %3, %1
%13 = and i1 %11, %12
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%17 = fcmp ugt double %0, %1
br i1 %17, label %23, label %18
18: ; preds = %5, %18
%19 = phi double [ %21, %18 ], [ %0, %5 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = fadd double %19, %4
%22 = fcmp ugt double %21, %1
br i1 %22, label %23, label %18
23: ; preds = %18, %5
%24 = tail call i32 @putchar(i32 10)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0))
%26 = fsub double %2, %0
%27 = fdiv double %26, %4
%28 = tail call double @llvm.ceil.f64(double %27)
%29 = tail call double @llvm.fmuladd.f64(double %4, double %28, double %0)
%30 = fcmp ugt double %29, %3
br i1 %30, label %36, label %31
31: ; preds = %23, %31
%32 = phi double [ %34, %31 ], [ %29, %23 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %32)
%34 = fadd double %32, %4
%35 = fcmp ugt double %34, %3
br i1 %35, label %36, label %31
36: ; preds = %31, %23
%37 = tail call i32 @putchar(i32 10)
ret double 0.000000e+00
}