#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 islower(char);
int countBlocksOfLower(char *s, int size) {
  int i;
  int isLower, lastIsLower = 0;
  int blockCount = 0;
  for (i = 0; i < size; ++i) {
    isLower = islower(s[i]);
    if (isLower && !lastIsLower)
      ++blockCount;
    lastIsLower = isLower;
  }
  return blockCount;
}


x86 assembly (clang, -O0):
<countBlocksOfLower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1185 <countBlocksOfLower+0x75>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <islower@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1171 <countBlocksOfLower+0x61>
cmpl   $0x0,-0x18(%rbp)
jne    1171 <countBlocksOfLower+0x61>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <countBlocksOfLower+0x24>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countBlocksOfLower>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    115a <countBlocksOfLower+0x4a>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <islower@plt>
test   %eax,%eax
setne  %cl
test   %r12d,%r12d
sete   %dl
and    %cl,%dl
movzbl %dl,%ecx
add    %ecx,%ebp
add    $0x1,%rbx
mov    %eax,%r12d
cmp    %rbx,%r15
jne    1130 <countBlocksOfLower+0x20>
jmp    115c <countBlocksOfLower+0x4c>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @countBlocksOfLower(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %5
br label %9
9: ; preds = %30, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @islower(i8 signext %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %13
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %28
28: ; preds = %25, %22, %13
%29 = load i32, i32* %6
store i32 %29, i32* %7
br label %30
30: ; preds = %28
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %9
33: ; preds = %9
%34 = load i32, i32* %8
ret i32 %34
}

LLVM IR (-O2):
define i32 @countBlocksOfLower(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %18, %6 ]
%8 = phi i32 [ 0, %4 ], [ %17, %6 ]
%9 = phi i32 [ 0, %4 ], [ %12, %6 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %7
%11 = load i8, i8* %10
%12 = tail call i32 @islower(i8 signext %11)
%13 = icmp ne i32 %12, 0
%14 = icmp eq i32 %9, 0
%15 = and i1 %14, %13
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %8, %16
%18 = add nuw nsw i64 %7, 1
%19 = icmp eq i64 %18, %5
br i1 %19, label %20, label %6
20: ; preds = %6, %2
%21 = phi i32 [ 0, %2 ], [ %17, %6 ]
ret i32 %21
}