#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 rand();
float foo(int a) {
  float b;
  int i;
  b = ((float)(rand() % 65536)) / ((float)(rand() % 65536));
  for (i = 0; i < 100; i++)
    b /= a;
  return b;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x10000,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movss  -0x10(%rbp),%xmm0
mov    $0x10000,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    1186 <foo+0x76>
cvtsi2ssl -0x4(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <foo+0x4b>
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
movss  0xc(%rsp),%xmm0
lea    0xffff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffff0000,%ecx
sub    %ecx,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
mov    $0x64,%eax
nop
divss  %xmm1,%xmm0
divss  %xmm1,%xmm0
divss  %xmm1,%xmm0
divss  %xmm1,%xmm0
divss  %xmm1,%xmm0
add    $0xfffffffb,%eax
jne    1170 <foo+0x60>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @foo(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @rand()
%6 = srem i32 %5, 65536
%7 = sitofp i32 %6 to float
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 65536
%10 = sitofp i32 %9 to float
%11 = fdiv float %7, %10
store float %11, float* %3
store i32 0, i32* %4
br label %12
12: ; preds = %20, %1
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 100
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i32, i32* %2
%17 = sitofp i32 %16 to float
%18 = load float, float* %3
%19 = fdiv float %18, %17
store float %19, float* %3
br label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %12
23: ; preds = %12
%24 = load float, float* %3
ret float %24
}

LLVM IR (-O2):
define float @foo(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 65536
%4 = sitofp i32 %3 to float
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 65536
%7 = sitofp i32 %6 to float
%8 = fdiv float %4, %7
%9 = sitofp i32 %0 to float
br label %10
10: ; preds = %10, %1
%11 = phi i32 [ 0, %1 ], [ %18, %10 ]
%12 = phi float [ %8, %1 ], [ %17, %10 ]
%13 = fdiv float %12, %9
%14 = fdiv float %13, %9
%15 = fdiv float %14, %9
%16 = fdiv float %15, %9
%17 = fdiv float %16, %9
%18 = add nuw nsw i32 %11, 5
%19 = icmp eq i32 %18, 100
br i1 %19, label %20, label %10
20: ; preds = %10
ret float %17
}