#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__ isprint(char);
char tolower(char);
char toupper(char);
int number_of_times_char_in_str(char *text_string, char letter) {
  int times = 0;
  int i = 0;
  while (isprint(text_string[i])) {
    if (text_string[i] == tolower(letter) || text_string[i] == toupper(letter))
      times++;
    i++;
  }
  return times;
}


x86 assembly (clang, -O0):
<number_of_times_char_in_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     11d2 <number_of_times_char_in_str+0xa2>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     11bb <number_of_times_char_in_str+0x8b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x1c(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jne    11c4 <number_of_times_char_in_str+0x94>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <number_of_times_char_in_str+0x20>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_of_times_char_in_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <isprint@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1198 <number_of_times_char_in_str+0x68>
movsbl %bpl,%ebp
jmp    1176 <number_of_times_char_in_str+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14d
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isprint@plt>
test   %rax,%rax
je     1198 <number_of_times_char_in_str+0x68>
movzbl (%rbx),%r15d
mov    %ebp,%edi
call   1040 <tolower@plt>
cmp    %al,%r15b
je     1160 <number_of_times_char_in_str+0x30>
movzbl (%rbx),%r15d
mov    %ebp,%edi
call   1030 <toupper@plt>
cmp    %al,%r15b
je     1160 <number_of_times_char_in_str+0x30>
jmp    1164 <number_of_times_char_in_str+0x34>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @number_of_times_char_in_str(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = tail call i64 @isprint(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %2, %19
%7 = phi i64 [ %21, %19 ], [ 0, %2 ]
%8 = phi i8* [ %22, %19 ], [ %0, %2 ]
%9 = phi i32 [ %20, %19 ], [ 0, %2 ]
%10 = load i8, i8* %8
%11 = tail call signext i8 @tolower(i8 signext %1)
%12 = icmp eq i8 %10, %11
br i1 %12, label %17, label %13
13: ; preds = %6
%14 = load i8, i8* %8
%15 = tail call signext i8 @toupper(i8 signext %1)
%16 = icmp eq i8 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13, %6
%18 = add nsw i32 %9, 1
br label %19
19: ; preds = %17, %13
%20 = phi i32 [ %18, %17 ], [ %9, %13 ]
%21 = add nuw i64 %7, 1
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = tail call i64 @isprint(i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %6
26: ; preds = %19, %2
%27 = phi i32 [ 0, %2 ], [ %20, %19 ]
ret i32 %27
}