#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 /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *, int *, int *, int *);
main() {
  double weak, k, sum, m;
  int h, u, d, f, day;
  int i, j, l, n, success;
  while (scanf("%d%d%d%d", &h, &u, &d, &f) == 4) {
    if (h == 0)
      break;
    weak = f / 100.0;
    sum = 0;
    success = 0;
    day = 0;
    k = weak * u;
    m = u;
    while (sum >= 0) {
      day++;
      if (m > 0)
        sum += m;
      m -= k;
      if (sum > h) {
        success = 1;
        break;
      }
      sum -= d;
    }
    if (success)
      printf("success on day %d\n", day);
    else
      printf("failure on day %d\n", day);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x34(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1040 <scanf@plt>
cmp    $0x4,%eax
jne    1265 <main+0x145>
cmpl   $0x0,-0x2c(%rbp)
jne    1163 <main+0x43>
jmp    1265 <main+0x145>
cvtsi2sdl -0x38(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x3c(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1233 <main+0x113>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11e8 <main+0xc8>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    121b <main+0xfb>
movl   $0x1,-0x50(%rbp)
jmp    1233 <main+0x113>
cvtsi2sdl -0x34(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ac <main+0x8c>
cmpl   $0x0,-0x50(%rbp)
je     1251 <main+0x131>
mov    -0x3c(%rbp),%esi
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
jmp    1260 <main+0x140>
mov    -0x3c(%rbp),%esi
lea    0xdc9(%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    $0x18,%rsp
lea    0xedb(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1040 <scanf@plt>
cmp    $0x4,%eax
jne    124d <main+0x12d>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     124d <main+0x12d>
movsd  0xe9d(%rip),%xmm6
lea    0xe9e(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
xorpd  %xmm7,%xmm7
lea    0xe9b(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0x14(%rsp),%xmm1
divsd  0xe46(%rip),%xmm0
mulsd  %xmm1,%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
mov    $0x1,%eax
xorps  %xmm3,%xmm3
cvtsi2sdl 0x10(%rsp),%xmm3
xorpd  %xmm5,%xmm5
nopw   0x0(%rax,%rax,1)
mov    %eax,%esi
movapd %xmm1,%xmm4
maxsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
ucomisd %xmm2,%xmm4
ja     1210 <main+0xf0>
subsd  %xmm0,%xmm1
subsd  %xmm3,%xmm4
lea    0x1(%rsi),%eax
ucomisd %xmm7,%xmm4
movapd %xmm4,%xmm5
jae    11e0 <main+0xc0>
mov    %rbp,%rdi
jmp    1217 <main+0xf7>
xchg   %ax,%ax
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1040 <scanf@plt>
cmp    $0x4,%eax
movsd  0xdcd(%rip),%xmm6
xorpd  %xmm7,%xmm7
jne    124d <main+0x12d>
mov    0x8(%rsp),%eax
test   %eax,%eax
jne    11a0 <main+0x80>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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