#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 *calloc(int, int);
int get_next_cloud_path(int /*<<< orphan*/, int, int *, int *,
                        int /*<<< orphan*/);
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  int *c = malloc(sizeof(int) * n);
  int *path = calloc(n, sizeof(int));
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  int x = get_next_cloud_path(0, n, c, path, 0);
  int jumps = 1;
  int i = 0;
  while (path[i] > 0) {
    jumps++;
    i++;
  }
  printf("%d", jumps);
}


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)
lea    0xe93(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d6 <main+0x86>
mov    -0x20(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe3d(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a1 <main+0x51>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
xor    %r8d,%r8d
mov    %r8d,%edi
call   1030 <get_next_cloud_path@plt>
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x38(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    1226 <main+0xd6>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11fd <main+0xad>
mov    -0x34(%rbp),%esi
lea    0xdd0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%r13d
lea    0x0(,%r13,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
test   %r13d,%r13d
jle    11cd <main+0x7d>
xor    %ebp,%ebp
lea    0xe61(%rip),%r12
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%r13
add    $0x4,%rbx
cmp    %r13,%rbp
jl     11b0 <main+0x60>
xor    %edi,%edi
mov    %r13d,%esi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1030 <get_next_cloud_path@plt>
cmpl   $0x0,(%r15)
jle    11fd <main+0xad>
mov    $0x1,%esi
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,(%r15,%rsi,4)
lea    0x1(%rsi),%rsi
jg     11f0 <main+0xa0>
jmp    1202 <main+0xb2>
mov    $0x1,%esi
lea    0xdf7(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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