#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  FILE *in;
  char name[25];
  int v = 0;
  char c;
  printf("Enter the input file name: ");
  scanf("%s", name);
  in = fopen(name, "rt");
  if (in == NULL) {
    printf("Failed to open the input file.");
    return 1;
  }
  while (!feof(in)) {
    c = (char)fgetc(in);
    switch (c) {
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'I':
    case 'o':
    case 'O':
    case 'u':
    case 'U':
      v++;
    }
  }
  printf("The number of vowels was: %d\n", v);
  fclose(in);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11cd <main+0x6d>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d9 <main+0x179>
jmp    11d2 <main+0x72>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f0 <main+0x90>
jmp    12b8 <main+0x158>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x35(%rbp)
movsbl -0x35(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x41,%eax
je     12aa <main+0x14a>
jmp    1211 <main+0xb1>
mov    -0x3c(%rbp),%eax
sub    $0x45,%eax
je     12aa <main+0x14a>
jmp    1222 <main+0xc2>
mov    -0x3c(%rbp),%eax
sub    $0x49,%eax
je     12aa <main+0x14a>
jmp    1233 <main+0xd3>
mov    -0x3c(%rbp),%eax
sub    $0x4f,%eax
je     12aa <main+0x14a>
jmp    1244 <main+0xe4>
mov    -0x3c(%rbp),%eax
sub    $0x55,%eax
je     12aa <main+0x14a>
jmp    1255 <main+0xf5>
mov    -0x3c(%rbp),%eax
sub    $0x61,%eax
je     12aa <main+0x14a>
jmp    1266 <main+0x106>
mov    -0x3c(%rbp),%eax
sub    $0x65,%eax
je     12aa <main+0x14a>
jmp    1277 <main+0x117>
mov    -0x3c(%rbp),%eax
sub    $0x69,%eax
je     12aa <main+0x14a>
jmp    1288 <main+0x128>
mov    -0x3c(%rbp),%eax
sub    $0x6f,%eax
je     12aa <main+0x14a>
jmp    1299 <main+0x139>
mov    -0x3c(%rbp),%eax
sub    $0x75,%eax
jne    12b3 <main+0x153>
jmp    12aa <main+0x14a>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d2 <main+0x72>
mov    -0x34(%rbp),%esi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1205 <main+0xa5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11e8 <main+0x88>
xor    %ebp,%ebp
movabs $0x10411100104111,%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
movsbl %al,%eax
add    $0xffffffbf,%eax
cmp    $0x34,%eax
ja     11dc <main+0x7c>
bt     %rax,%r14
jae    11dc <main+0x7c>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11c0 <main+0x60>
lea    0xe52(%rip),%rdi
xor    %r14d,%r14d
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1219 <main+0xb9>
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter the input file name: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [31 x i8] c"Failed to open the input file.\00"
@.str.4 = [30 x i8] c"The number of vowels was: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [25 x i8]
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %2
%11 = load i32*, i32** %2
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %36
15: ; preds = %0
br label %16
16: ; preds = %30, %15
%17 = load i32*, i32** %2
%18 = call i32 @feof(i32* %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %31
21: ; preds = %16
%22 = load i32*, i32** %2
%23 = call i64 @fgetc(i32* %22)
%24 = trunc i64 %23 to i8
store i8 %24, i8* %5
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
switch i32 %26, label %30 [
i32 97, label %27
i32 65, label %27
i32 101, label %27
i32 69, label %27
i32 105, label %27
i32 73, label %27
i32 111, label %27
i32 79, label %27
i32 117, label %27
i32 85, label %27
]
27: ; preds = %21, %21, %21, %21, %21, %21, %21, %21, %21, %21
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %30
30: ; preds = %27, %21
br label %16
31: ; preds = %16
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %2
%35 = call i32 @fclose(i32* %34)
store i32 0, i32* %1
br label %36
36: ; preds = %31, %13
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter the input file name: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"rt\00"
@.str.3 = [31 x i8] c"Failed to open the input file.\00"
@.str.4 = [30 x i8] c"The number of vowels was: %d\0A\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @feof(i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %24
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %28
12: ; preds = %7, %20
%13 = phi i32 [ %21, %20 ], [ 0, %7 ]
%14 = call i64 @fgetc(i32* %5)
%15 = trunc i64 %14 to i32
%16 = shl i32 %15, 24
%17 = ashr exact i32 %16, 24
switch i32 %17, label %20 [
i32 97, label %18
i32 65, label %18
i32 101, label %18
i32 69, label %18
i32 105, label %18
i32 73, label %18
i32 111, label %18
i32 79, label %18
i32 117, label %18
i32 85, label %18
]
18: ; preds = %12, %12, %12, %12, %12, %12, %12, %12, %12, %12
%19 = add nsw i32 %13, 1
br label %20
20: ; preds = %18, %12
%21 = phi i32 [ %13, %12 ], [ %19, %18 ]
%22 = call i32 @feof(i32* %5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %12, label %24
24: ; preds = %20, %7
%25 = phi i32 [ 0, %7 ], [ %21, %20 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = call i32 @fclose(i32* %5)
br label %28
28: ; preds = %24, %10
%29 = phi i32 [ 1, %10 ], [ 0, %24 ]
ret i32 %29
}