#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/);
int /*<<< orphan*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *, int *, int *, int *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int height;
  int disU;
  int disD;
  int per;
  double current;
  double up;
  int d;
  if (argc != 2) {
    printf("Usage: %s INPUT_FILE\n\n", argv[0]);
    exit(-1);
  }
  if (access(argv[1], F_OK)) {
    printf("Error: INPUT_FILE %s does not exist\n\n", argv[1]);
    exit(-1);
  }
  freopen(argv[1], "r", stdin);
  while (scanf("%d %d %d %d", &height, &disU, &disD, &per) && height) {
    current = 0.0;
    up = (double)disU;
    d = 0;
    while (1) {
      d++;
      current += up;
      if (current > height) {
        printf("success on day %d\n", d);
        break;
      }
      current -= disD;
      if (current < 0) {
        printf("failure on day %d\n", d);
        break;
      }
      up -= disU * (per / 100.0);
      if (up < 0)
        up = 0;
    }
  }
  fclose(stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
call   1070 <access@plt>
cmp    $0x0,%rax
je     11df <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
lea    0xe4e(%rip),%rsi
call   1050 <freopen@plt>
lea    0xe44(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1060 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x35(%rbp)
je     1234 <main+0xd4>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    1244 <main+0xe4>
jmp    1335 <main+0x1d5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    129f <main+0x13f>
mov    -0x34(%rbp),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1330 <main+0x1d0>
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    12d6 <main+0x176>
mov    -0x34(%rbp),%esi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1330 <main+0x1d0>
cvtsi2sdl -0x18(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm2
movsd  0xd18(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    132b <main+0x1cb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    125d <main+0xfd>
jmp    11fc <main+0x9c>
mov    0x2cac(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    12e6 <main+0x186>
mov    0x8(%rbx),%rdi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
call   1070 <access@plt>
mov    0x8(%rbx),%rcx
test   %rax,%rax
jne    12f2 <main+0x192>
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
lea    0xeb4(%rip),%rsi
mov    %rcx,%rdi
call   1050 <freopen@plt>
lea    0xea7(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1060 <scanf@plt>
test   %rax,%rax
je     12c7 <main+0x167>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     12c7 <main+0x167>
lea    0xe7e(%rip),%r14
lea    0xe6b(%rip),%r15
lea    0x8(%rsp),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rbp
xorpd  %xmm7,%xmm7
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sdl 0x14(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    $0x1,%esi
ucomisd %xmm1,%xmm0
ja     128b <main+0x12b>
xorps  %xmm2,%xmm2
cvtsi2sdl 0x10(%rsp),%xmm2
xorps  %xmm3,%xmm3
cvtsi2sdl 0xc(%rsp),%xmm3
divsd  0xdbb(%rip),%xmm3
movapd %xmm0,%xmm4
xorpd  0xdbf(%rip),%xmm4
mov    $0x1,%esi
movapd %xmm0,%xmm5
nopw   0x0(%rax,%rax,1)
subsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm7
ja     1290 <main+0x130>
movapd %xmm4,%xmm6
mulsd  %xmm3,%xmm6
addsd  %xmm5,%xmm6
xorpd  %xmm5,%xmm5
maxsd  %xmm6,%xmm5
add    $0x1,%esi
addsd  %xmm5,%xmm0
ucomisd %xmm1,%xmm0
jbe    1260 <main+0x100>
mov    %r14,%rdi
jmp    1297 <main+0x137>
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1060 <scanf@plt>
test   %rax,%rax
xorpd  %xmm7,%xmm7
je     12c7 <main+0x167>
mov    0x8(%rsp),%eax
test   %eax,%eax
jne    1210 <main+0xb0>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xd30(%rip),%rdi
jmp    12fc <main+0x19c>
lea    0xd3e(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [12 x i8] c"%d %d %d %d\00"
@.str.4 = [19 x i8] c"success on day %d\0A\00"
@.str.5 = [19 x i8] c"failure on day %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* @F_OK
%26 = call i64 @access(i8* %24, i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 -1)
unreachable
34: ; preds = %21
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @stdin
%39 = call i32 @freopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %87, %34
%41 = call i64 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %6, i32* %7, i32* %8, i32* %9)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br label %46
46: ; preds = %43, %40
%47 = phi i1 [ false, %40 ], [ %45, %43 ]
br i1 %47, label %48, label %88
48: ; preds = %46
store double 0.000000e+00, double* %10
%49 = load i32, i32* %7
%50 = sitofp i32 %49 to double
store double %50, double* %11
store i32 0, i32* %12
br label %51
51: ; preds = %48, %86
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %12
%54 = load double, double* %11
%55 = load double, double* %10
%56 = fadd double %55, %54
store double %56, double* %10
%57 = load double, double* %10
%58 = load i32, i32* %6
%59 = sitofp i32 %58 to double
%60 = fcmp ogt double %57, %59
br i1 %60, label %61, label %64
61: ; preds = %51
%62 = load i32, i32* %12
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %87
64: ; preds = %51
%65 = load i32, i32* %8
%66 = sitofp i32 %65 to double
%67 = load double, double* %10
%68 = fsub double %67, %66
store double %68, double* %10
%69 = load double, double* %10
%70 = fcmp olt double %69, 0.000000e+00
br i1 %70, label %71, label %74
71: ; preds = %64
%72 = load i32, i32* %12
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %72)
br label %87
74: ; preds = %64
%75 = load i32, i32* %7
%76 = sitofp i32 %75 to double
%77 = load i32, i32* %9
%78 = sitofp i32 %77 to double
%79 = fdiv double %78, 1.000000e+02
%80 = load double, double* %11
%81 = fneg double %76
%82 = call double @llvm.fmuladd.f64(double %81, double %79, double %80)
store double %82, double* %11
%83 = load double, double* %11
%84 = fcmp olt double %83, 0.000000e+00
br i1 %84, label %85, label %86
85: ; preds = %74
store double 0.000000e+00, double* %11
br label %86
86: ; preds = %85, %74
br label %51
87: ; preds = %71, %61
br label %40
88: ; preds = %46
%89 = load i32, i32* @stdin
%90 = call i32 @fclose(i32 %89)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Usage: %s INPUT_FILE\0A\0A\00"
@F_OK = global i32 0
@.str.1 = [38 x i8] c"Error: INPUT_FILE %s does not exist\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.3 = [12 x i8] c"%d %d %d %d\00"
@.str.4 = [19 x i8] c"success on day %d\0A\00"
@.str.5 = [19 x i8] c"failure on day %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 -1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @F_OK
%20 = tail call i64 @access(i8* %18, i32 %19)
%21 = icmp eq i64 %20, 0
%22 = load i8*, i8** %17
br i1 %21, label %26, label %23
23: ; preds = %16
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%25 = tail call i32 @exit(i32 -1)
unreachable
26: ; preds = %16
%27 = load i32, i32* @stdin
%28 = tail call i32 @freopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = call i64 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%30 = icmp ne i64 %29, 0
%31 = load i32, i32* %3
%32 = icmp ne i32 %31, 0
%33 = select i1 %30, i1 %32, i1 false
br i1 %33, label %34, label %71
34: ; preds = %26, %65
%35 = phi i32 [ %68, %65 ], [ %31, %26 ]
%36 = load i32, i32* %4
%37 = sitofp i32 %36 to double
%38 = sitofp i32 %35 to double
%39 = fcmp ogt double %37, %38
br i1 %39, label %47, label %40
40: ; preds = %34
%41 = load i32, i32* %5
%42 = sitofp i32 %41 to double
%43 = load i32, i32* %6
%44 = sitofp i32 %43 to double
%45 = fdiv double %44, 1.000000e+02
%46 = fneg double %37
br label %50
47: ; preds = %58, %34
%48 = phi i32 [ 1, %34 ], [ %62, %58 ]
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %65
50: ; preds = %40, %58
%51 = phi double [ %37, %40 ], [ %63, %58 ]
%52 = phi i32 [ 1, %40 ], [ %62, %58 ]
%53 = phi double [ %37, %40 ], [ %61, %58 ]
%54 = fsub double %51, %42
%55 = fcmp olt double %54, 0.000000e+00
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %52)
br label %65
58: ; preds = %50
%59 = call double @llvm.fmuladd.f64(double %46, double %45, double %53)
%60 = fcmp olt double %59, 0.000000e+00
%61 = select i1 %60, double 0.000000e+00, double %59
%62 = add nuw nsw i32 %52, 1
%63 = fadd double %54, %61
%64 = fcmp ogt double %63, %38
br i1 %64, label %47, label %50
65: ; preds = %56, %47
%66 = call i64 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%67 = icmp ne i64 %66, 0
%68 = load i32, i32* %3
%69 = icmp ne i32 %68, 0
%70 = select i1 %67, i1 %69, i1 false
br i1 %70, label %34, label %71
71: ; preds = %65, %26
%72 = load i32, i32* @stdin
%73 = call i32 @fclose(i32 %72)
ret i32 0
}