#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 *, ...);
scalar_t__ scanf(char *, double *, double *, double *, double *);
int main() {
  double h, u, d, f;
  int day;
  double ih, dc, hac, has;
  while (scanf("%lf%lf%lf%lf", &h, &u, &d, &f) != EOF) {
    if (h == 0)
      break;
    day = 1;
    ih = 0;
    dc = u;
    hac = ih + dc;
    has = hac - d;
    f = f * u / 100.0;
    while (hac <= h && has >= 0) {
      day++;
      ih = has;
      dc -= f;
      if (dc < 0)
        dc = 0;
      hac = ih + dc;
      has = hac - d;
      if (has < 0)
        break;
    }
    if (hac > h)
      printf("success ");
    else
      printf("failure ");
    printf("on day %d\n", day);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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    0x2e96(%rip),%rcx
cmp    (%rcx),%rax
je     12be <main+0x19e>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1178 <main+0x58>
jp     1178 <main+0x58>
jmp    12be <main+0x19e>
movl   $0x1,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x51(%rbp)
jb     11f5 <main+0xd5>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1205 <main+0xe5>
jmp    1277 <main+0x157>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1241 <main+0x121>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1272 <main+0x152>
jmp    1277 <main+0x157>
jmp    11ca <main+0xaa>
movsd  -0x48(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    129a <main+0x17a>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a8 <main+0x188>
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x60,%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    0xed3(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <scanf@plt>
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%rax
je     126e <main+0x14e>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm7,%xmm7
ucomisd %xmm7,%xmm0
jne    1174 <main+0x54>
jnp    126e <main+0x14e>
lea    0xe8d(%rip),%r15
lea    0x10(%rsp),%r12
lea    0x20(%rsp),%r13
lea    0x18(%rsp),%rbx
lea    0x8(%rsp),%rbp
nop
movsd  0x20(%rsp),%xmm5
movapd %xmm5,%xmm1
addsd  %xmm7,%xmm1
movsd  0x18(%rsp),%xmm2
movapd %xmm1,%xmm4
subsd  %xmm2,%xmm4
movsd  0x8(%rsp),%xmm3
mulsd  %xmm5,%xmm3
divsd  0xe42(%rip),%xmm3
movsd  %xmm3,0x8(%rsp)
mov    $0x1,%r14d
nopw   0x0(%rax,%rax,1)
ucomisd %xmm1,%xmm0
jb     1206 <main+0xe6>
ucomisd %xmm7,%xmm4
jb     1206 <main+0xe6>
add    $0x1,%r14d
subsd  %xmm3,%xmm5
xorpd  %xmm6,%xmm6
maxsd  %xmm5,%xmm6
movapd %xmm4,%xmm1
addsd  %xmm6,%xmm1
movapd %xmm1,%xmm4
subsd  %xmm2,%xmm4
ucomisd %xmm4,%xmm7
movapd %xmm6,%xmm5
jbe    11d0 <main+0xb0>
ucomisd %xmm0,%xmm1
lea    0xe0d(%rip),%rdi
lea    0xdfd(%rip),%rax
cmova  %rax,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1040 <scanf@plt>
xorpd  %xmm7,%xmm7
mov    0x2d95(%rip),%rcx
cmp    (%rcx),%rax
je     126e <main+0x14e>
movsd  0x10(%rsp),%xmm0
ucomisd %xmm7,%xmm0
jne    1190 <main+0x70>
jp     1190 <main+0x70>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"%lf%lf%lf%lf\00"
@EOF = global i64 0
@.str.1 = [9 x i8] c"success \00"
@.str.2 = [9 x i8] c"failure \00"
@.str.3 = [11 x i8] c"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 ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
%12 = load double, double* %1
%13 = fcmp oeq double %12, 0.000000e+00
%14 = select i1 %11, i1 true, i1 %13
br i1 %14, label %53, label %15
15: ; preds = %0, %40
%16 = phi double [ %50, %40 ], [ %12, %0 ]
%17 = load double, double* %2
%18 = fadd double %17, 0.000000e+00
%19 = load double, double* %3
%20 = fsub double %18, %19
%21 = load double, double* %4
%22 = fmul double %17, %21
%23 = fdiv double %22, 1.000000e+02
store double %23, double* %4
br label %24
24: ; preds = %32, %15
%25 = phi i32 [ 1, %15 ], [ %33, %32 ]
%26 = phi double [ %17, %15 ], [ %36, %32 ]
%27 = phi double [ %18, %15 ], [ %37, %32 ]
%28 = phi double [ %20, %15 ], [ %38, %32 ]
%29 = fcmp ole double %27, %16
%30 = fcmp oge double %28, 0.000000e+00
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %32, label %40
32: ; preds = %24
%33 = add nuw nsw i32 %25, 1
%34 = fsub double %26, %23
%35 = fcmp olt double %34, 0.000000e+00
%36 = select i1 %35, double 0.000000e+00, double %34
%37 = fadd double %28, %36
%38 = fsub double %37, %19
%39 = fcmp olt double %38, 0.000000e+00
br i1 %39, label %40, label %24
40: ; preds = %32, %24
%41 = phi i32 [ %33, %32 ], [ %25, %24 ]
%42 = phi double [ %37, %32 ], [ %27, %24 ]
%43 = fcmp ogt double %42, %16
%44 = select i1 %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %44)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%47 = call i64 @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%48 = load i64, i64* @EOF
%49 = icmp eq i64 %47, %48
%50 = load double, double* %1
%51 = fcmp oeq double %50, 0.000000e+00
%52 = select i1 %49, i1 true, i1 %51
br i1 %52, label %53, label %15
53: ; preds = %40, %0
ret i32 0
}