#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__ malloc(int);
scalar_t__ my_string_compare(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n;
  int i, count = 0;
  char *iter;
  scanf("%d", &n);
  char *B = (char *)malloc(10240 * sizeof(char));
  scanf("%s", B);
  i = 0;
  iter = B;
  while (i < n) {
    if (my_string_compare(&iter[i], "010") == 0) {
      iter[i + 2] = '1';
      count++;
      i = i + 2;
    } else
      i++;
  }
  printf("\n%d", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeab(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x2800,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fa <main+0xba>
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
lea    0xe4e(%rip),%rsi
call   1040 <my_string_compare@plt>
cmp    $0x0,%rax
jne    11ec <main+0xac>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x31,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    11f5 <main+0xb5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x57>
mov    -0x10(%rbp),%esi
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeb5(%rip),%rdi
xor    %r15d,%r15d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    $0x2800,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
lea    0xe8a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11d3 <main+0x93>
xor    %ebp,%ebp
lea    0xe73(%rip),%r14
xor    %r15d,%r15d
jmp    11a9 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11d3 <main+0x93>
movslq %ebp,%rbx
lea    (%r12,%rbx,1),%rdi
mov    %r14,%rsi
call   1040 <my_string_compare@plt>
test   %rax,%rax
jne    11a0 <main+0x60>
movb   $0x31,0x2(%r12,%rbx,1)
add    $0x2,%rbx
add    $0x1,%r15d
mov    %ebx,%ebp
cmp    0xc(%rsp),%ebp
jl     11a9 <main+0x69>
lea    0xe2d(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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