#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 getval();
int f2(double x) {
  unsigned short s;
  int a, b, c, d, e, f, g, h, i, j;
  a = getval();
  b = getval();
  c = getval();
  d = getval();
  e = getval();
  f = getval();
  g = getval();
  h = getval();
  i = getval();
  j = getval();
  s = x;
  return a + b + c + d + e + f + g + h + i + j + s;
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
xor    %eax,%eax
mov    %al,-0x35(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x10(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x14(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x18(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x1c(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x20(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x24(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x28(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x2c(%rbp)
call   1030 <getval@plt>
mov    %eax,%ecx
mov    -0x35(%rbp),%al
mov    %ecx,-0x30(%rbp)
call   1030 <getval@plt>
mov    %eax,-0x34(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %ax,-0xa(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
add    -0x34(%rbp),%eax
movzwl -0xa(%rbp),%ecx
add    %ecx,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1030 <getval@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1030 <getval@plt>
cvttsd2si 0x10(%rsp),%ecx
movzwl %cx,%ecx
add    0xc(%rsp),%ecx
add    0x8(%rsp),%ecx
add    0x4(%rsp),%ecx
add    %r13d,%ecx
add    %ebx,%ecx
add    %ebp,%ecx
add    %r14d,%ecx
add    %r15d,%ecx
add    %r12d,%ecx
add    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @f2(double %0) {
%2 = alloca double
%3 = alloca i16
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store double %0, double* %2
%14 = call i32 (...) @getval()
store i32 %14, i32* %4
%15 = call i32 (...) @getval()
store i32 %15, i32* %5
%16 = call i32 (...) @getval()
store i32 %16, i32* %6
%17 = call i32 (...) @getval()
store i32 %17, i32* %7
%18 = call i32 (...) @getval()
store i32 %18, i32* %8
%19 = call i32 (...) @getval()
store i32 %19, i32* %9
%20 = call i32 (...) @getval()
store i32 %20, i32* %10
%21 = call i32 (...) @getval()
store i32 %21, i32* %11
%22 = call i32 (...) @getval()
store i32 %22, i32* %12
%23 = call i32 (...) @getval()
store i32 %23, i32* %13
%24 = load double, double* %2
%25 = fptoui double %24 to i16
store i16 %25, i16* %3
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = add nsw i32 %26, %27
%29 = load i32, i32* %6
%30 = add nsw i32 %28, %29
%31 = load i32, i32* %7
%32 = add nsw i32 %30, %31
%33 = load i32, i32* %8
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %9
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %10
%38 = add nsw i32 %36, %37
%39 = load i32, i32* %11
%40 = add nsw i32 %38, %39
%41 = load i32, i32* %12
%42 = add nsw i32 %40, %41
%43 = load i32, i32* %13
%44 = add nsw i32 %42, %43
%45 = load i16, i16* %3
%46 = zext i16 %45 to i32
%47 = add nsw i32 %44, %46
ret i32 %47
}

LLVM IR (-O2):
define i32 @f2(double %0) {
%2 = tail call i32 (...) @getval()
%3 = tail call i32 (...) @getval()
%4 = tail call i32 (...) @getval()
%5 = tail call i32 (...) @getval()
%6 = tail call i32 (...) @getval()
%7 = tail call i32 (...) @getval()
%8 = tail call i32 (...) @getval()
%9 = tail call i32 (...) @getval()
%10 = tail call i32 (...) @getval()
%11 = tail call i32 (...) @getval()
%12 = fptoui double %0 to i16
%13 = zext i16 %12 to i32
%14 = add i32 %2, %13
%15 = add i32 %14, %3
%16 = add i32 %15, %4
%17 = add i32 %16, %5
%18 = add i32 %17, %6
%19 = add i32 %18, %7
%20 = add i32 %19, %8
%21 = add i32 %20, %9
%22 = add i32 %21, %10
%23 = add i32 %22, %11
ret i32 %23
}