#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 */
float g_random(double, double);
int /*<<< orphan*/ printf(char *, ...);
void test() {
  float sum = 0;
  float t_sum = 0;
  int i = 0, j = 0;
  for (i = 0; i < 10; i++) {
    j++;
    if (i == 9) {
      printf("%d: %.2f\n", j, 100.0 - sum);
      break;
    }
    float f = g_random(6.0, 12.0);
    sum += f;
    t_sum = 100.0 - sum;
    if (t_sum < 0 || (9 - i) * 6 > t_sum || (9 - i) * 12 < t_sum) {
      i--;
    } else {
      printf("J: %d, i: %d, : %.2f, sum: %.2f, t_sum:%.2f\n", j, i, f, sum,
             t_sum);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    126f <test+0x14f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x9,-0xc(%rbp)
jne    1195 <test+0x75>
mov    -0x10(%rbp),%esi
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe82(%rip),%xmm0
subsd  %xmm1,%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    126f <test+0x14f>
movsd  0xe6b(%rip),%xmm0
movsd  0xe6b(%rip),%xmm1
call   1040 <g_random@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe31(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
ja     121f <test+0xff>
mov    $0x9,%eax
sub    -0xc(%rbp),%eax
imul   $0x6,%eax,%eax
cvtsi2ss %eax,%xmm0
ucomiss -0x8(%rbp),%xmm0
ja     121f <test+0xff>
mov    $0x9,%eax
sub    -0xc(%rbp),%eax
imul   $0xc,%eax,%eax
cvtsi2ss %eax,%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    122d <test+0x10d>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    125c <test+0x13c>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x8(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdcd(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1261 <test+0x141>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <test+0x2d>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
mov    $0x1,%ebx
lea    0xee4(%rip),%r14
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
jmp    1172 <test+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
add    $0x1,%ebp
add    $0x1,%ebx
cmp    $0x9,%ebp
je     1208 <test+0xd8>
movsd  0xe86(%rip),%xmm0
movsd  0xe86(%rip),%xmm1
call   1050 <g_random@plt>
movss  0x4(%rsp),%xmm2
addss  %xmm0,%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm2,%xmm3
movss  0xe78(%rip),%xmm1
movss  %xmm2,0x4(%rsp)
subss  %xmm2,%xmm1
xorps  %xmm2,%xmm2
ucomiss %xmm1,%xmm2
movsd  %xmm3,0x8(%rsp)
ja     1160 <test+0x30>
mov    $0x9,%eax
sub    %ebp,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,2),%ecx
xorps  %xmm2,%xmm2
cvtsi2ss %ecx,%xmm2
ucomiss %xmm1,%xmm2
ja     1160 <test+0x30>
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
ucomiss %xmm2,%xmm1
ja     1160 <test+0x30>
cvtss2sd %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm1,%xmm2
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
movaps %xmm3,%xmm1
mov    $0x3,%al
call   1040 <printf@plt>
jmp    1163 <test+0x33>
movsd  0xe00(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xe03(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%d: %.2f\0A\00"
@.str.1 = [45 x i8] c"J: %d, i: %d, : %.2f, sum: %.2f, t_sum:%.2f\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @test() {
%1 = alloca float
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store float 0.000000e+00, float* %1
store float 0.000000e+00, float* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %59, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %62
9: ; preds = %6
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
store i32 %11, i32* %4
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 9
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* %4
%16 = load float, float* %1
%17 = fpext float %16 to double
%18 = fsub double 1.000000e+02, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %15, double %18)
br label %62
20: ; preds = %9
%21 = call float @g_random(double 6.000000e+00, double 1.200000e+01)
store float %21, float* %5
%22 = load float, float* %5
%23 = load float, float* %1
%24 = fadd float %23, %22
store float %24, float* %1
%25 = load float, float* %1
%26 = fpext float %25 to double
%27 = fsub double 1.000000e+02, %26
%28 = fptrunc double %27 to float
store float %28, float* %2
%29 = load float, float* %2
%30 = fcmp olt float %29, 0.000000e+00
br i1 %30, label %45, label %31
31: ; preds = %20
%32 = load i32, i32* %3
%33 = sub nsw i32 9, %32
%34 = mul nsw i32 %33, 6
%35 = sitofp i32 %34 to float
%36 = load float, float* %2
%37 = fcmp ogt float %35, %36
br i1 %37, label %45, label %38
38: ; preds = %31
%39 = load i32, i32* %3
%40 = sub nsw i32 9, %39
%41 = mul nsw i32 %40, 12
%42 = sitofp i32 %41 to float
%43 = load float, float* %2
%44 = fcmp olt float %42, %43
br i1 %44, label %45, label %48
45: ; preds = %38, %31, %20
%46 = load i32, i32* %3
%47 = add nsw i32 %46, -1
store i32 %47, i32* %3
br label %58
48: ; preds = %38
%49 = load i32, i32* %4
%50 = load i32, i32* %3
%51 = load float, float* %5
%52 = fpext float %51 to double
%53 = load float, float* %1
%54 = fpext float %53 to double
%55 = load float, float* %2
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %50, double %52, double %54, double %56)
br label %58
58: ; preds = %48, %45
br label %59
59: ; preds = %58
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %6
62: ; preds = %14, %6
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d: %.2f\0A\00"
@.str.1 = [45 x i8] c"J: %d, i: %d, : %.2f, sum: %.2f, t_sum:%.2f\0A\00"
define void @test() {
br label %1
1: ; preds = %0, %25
%2 = phi i32 [ 1, %0 ], [ %28, %25 ]
%3 = phi float [ 0.000000e+00, %0 ], [ %6, %25 ]
%4 = phi i32 [ 0, %0 ], [ %27, %25 ]
%5 = tail call float @g_random(double 6.000000e+00, double 1.200000e+01)
%6 = fadd float %3, %5
%7 = fpext float %6 to double
%8 = fsub float 1.000000e+02, %6
%9 = fcmp olt float %8, 0.000000e+00
br i1 %9, label %19, label %10
10: ; preds = %1
%11 = sub nsw i32 9, %4
%12 = mul nsw i32 %11, 6
%13 = sitofp i32 %12 to float
%14 = fcmp olt float %8, %13
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = mul nsw i32 %11, 12
%17 = sitofp i32 %16 to float
%18 = fcmp ogt float %8, %17
br i1 %18, label %19, label %21
19: ; preds = %15, %10, %1
%20 = add nsw i32 %4, -1
br label %25
21: ; preds = %15
%22 = fpext float %5 to double
%23 = fpext float %8 to double
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %4, double %22, double %7, double %23)
br label %25
25: ; preds = %21, %19
%26 = phi i32 [ %20, %19 ], [ %4, %21 ]
%27 = add nsw i32 %26, 1
%28 = add nuw nsw i32 %2, 1
%29 = icmp eq i32 %27, 9
br i1 %29, label %30, label %1
30: ; preds = %25
%31 = fsub double 1.000000e+02, %7
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %28, double %31)
%33 = tail call i32 @putchar(i32 10)
ret void
}