#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__ EOF;
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, double *, double *, double *, double *);
int main() {
  double H, U, D, F;
  double up_dist, distance;
  int days;
  while (scanf("%lf %lf %lf %lf\n", &H, &U, &D, &F) != EOF && H != 0) {
    days = distance = 0;
    while (1) {
      up_dist = (U - days * U * F / 100);
      distance = (up_dist >= 0) ? distance + up_dist : distance;
      ++days;
      if (distance > H)
        break;
      distance -= D;
      if (distance < 0)
        break;
    }
    if (distance < 0) {
      printf("failure on day %d\n", days);
    } else {
      printf("success on day %d\n", days);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1040 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e91(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x3d(%rbp)
je     117a <main+0x5a>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    118a <main+0x6a>
jmp    127b <main+0x15b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x3c(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e8 <main+0xc8>
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11f2 <main+0xd2>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    121a <main+0xfa>
jmp    1245 <main+0x125>
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1240 <main+0x120>
jmp    1245 <main+0x125>
jmp    1199 <main+0x79>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1267 <main+0x147>
mov    -0x3c(%rbp),%esi
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
jmp    1276 <main+0x156>
mov    -0x3c(%rbp),%esi
lea    0xdbb(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xedb(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1040 <scanf@plt>
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%rax
je     1281 <main+0x161>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm7,%xmm7
ucomisd %xmm7,%xmm0
jne    1174 <main+0x54>
jnp    1281 <main+0x161>
movsd  0xe83(%rip),%xmm8
movsd  0xe82(%rip),%xmm9
lea    0xea7(%rip),%rbp
lea    0xe7c(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0x10(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
movsd  0x20(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
xorpd  %xmm4,%xmm4
mov    $0x1,%eax
movsd  0x18(%rsp),%xmm3
nopl   0x0(%rax,%rax,1)
mov    %eax,%esi
lea    -0x1(%rsi),%eax
xorps  %xmm6,%xmm6
cvtsi2sd %eax,%xmm6
mulsd  %xmm1,%xmm6
mulsd  %xmm2,%xmm6
divsd  %xmm8,%xmm6
addsd  %xmm1,%xmm6
xorpd  %xmm5,%xmm5
cmplesd %xmm6,%xmm5
andpd  %xmm5,%xmm6
andnpd %xmm9,%xmm5
orpd   %xmm6,%xmm5
addsd  %xmm4,%xmm5
ucomisd %xmm0,%xmm5
ja     121e <main+0xfe>
subsd  %xmm3,%xmm5
lea    0x1(%rsi),%eax
ucomisd %xmm5,%xmm7
movapd %xmm5,%xmm4
jbe    11d0 <main+0xb0>
ucomisd %xmm5,%xmm7
mov    %rbp,%rdi
lea    0xdf5(%rip),%rax
cmova  %rax,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <scanf@plt>
movsd  0xdb6(%rip),%xmm9
movsd  0xda5(%rip),%xmm8
xorpd  %xmm7,%xmm7
mov    0x2d82(%rip),%rcx
cmp    (%rcx),%rax
je     1281 <main+0x161>
movsd  0x8(%rsp),%xmm0
ucomisd %xmm7,%xmm0
jne    11b0 <main+0x90>
jp     11b0 <main+0x90>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@EOF = global i64 0
@.str.1 = [19 x i8] c"failure on day %d\0A\00"
@.str.2 = [19 x i8] c"success on day %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 0, i32* %1
br label %9
9: ; preds = %62, %0
%10 = call i64 @scanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load double, double* %2
%15 = fcmp une double %14, 0.000000e+00
br label %16
16: ; preds = %13, %9
%17 = phi i1 [ false, %9 ], [ %15, %13 ]
br i1 %17, label %18, label %63
18: ; preds = %16
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %19
19: ; preds = %18, %52
%20 = load double, double* %3
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to double
%23 = load double, double* %3
%24 = fmul double %22, %23
%25 = load double, double* %5
%26 = fmul double %24, %25
%27 = fdiv double %26, 1.000000e+02
%28 = fsub double %20, %27
store double %28, double* %6
%29 = load double, double* %6
%30 = fcmp oge double %29, 0.000000e+00
br i1 %30, label %31, label %35
31: ; preds = %19
%32 = load double, double* %7
%33 = load double, double* %6
%34 = fadd double %32, %33
br label %37
35: ; preds = %19
%36 = load double, double* %7
br label %37
37: ; preds = %35, %31
%38 = phi double [ %34, %31 ], [ %36, %35 ]
store double %38, double* %7
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = load double, double* %7
%42 = load double, double* %2
%43 = fcmp ogt double %41, %42
br i1 %43, label %44, label %45
44: ; preds = %37
br label %53
45: ; preds = %37
%46 = load double, double* %4
%47 = load double, double* %7
%48 = fsub double %47, %46
store double %48, double* %7
%49 = load double, double* %7
%50 = fcmp olt double %49, 0.000000e+00
br i1 %50, label %51, label %52
51: ; preds = %45
br label %53
52: ; preds = %45
br label %19
53: ; preds = %51, %44
%54 = load double, double* %7
%55 = fcmp olt double %54, 0.000000e+00
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = load i32, i32* %8
%58 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %62
59: ; preds = %53
%60 = load i32, i32* %8
%61 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %59, %56
br label %9
63: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@EOF = global i64 0
@.str.1 = [19 x i8] c"failure on day %d\0A\00"
@.str.2 = [19 x i8] c"success on day %d\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = call i64 @scanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
%12 = load double, double* %1
%13 = fcmp une double %12, 0.000000e+00
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %47
15: ; preds = %0, %36
%16 = phi double [ %44, %36 ], [ %12, %0 ]
%17 = load double, double* %2
%18 = load double, double* %4
%19 = load double, double* %3
br label %20
20: ; preds = %15, %33
%21 = phi double [ %34, %33 ], [ 0.000000e+00, %15 ]
%22 = phi i32 [ %31, %33 ], [ 0, %15 ]
%23 = sitofp i32 %22 to double
%24 = fmul double %17, %23
%25 = fmul double %24, %18
%26 = fdiv double %25, 1.000000e+02
%27 = fsub double %17, %26
%28 = fcmp oge double %27, 0.000000e+00
%29 = select i1 %28, double %27, double -0.000000e+00
%30 = fadd double %21, %29
%31 = add nuw nsw i32 %22, 1
%32 = fcmp ogt double %30, %16
br i1 %32, label %36, label %33
33: ; preds = %20
%34 = fsub double %30, %19
%35 = fcmp olt double %34, 0.000000e+00
br i1 %35, label %36, label %20
36: ; preds = %33, %20
%37 = phi double [ %30, %20 ], [ %34, %33 ]
%38 = fcmp olt double %37, 0.000000e+00
%39 = select i1 %38, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0)
%40 = call i32 @printf(i8* %39, i32 %31)
%41 = call i64 @scanf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%42 = load i64, i64* @EOF
%43 = icmp ne i64 %41, %42
%44 = load double, double* %1
%45 = fcmp une double %44, 0.000000e+00
%46 = select i1 %43, i1 %45, i1 false
br i1 %46, label %15, label %47
47: ; preds = %36, %0
ret i32 0
}