#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*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
scalar_t__ isalpha(char);
char toupper(char);
int read_file(FILE *file_string, char *String) {
  char b;
  int i;
  i = 0;
  while (!feof(file_string)) {
    b = fgetc(file_string);
    if (isalpha(b)) {
      String[i] = toupper(b);
      i++;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1175 <read_file+0x35>
jmp    11b8 <read_file+0x78>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11b3 <read_file+0x73>
movsbl -0x11(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <read_file+0x17>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1165 <read_file+0x25>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
jmp    117c <read_file+0x3c>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1158 <read_file+0x18>
mov    %r15,%rdi
call   1040 <fgetc@plt>
movsbl %al,%ebp
mov    %ebp,%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     1170 <read_file+0x30>
mov    %ebp,%edi
call   1030 <toupper@plt>
movslq %ebx,%rbx
mov    %al,(%r14,%rbx,1)
add    $0x1,%ebx
jmp    1170 <read_file+0x30>

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

LLVM IR (-O2):
define i32 @read_file(i32* nocapture %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @feof(i32* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %2, %15
%6 = phi i32 [ %16, %15 ], [ 0, %2 ]
%7 = tail call signext i8 @fgetc(i32* %0)
%8 = tail call i64 @isalpha(i8 signext %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = tail call signext i8 @toupper(i8 signext %7)
%12 = sext i32 %6 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %11, i8* %13
%14 = add nsw i32 %6, 1
br label %15
15: ; preds = %10, %5
%16 = phi i32 [ %14, %10 ], [ %6, %5 ]
%17 = tail call i32 @feof(i32* %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %5, label %19
19: ; preds = %15, %2
%20 = phi i32 [ 0, %2 ], [ %16, %15 ]
ret i32 %20
}