#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*/ *);
int toupper(char);
unsigned int read_file(FILE *file_string, char *String) {
  char b;
  unsigned int i;
  i = 0;
  while (!feof(file_string)) {
    b = fgetc(file_string);
    if (b) {
      String[i] = (toupper(b) - 64) % 5;
      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    1165 <read_file+0x35>
jmp    11a7 <read_file+0x77>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x11(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     11a2 <read_file+0x72>
movsbl -0x11(%rbp),%edi
call   1030 <toupper@plt>
sub    $0x40,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1147 <read_file+0x17>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     114c <read_file+0x1c>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebp,%ebp
jmp    115c <read_file+0x2c>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1145 <read_file+0x15>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
test   %al,%al
je     1150 <read_file+0x20>
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
add    $0xffffffc0,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0xffffffc0,%eax
mov    %ebp,%ecx
mov    %al,(%r14,%rcx,1)
add    $0x1,%ebp
jmp    1150 <read_file+0x20>

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 = %29, %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 %30
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 = icmp ne i8 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i8, i8* %5
%19 = call i32 @toupper(i8 signext %18)
%20 = sub nsw i32 %19, 64
%21 = srem i32 %20, 5
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = load i32, i32* %6
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i32, i32* %6
%28 = add i32 %27, 1
store i32 %28, i32* %6
br label %29
29: ; preds = %17, %12
br label %7
30: ; preds = %7
%31 = load i32, i32* %6
ret i32 %31
}

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 %21
5: ; preds = %2, %17
%6 = phi i32 [ %18, %17 ], [ 0, %2 ]
%7 = tail call signext i8 @fgetc(i32* %0)
%8 = icmp eq i8 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %5
%10 = tail call i32 @toupper(i8 signext %7)
%11 = add nsw i32 %10, -64
%12 = srem i32 %11, 5
%13 = trunc i32 %12 to i8
%14 = zext i32 %6 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 %13, i8* %15
%16 = add i32 %6, 1
br label %17
17: ; preds = %9, %5
%18 = phi i32 [ %16, %9 ], [ %6, %5 ]
%19 = tail call i32 @feof(i32* %0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %5, label %21
21: ; preds = %17, %2
%22 = phi i32 [ 0, %2 ], [ %18, %17 ]
ret i32 %22
}