#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 analisar(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *, ...);
int main(void) {
  int DIAS, CUSTO_POR_DIA;
  while (scanf("%d %d\n", &DIAS, &CUSTO_POR_DIA) != EOF) {
    int LUCROS[50];
    int i;
    for (i = 0; i < DIAS; i++) {
      scanf("%d\n", LUCROS + i);
    }
    printf("%d\n", analisar(LUCROS, DIAS, CUSTO_POR_DIA));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%rax
je     11dd <main+0xad>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <main+0x88>
lea    -0xe0(%rbp),%rsi
movslq -0xe4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1172 <main+0x42>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <analisar@plt>
mov    %eax,%esi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%rax
jne    1179 <main+0x49>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r14
lea    0xe7e(%rip),%rbx
lea    0x8(%rsp),%r12
lea    0xc(%rsp),%r13
jmp    11d6 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
mov    %r14,%rdi
call   1040 <analisar@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%rax
je     1165 <main+0x35>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    11a0 <main+0x70>
mov    %r14,%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r15
movslq 0x8(%rsp),%rsi
add    $0x4,%rbp
cmp    %rsi,%r15
jl     11f0 <main+0xc0>
jmp    11a0 <main+0x70>

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [50 x i32]
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %24, %0
%7 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i64, i64* @EOF
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %30
10: ; preds = %6
store i32 0, i32* %5
br label %11
11: ; preds = %21, %10
%12 = load i32, i32* %5
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %19)
br label %21
21: ; preds = %15
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %11
24: ; preds = %11
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call i32 @analisar(i32* %25, i32 %26, i32 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %6
30: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %31, label %9
9: ; preds = %0
%10 = bitcast [50 x i32]* %3 to i8*
%11 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
br label %12
12: ; preds = %9, %23
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %12, %15
%16 = phi i64 [ %19, %15 ], [ 0, %12 ]
%17 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %16
%18 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %23
23: ; preds = %15, %12
%24 = phi i32 [ %13, %12 ], [ %20, %15 ]
%25 = load i32, i32* %2
%26 = call i32 @analisar(i32* %11, i32 %24, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%29 = load i64, i64* @EOF
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %12
31: ; preds = %23, %0
ret i32 0
}