#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*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *fpt;
  fpt = fopen("awmt.txt", "r");
  char text[50000];
  int bytes_read = fread(text, 1, 50000, fpt);
  printf("%s\n", text);
  printf("The number of bytes read = %d\n", bytes_read);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc370,%rsp
lea    0xebe(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    -0xc360(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0xc350,%edx
call   1030 <fread@plt>
mov    %eax,-0xc364(%rbp)
lea    -0xc360(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc364(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xc358,%rsp
lea    0xeb0(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xc350,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc358,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"awmt.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [31 x i8] c"The number of bytes read = %d\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca [50000 x i8]
%3 = alloca i32
%4 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 0
%6 = load i32*, i32** %1
%7 = call i32 @fread(i8* %5, i32 1, i32 50000, i32* %6)
store i32 %7, i32* %3
%8 = getelementptr inbounds [50000 x i8], [50000 x i8]* %2, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"awmt.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [31 x i8] c"The number of bytes read = %d\0A\00"
define i32 @main() {
%1 = alloca [50000 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [50000 x i8], [50000 x i8]* %1, i64 0, i64 0
%4 = call i32 @fread(i8* %3, i32 1, i32 50000, i32* %2)
%5 = call i32 @puts(i8* %3)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %4)
ret i32 0
}