#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 /*<<< orphan*/ scanf(char *, int *, float *, int *, int *);
int main() {
  int H, D, F, c, days;
  float U, f, s;
  while (1) {
    scanf("%d %f %d %d", &H, &U, &D, &F);
    if (H == 0)
      break;
    days = 1;
    s = 0;
    f = U * F / 100.0;
    while (1) {
      s += U;
      if (U > 0)
        U -= f;
      if (s > H)
        break;
      s -= D;
      if (s < 0)
        break;
      days++;
    }
    if (s < 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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    115a <main+0x3a>
jmp    1243 <main+0x123>
movl   $0x1,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11c3 <main+0xa3>
movss  -0x20(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x24(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jbe    11db <main+0xbb>
jmp    120e <main+0xee>
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x24(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x24(%rbp),%xmm0
jbe    1200 <main+0xe0>
jmp    120e <main+0xee>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1190 <main+0x70>
xorps  %xmm0,%xmm0
ucomiss -0x24(%rbp),%xmm0
jbe    122f <main+0x10f>
mov    -0x18(%rbp),%esi
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
jmp    123e <main+0x11e>
mov    -0x18(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x30,%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    0xecf(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1247 <main+0x127>
xorps  %xmm6,%xmm6
lea    0xebf(%rip),%rbp
lea    0xe99(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbx
jmp    11c8 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movaps %xmm5,%xmm1
ucomiss %xmm1,%xmm6
mov    %rbp,%rdi
lea    0xe70(%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>
xorps  %xmm6,%xmm6
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1247 <main+0x127>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x10(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
mulss  %xmm1,%xmm0
divss  0xe1d(%rip),%xmm0
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
mov    $0x1,%esi
xorps  %xmm3,%xmm3
cvtsi2ssl 0x14(%rsp),%xmm3
xorps  %xmm5,%xmm5
movaps %xmm1,%xmm4
ucomiss %xmm6,%xmm1
jbe    121d <main+0xfd>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movaps %xmm1,%xmm4
subss  %xmm0,%xmm4
movss  %xmm4,0x8(%rsp)
addss  %xmm5,%xmm1
ucomiss %xmm2,%xmm1
ja     1193 <main+0x73>
movaps %xmm1,%xmm5
subss  %xmm3,%xmm5
ucomiss %xmm5,%xmm6
ja     1190 <main+0x70>
add    $0x1,%esi
movaps %xmm4,%xmm1
ucomiss %xmm6,%xmm1
ja     1210 <main+0xf0>
jmp    121d <main+0xfd>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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