#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 */
typedef int /*<<< orphan*/ traffic;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
double data_traffic_func(double x, void *params) {
  double traffic[] = {
      3.2, 2.7, 1.9, 1.7, 1.3, 1.0, 1.1, 1.3, 2.8, 5.7, 7.1, 7.7, 7.9,
  };
  int hour = (int)(x / 3600.0);
  (void)params;
  assert(hour >= 0 && hour < (sizeof(traffic) / sizeof(traffic[0])));
  return traffic[hour];
}


x86 assembly (clang, -O0):
<data_traffic_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xed1(%rip),%rsi
mov    $0x68,%edx
call   1040 <memcpy@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x84(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x84(%rbp)
mov    %al,-0x85(%rbp)
jl     118d <data_traffic_func+0x6d>
movslq -0x84(%rbp),%rax
cmp    $0xd,%rax
setb   %al
mov    %al,-0x85(%rbp)
mov    -0x85(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0x84(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_traffic_func>:
push   %rbx
divsd  0xee7(%rip),%xmm0
cvttsd2si %xmm0,%eax
movslq %eax,%rbx
xor    %edi,%edi
cmp    $0xd,%ebx
setb   %dil
call   1030 <assert@plt>
lea    0xedb(%rip),%rax
movsd  (%rax,%rbx,8),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
@__const.data_traffic_func.traffic = [13 x double] [double 3.200000e+00, double 2.700000e+00, double 1.900000e+00, double 1.700000e+00, double 1.300000e+00, double 1.000000e+00, double 1.100000e+00, double 1.300000e+00, double 2.800000e+00, double 5.700000e+00, double 7.100000e+00, double 7.700000e+00, double 7.900000e+00]
define double @data_traffic_func(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca [13 x double]
%6 = alloca i32
store double %0, double* %3
store i8* %1, i8** %4
%7 = bitcast [13 x double]* %5 to i8*
%8 = load double, double* %3
%9 = fdiv double %8, 3.600000e+03
%10 = fptosi double %9 to i32
store i32 %10, i32* %6
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = icmp ult i64 %16, 13
br label %18
18: ; preds = %14, %2
%19 = phi i1 [ false, %2 ], [ %17, %14 ]
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [13 x double], [13 x double]* %5, i64 0, i64 %23
%25 = load double, double* %24
ret double %25
}

LLVM IR (-O2):
@__const.data_traffic_func.traffic = [13 x double] [double 3.200000e+00, double 2.700000e+00, double 1.900000e+00, double 1.700000e+00, double 1.300000e+00, double 1.000000e+00, double 1.100000e+00, double 1.300000e+00, double 2.800000e+00, double 5.700000e+00, double 7.100000e+00, double 7.700000e+00, double 7.900000e+00]
define double @data_traffic_func(double %0, i8* nocapture readnone %1) {
%3 = fdiv double %0, 3.600000e+03
%4 = fptosi double %3 to i32
%5 = sext i32 %4 to i64
%6 = icmp ult i32 %4, 13
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = getelementptr inbounds [13 x double], [13 x double]* @__const.data_traffic_func.traffic, i64 0, i64 %5
%10 = load double, double* %9
ret double %10
}