#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 *);
int validator(int);
int main() {
  int input = 0;
  int balance = 0;
  int financial_movement = 0;
  int index = 0;
  scanf("%d", &input);
  if (input >= 1 && input <= 30) {
    scanf("%d", &balance);
    if (validator(balance) == 1) {
      for (index = 0; index < input; index++) {
        scanf("%d", &financial_movement);
        if (validator(financial_movement) == 1) {
          balance = balance + financial_movement;
        } else {
          return 0;
        }
      }
    } else {
      return 0;
    }
    printf("%d", balance);
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     1226 <main+0xf6>
cmpl   $0x1e,-0x8(%rbp)
jg     1226 <main+0xf6>
lea    0xe7a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1050 <validator@plt>
cmp    $0x1,%eax
jne    1206 <main+0xd6>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1201 <main+0xd1>
lea    0xe46(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%edi
call   1050 <validator@plt>
cmp    $0x1,%eax
jne    11e2 <main+0xb2>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ee <main+0xbe>
movl   $0x0,-0x4(%rbp)
jmp    122d <main+0xfd>
jmp    11f3 <main+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <main+0x77>
jmp    1212 <main+0xe2>
movl   $0x0,-0x4(%rbp)
jmp    122d <main+0xfd>
mov    -0xc(%rbp),%esi
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
jmp    122d <main+0xfd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xea9(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x1d,%eax
ja     11f0 <main+0xc0>
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
call   1050 <validator@plt>
cmp    $0x1,%eax
jne    11f0 <main+0xc0>
cmpl   $0x0,0x8(%rsp)
jle    11e0 <main+0xb0>
xor    %ebp,%ebp
lea    0xe60(%rip),%r14
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%edi
call   1050 <validator@plt>
cmp    $0x1,%eax
jne    11f0 <main+0xc0>
mov    0xc(%rsp),%esi
add    0x4(%rsp),%esi
mov    %esi,0x4(%rsp)
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     11b0 <main+0x80>
jmp    11e4 <main+0xb4>
mov    0x4(%rsp),%esi
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sge i32 %7, 1
br i1 %8, label %9, label %41
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 30
br i1 %11, label %12, label %41
12: ; preds = %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = call i32 @validator(i32 %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %37
17: ; preds = %12
store i32 0, i32* %5
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %2
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = call i32 @validator(i32 %24)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %28, %29
store i32 %30, i32* %3
br label %32
31: ; preds = %22
store i32 0, i32* %1
br label %42
32: ; preds = %27
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %18
36: ; preds = %18
br label %38
37: ; preds = %12
store i32 0, i32* %1
br label %42
38: ; preds = %36
%39 = load i32, i32* %3
%40 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %39)
br label %42
41: ; preds = %9, %0
store i32 0, i32* %1
br label %42
42: ; preds = %31, %37, %41, %38
%43 = load i32, i32* %1
ret i32 %43
}

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