#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 str_length(char *);
int count_vowels(char *string) {
  int count = 0;
  int i;
  for (i = 0; i < str_length(string); i++) {
    switch (string[i]) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
    case 'A':
    case 'E':
    case 'I':
    case 'O':
    case 'U':
      count++;
      break;
    default:
      continue;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<count_vowels>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <str_length@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    1222 <count_vowels+0x112>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
sub    $0x41,%eax
je     11fc <count_vowels+0xec>
jmp    1163 <count_vowels+0x53>
mov    -0x18(%rbp),%eax
sub    $0x45,%eax
je     11fc <count_vowels+0xec>
jmp    1174 <count_vowels+0x64>
mov    -0x18(%rbp),%eax
sub    $0x49,%eax
je     11fc <count_vowels+0xec>
jmp    1185 <count_vowels+0x75>
mov    -0x18(%rbp),%eax
sub    $0x4f,%eax
je     11fc <count_vowels+0xec>
jmp    1196 <count_vowels+0x86>
mov    -0x18(%rbp),%eax
sub    $0x55,%eax
je     11fc <count_vowels+0xec>
jmp    11a7 <count_vowels+0x97>
mov    -0x18(%rbp),%eax
sub    $0x61,%eax
je     11fc <count_vowels+0xec>
jmp    11b8 <count_vowels+0xa8>
mov    -0x18(%rbp),%eax
sub    $0x65,%eax
je     11fc <count_vowels+0xec>
jmp    11c9 <count_vowels+0xb9>
mov    -0x18(%rbp),%eax
sub    $0x69,%eax
je     11fc <count_vowels+0xec>
jmp    11da <count_vowels+0xca>
mov    -0x18(%rbp),%eax
sub    $0x6f,%eax
je     11fc <count_vowels+0xec>
jmp    11eb <count_vowels+0xdb>
mov    -0x18(%rbp),%eax
sub    $0x75,%eax
jne    120a <count_vowels+0xfa>
jmp    11fc <count_vowels+0xec>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120f <count_vowels+0xff>
jmp    1214 <count_vowels+0x104>
jmp    1214 <count_vowels+0x104>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <count_vowels+0x1a>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_vowels>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <str_length@plt>
test   %eax,%eax
jle    116b <count_vowels+0x5b>
xor    %ebx,%ebx
movabs $0x10411100104111,%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%eax
add    $0xffffffbf,%eax
cmp    $0x34,%eax
ja     1156 <count_vowels+0x46>
bt     %rax,%r15
jae    1156 <count_vowels+0x46>
add    $0x1,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <str_length@plt>
cltq
cmp    %rax,%rbx
jl     1140 <count_vowels+0x30>
jmp    116d <count_vowels+0x5d>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @count_vowels(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %4
%7 = load i8*, i8** %2
%8 = call i32 @str_length(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %25
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %20 [
i32 97, label %17
i32 101, label %17
i32 105, label %17
i32 111, label %17
i32 117, label %17
i32 65, label %17
i32 69, label %17
i32 73, label %17
i32 79, label %17
i32 85, label %17
]
17: ; preds = %10, %10, %10, %10, %10, %10, %10, %10, %10, %10
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %21
20: ; preds = %10
br label %22
21: ; preds = %17
br label %22
22: ; preds = %21, %20
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %5
25: ; preds = %5
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @count_vowels(i8* %0) {
%2 = tail call i32 @str_length(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1, %12
%5 = phi i64 [ %14, %12 ], [ 0, %1 ]
%6 = phi i32 [ %13, %12 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %12 [
i32 97, label %10
i32 101, label %10
i32 105, label %10
i32 111, label %10
i32 117, label %10
i32 65, label %10
i32 69, label %10
i32 73, label %10
i32 79, label %10
i32 85, label %10
]
10: ; preds = %4, %4, %4, %4, %4, %4, %4, %4, %4, %4
%11 = add nsw i32 %6, 1
br label %12
12: ; preds = %4, %10
%13 = phi i32 [ %6, %4 ], [ %11, %10 ]
%14 = add nuw nsw i64 %5, 1
%15 = tail call i32 @str_length(i8* %0)
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %4, label %18
18: ; preds = %12, %1
%19 = phi i32 [ 0, %1 ], [ %13, %12 ]
ret i32 %19
}