#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__ scanf(char *, char *);
void update_storage(int *storage, int size) {
  int i = -1;
  char currentChar;
  while (scanf("%c", &currentChar) != 0 && ++i < size) {
    switch (currentChar) {
    case ' ':
      i--;
      break;
    case 'V':
      storage[i]++;
      break;
    default:
      storage[i] = 0;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<update_storage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
lea    0xed3(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1030 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x12(%rbp)
je     115a <update_storage+0x4a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    116a <update_storage+0x5a>
jmp    11c8 <update_storage+0xb8>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x20,%eax
je     1190 <update_storage+0x80>
jmp    117f <update_storage+0x6f>
mov    -0x18(%rbp),%eax
sub    $0x56,%eax
je     119e <update_storage+0x8e>
jmp    11b4 <update_storage+0xa4>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11c3 <update_storage+0xb3>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    11c3 <update_storage+0xb3>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1126 <update_storage+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_storage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xed8(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1030 <scanf@plt>
test   %rax,%rax
je     118d <update_storage+0x7d>
mov    $0xffffffff,%ebx
lea    0xebd(%rip),%r15
lea    0xf(%rsp),%r12
jmp    116d <update_storage+0x5d>
nopw   0x0(%rax,%rax,1)
movslq %eax,%rcx
movl   $0x0,(%r14,%rcx,4)
mov    %eax,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <scanf@plt>
test   %rax,%rax
je     118d <update_storage+0x7d>
lea    0x1(%rbx),%eax
cmp    %ebp,%eax
jge    118d <update_storage+0x7d>
movsbl 0xf(%rsp),%ecx
cmp    $0x20,%ecx
je     115d <update_storage+0x4d>
cmp    $0x56,%ecx
jne    1150 <update_storage+0x40>
movslq %eax,%rcx
addl   $0x1,(%r14,%rcx,4)
jmp    115b <update_storage+0x4b>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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