#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 */
long sok_history_getpushes(char *history) {
  int res = 0;
  if (history == NULL)
    return (0);
  while (*history != 0) {
    if ((*history >= 'A') && (*history <= 'Z'))
      res += 1;
    history += 1;
  }
  return (res);
}


x86 assembly (clang, -O0):
<sok_history_getpushes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1127 <sok_history_getpushes+0x27>
movq   $0x0,-0x8(%rbp)
jmp    117e <sok_history_getpushes+0x7e>
jmp    112c <sok_history_getpushes+0x2c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1176 <sok_history_getpushes+0x76>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     1165 <sok_history_getpushes+0x65>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     1165 <sok_history_getpushes+0x65>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <sok_history_getpushes+0x2c>
movslq -0x14(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sok_history_getpushes>:
test   %rdi,%rdi
je     1137 <sok_history_getpushes+0x37>
mov    (%rdi),%cl
xor    %eax,%eax
test   %cl,%cl
je     1136 <sok_history_getpushes+0x36>
add    $0x1,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xbf,%cl
cmp    $0x1a,%cl
adc    $0x0,%eax
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
jne    1120 <sok_history_getpushes+0x20>
mov    %eax,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i64 @sok_history_getpushes(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3, %6
%7 = phi i8 [ %15, %6 ], [ %4, %3 ]
%8 = phi i32 [ %13, %6 ], [ 0, %3 ]
%9 = phi i8* [ %14, %6 ], [ %0, %3 ]
%10 = add i8 %7, -65
%11 = icmp ult i8 %10, 26
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %8, %12
%14 = getelementptr inbounds i8, i8* %9, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %6
17: ; preds = %6
%18 = zext i32 %13 to i64
br label %19
19: ; preds = %3, %17, %1
%20 = phi i64 [ 0, %1 ], [ 0, %3 ], [ %18, %17 ]
ret i64 %20
}