#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 /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int a[10], m = 0;
    for (int i = 0; i < 10; i++)
      scanf("%d", &a[i]);
    for (int i = 0; i < 10; i++) {
      if (n == 0)
        break;
      n += a[i];
      m++;
    }
    printf("%d\n", m);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
je     11e9 <main+0xc9>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1190 <main+0x70>
movslq -0x38(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe83(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    115d <main+0x3d>
movl   $0x0,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    11d5 <main+0xb5>
cmpl   $0x0,-0x8(%rbp)
jne    11b0 <main+0x90>
jmp    11d5 <main+0xb5>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1197 <main+0x77>
mov    -0x34(%rbp),%esi
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
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    $0x38,%rsp
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2ea2(%rip),%r15
cmp    (%r15),%rax
jne    115c <main+0x3c>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x34(%rsp),%r12
lea    0xe98(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0xe8f(%rip),%rbp
lea    0xc(%rsp),%r14
jmp    119a <main+0x7a>
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
cmp    (%r15),%rax
je     114b <main+0x2b>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x18(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x1c(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x24(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x28(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x2c(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
lea    0x30(%rsp),%rsi
call   1040 <scanf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1180 <main+0x60>
add    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
je     1290 <main+0x170>
add    0x14(%rsp),%eax
mov    %eax,0xc(%rsp)
je     129a <main+0x17a>
add    0x18(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12a4 <main+0x184>
add    0x1c(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12ae <main+0x18e>
add    0x20(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12b8 <main+0x198>
add    0x24(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12c2 <main+0x1a2>
add    0x28(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12cc <main+0x1ac>
add    0x2c(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12d6 <main+0x1b6>
add    0x30(%rsp),%eax
mov    %eax,0xc(%rsp)
je     12e0 <main+0x1c0>
add    0x34(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    $0xa,%esi
jmp    1182 <main+0x62>
mov    $0x1,%esi
jmp    1182 <main+0x62>
mov    $0x2,%esi
jmp    1182 <main+0x62>
mov    $0x3,%esi
jmp    1182 <main+0x62>
mov    $0x4,%esi
jmp    1182 <main+0x62>
mov    $0x5,%esi
jmp    1182 <main+0x62>
mov    $0x6,%esi
jmp    1182 <main+0x62>
mov    $0x7,%esi
jmp    1182 <main+0x62>
mov    $0x8,%esi
jmp    1182 <main+0x62>
mov    $0x9,%esi
jmp    1182 <main+0x62>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = bitcast i32* %1 to i8*
%4 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %77, label %7
7: ; preds = %0
%8 = bitcast [10 x i32]* %2 to i8*
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 3
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 4
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 5
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 7
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 8
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
br label %19
19: ; preds = %7, %71
%20 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%21 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%22 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%23 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%25 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%26 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%28 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
%30 = load i32, i32* %1
%31 = icmp eq i32 %30, 0
br i1 %31, label %71, label %32
32: ; preds = %19
%33 = load i32, i32* %9
%34 = add nsw i32 %33, %30
store i32 %34, i32* %1
%35 = icmp eq i32 %34, 0
br i1 %35, label %71, label %36
36: ; preds = %32
%37 = load i32, i32* %10
%38 = add nsw i32 %37, %34
store i32 %38, i32* %1
%39 = icmp eq i32 %38, 0
br i1 %39, label %71, label %40
40: ; preds = %36
%41 = load i32, i32* %11
%42 = add nsw i32 %41, %38
store i32 %42, i32* %1
%43 = icmp eq i32 %42, 0
br i1 %43, label %71, label %44
44: ; preds = %40
%45 = load i32, i32* %12
%46 = add nsw i32 %45, %42
store i32 %46, i32* %1
%47 = icmp eq i32 %46, 0
br i1 %47, label %71, label %48
48: ; preds = %44
%49 = load i32, i32* %13
%50 = add nsw i32 %49, %46
store i32 %50, i32* %1
%51 = icmp eq i32 %50, 0
br i1 %51, label %71, label %52
52: ; preds = %48
%53 = load i32, i32* %14
%54 = add nsw i32 %53, %50
store i32 %54, i32* %1
%55 = icmp eq i32 %54, 0
br i1 %55, label %71, label %56
56: ; preds = %52
%57 = load i32, i32* %15
%58 = add nsw i32 %57, %54
store i32 %58, i32* %1
%59 = icmp eq i32 %58, 0
br i1 %59, label %71, label %60
60: ; preds = %56
%61 = load i32, i32* %16
%62 = add nsw i32 %61, %58
store i32 %62, i32* %1
%63 = icmp eq i32 %62, 0
br i1 %63, label %71, label %64
64: ; preds = %60
%65 = load i32, i32* %17
%66 = add nsw i32 %65, %62
store i32 %66, i32* %1
%67 = icmp eq i32 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %64
%69 = load i32, i32* %18
%70 = add nsw i32 %69, %66
store i32 %70, i32* %1
br label %71
71: ; preds = %68, %64, %60, %56, %52, %48, %44, %40, %36, %32, %19
%72 = phi i32 [ 0, %19 ], [ 1, %32 ], [ 2, %36 ], [ 3, %40 ], [ 4, %44 ], [ 5, %48 ], [ 6, %52 ], [ 7, %56 ], [ 8, %60 ], [ 9, %64 ], [ 10, %68 ]
%73 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %72)
%74 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%75 = load i64, i64* @EOF
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %19
77: ; preds = %71, %0
ret i32 0
}