#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 main() {
  int V, T, X;
  scanf(" %d %d", &V, &T);
  while (T > 0) {
    scanf(" %d", &X);
    if (X >= 0)
      V += X;
    else
      V = V - (X * -1);
    if (V > 100)
      V = 100;
    if (V < 0)
      V = 0;
    T--;
  }
  printf("%d", V);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11b5 <main+0x95>
lea    0xead(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jl     1179 <main+0x59>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1185 <main+0x65>
mov    -0x8(%rbp),%eax
imul   $0xffffffff,-0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jle    1196 <main+0x76>
movl   $0x64,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11a7 <main+0x87>
movl   $0x0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <main+0x25>
mov    -0x8(%rbp),%esi
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1197 <main+0x77>
lea    0xeb5(%rip),%r14
lea    0xc(%rsp),%rbx
mov    $0x64,%ebp
jmp    1174 <main+0x54>
nopw   0x0(%rax,%rax,1)
mov    %esi,0x8(%rsp)
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
cmp    $0x1,%eax
jle    119b <main+0x7b>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
cmp    $0x64,%esi
cmovge %ebp,%esi
test   %esi,%esi
jns    1160 <main+0x40>
xor    %esi,%esi
jmp    1160 <main+0x40>
mov    0x8(%rsp),%esi
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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