#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 */
scalar_t__ is_bouncy(int);
int /*<<< orphan*/ printf(char *, int, float);
int main(void) {
  int i = 0;
  int n = 0;
  while (true) {
    if (is_bouncy(i))
      n++;
    if ((float)n / (float)i >= 0.99)
      break;
    i++;
  }
  printf("number of bouncy numbers from 0 to %d: %d\n", i, n);
  printf("percentage of bouncy numbers from 0 to %d: %f\n", i,
         (float)n / (float)i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <is_bouncy@plt>
cmp    $0x0,%rax
je     1158 <main+0x38>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1181 <main+0x61>
jmp    118f <main+0x6f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0x8(%rbp),%esi
cvtsi2ssl -0xc(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
mov    $0xffffffff,%ebx
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %ebx,%edi
call   1040 <is_bouncy@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movaps %xmm0,%xmm2
divss  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
ucomisd 0xe9b(%rip),%xmm1
jb     1130 <main+0x10>
lea    0xe9a(%rip),%rdi
mov    %ebx,%esi
movss  %xmm2,0x4(%rsp)
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %ebx,%esi
movss  0x4(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"number of bouncy numbers from 0 to %d: %d\0A\00"
@.str.1 = [47 x i8] c"percentage of bouncy numbers from 0 to %d: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %0, %20
%5 = load i32, i32* %2
%6 = call i64 @is_bouncy(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %4
%12 = load i32, i32* %3
%13 = sitofp i32 %12 to float
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to float
%16 = fdiv float %13, %15
%17 = fpext float %16 to double
%18 = fcmp oge double %17, 0x3FEFAE147AE147AE
br i1 %18, label %19, label %20
19: ; preds = %11
br label %23
20: ; preds = %11
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %4
23: ; preds = %19
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = sitofp i32 %25 to float
%27 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %24, float %26)
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = sitofp i32 %29 to float
%31 = load i32, i32* %2
%32 = sitofp i32 %31 to float
%33 = fdiv float %30, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %28, float %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"number of bouncy numbers from 0 to %d: %d\0A\00"
@.str.1 = [47 x i8] c"percentage of bouncy numbers from 0 to %d: %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %13, %1 ]
%3 = phi i32 [ 0, %0 ], [ %7, %1 ]
%4 = tail call i64 @is_bouncy(i32 %2)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i32
%7 = add nuw nsw i32 %3, %6
%8 = sitofp i32 %7 to float
%9 = sitofp i32 %2 to float
%10 = fdiv float %8, %9
%11 = fpext float %10 to double
%12 = fcmp ult double %11, 0x3FEFAE147AE147AE
%13 = add nuw nsw i32 %2, 1
br i1 %12, label %1, label %14
14: ; preds = %1
%15 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %2, float %8)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, float %10)
ret i32 0
}