#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 INT_MAX;
int rand();
int pick_dist(int u) {
  int v;
  v = (int)((u + 0.99999999999) * rand() / INT_MAX);
  u = (int)((v + 0.99999999999) * rand() / INT_MAX);
  return ((int)((u + 0.99999999999) * rand() / INT_MAX));
}


x86 assembly (clang, -O0):
<pick_dist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xed8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e9c(%rip),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe98(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e5c(%rip),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movsd  -0x10(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e1c(%rip),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pick_dist>:
push   %rbx
sub    $0x10,%rsp
cvtsi2sd %edi,%xmm0
addsd  0xedf(%rip),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x2ead(%rip),%rbx
cvtsi2sdl (%rbx),%xmm1
mulsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
addsd  0xea8(%rip),%xmm0
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%rbx),%xmm1
mulsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
addsd  0xe75(%rip),%xmm0
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%rbx),%xmm1
mulsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32 @pick_dist(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sitofp i32 %4 to double
%6 = fadd double %5, 0x3FEFFFFFFFFEA028
%7 = call i32 (...) @rand()
%8 = sitofp i32 %7 to double
%9 = fmul double %6, %8
%10 = load i32, i32* @INT_MAX
%11 = sitofp i32 %10 to double
%12 = fdiv double %9, %11
%13 = fptosi double %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = fadd double %15, 0x3FEFFFFFFFFEA028
%17 = call i32 (...) @rand()
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
%20 = load i32, i32* @INT_MAX
%21 = sitofp i32 %20 to double
%22 = fdiv double %19, %21
%23 = fptosi double %22 to i32
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = sitofp i32 %24 to double
%26 = fadd double %25, 0x3FEFFFFFFFFEA028
%27 = call i32 (...) @rand()
%28 = sitofp i32 %27 to double
%29 = fmul double %26, %28
%30 = load i32, i32* @INT_MAX
%31 = sitofp i32 %30 to double
%32 = fdiv double %29, %31
%33 = fptosi double %32 to i32
ret i32 %33
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32 @pick_dist(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fadd double %2, 0x3FEFFFFFFFFEA028
%4 = tail call i32 (...) @rand()
%5 = sitofp i32 %4 to double
%6 = fmul double %3, %5
%7 = load i32, i32* @INT_MAX
%8 = sitofp i32 %7 to double
%9 = fdiv double %6, %8
%10 = fptosi double %9 to i32
%11 = sitofp i32 %10 to double
%12 = fadd double %11, 0x3FEFFFFFFFFEA028
%13 = tail call i32 (...) @rand()
%14 = sitofp i32 %13 to double
%15 = fmul double %12, %14
%16 = load i32, i32* @INT_MAX
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
%19 = fptosi double %18 to i32
%20 = sitofp i32 %19 to double
%21 = fadd double %20, 0x3FEFFFFFFFFEA028
%22 = tail call i32 (...) @rand()
%23 = sitofp i32 %22 to double
%24 = fmul double %21, %23
%25 = load i32, i32* @INT_MAX
%26 = sitofp i32 %25 to double
%27 = fdiv double %24, %26
%28 = fptosi double %27 to i32
ret i32 %28
}