#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 */

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ compare_array(int *, int *, int);
int /*<<< orphan*/ read_file(char *, int *, int);
int /*<<< orphan*/ write_file(char *, int *, int);
void test_write_read_file() {
  int a[] = {5, 6, 7};
  int b[] = {0, 0, 0};
  assert(write_file("file.temp", a, 3));
  assert(read_file("file.temp", b, 3));
  assert(compare_array(a, b, 3));
}


x86 assembly (clang, -O0):
<test_write_read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xea1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
lea    -0xc(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x3,%edx
call   1030 <write_file@plt>
mov    %eax,%edi
call   1050 <assert@plt>
lea    -0x18(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x3,%edx
call   1060 <read_file@plt>
mov    %eax,%edi
call   1050 <assert@plt>
lea    -0xc(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1070 <compare_array@plt>
mov    %eax,%edi
call   1050 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_write_read_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0xeb9(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xea6(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xe96(%rip),%r15
lea    0x10(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <write_file@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1050 <read_file@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <compare_array@plt>
mov    %eax,%edi
call   1040 <assert@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_write_read_file.a = [3 x i32] [i32 5, i32 6, i32 7]
@.str = [10 x i8] c"file.temp\00"
define void @test_write_read_file() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = call i32 @write_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %5, i32 3)
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%9 = call i32 @read_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %8, i32 3)
%10 = call i32 @assert(i32 %9)
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%13 = call i32 @compare_array(i32* %11, i32* %12, i32 3)
%14 = call i32 @assert(i32 %13)
ret void
}

LLVM IR (-O2):
@__const.test_write_read_file.a = [3 x i32] [i32 5, i32 6, i32 7]
@.str = [10 x i8] c"file.temp\00"
define void @test_write_read_file() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = call i32 @write_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %5, i32 3)
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%9 = call i32 @read_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %8, i32 3)
%10 = call i32 @assert(i32 %9)
%11 = call i32 @compare_array(i32* %5, i32* %8, i32 3)
%12 = call i32 @assert(i32 %11)
ret void
}