#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*/ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int main() {
  char buf[80];
  FILE *f;
  f = fopen("/dev/urandom", "r");
  fread(buf, 80, 1, f);
  fgetc(f);
  fread(buf, 80, 1, f);
  fgetc(f);
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x50,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fgetc@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    $0x50,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fgetc@plt>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xeb2(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x50,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %r14,%rdi
mov    $0x50,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca i32*
%3 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%5 = load i32*, i32** %2
%6 = call i32 @fread(i8* %4, i32 80, i32 1, i32* %5)
%7 = load i32*, i32** %2
%8 = call i32 @fgetc(i32* %7)
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32 @fread(i8* %9, i32 80, i32 1, i32* %10)
%12 = load i32*, i32** %2
%13 = call i32 @fgetc(i32* %12)
%14 = load i32*, i32** %2
%15 = call i32 @fclose(i32* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/urandom\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @fread(i8* %2, i32 80, i32 1, i32* %3)
%5 = tail call i32 @fgetc(i32* %3)
%6 = call i32 @fread(i8* %2, i32 80, i32 1, i32* %3)
%7 = tail call i32 @fgetc(i32* %3)
%8 = tail call i32 @fclose(i32* %3)
ret i32 0
}