#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*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ write(int, int *, int);
int main() {
  int a2b, b2a, n;
  a2b = open("./a2b", O_RDONLY);
  b2a = open("./b2a", O_WRONLY);
  read(a2b, &n, sizeof(int));
  n *= 2;
  write(b2a, &n, sizeof(int));
  close(a2b);
  close(b2a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
lea    0xea1(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1050 <read@plt>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
shll   0xc(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %ebp,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"./a2b\00"
@O_RDONLY = global i32 0
@.str.1 = [6 x i8] c"./b2a\00"
@O_WRONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = call i32 @read(i32 %9, i32* %4, i32 4)
%11 = load i32, i32* %4
%12 = mul nsw i32 %11, 2
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = call i32 @write(i32 %13, i32* %4, i32 4)
%15 = load i32, i32* %2
%16 = call i32 @close(i32 %15)
%17 = load i32, i32* %3
%18 = call i32 @close(i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"./a2b\00"
@O_RDONLY = global i32 0
@.str.1 = [6 x i8] c"./b2a\00"
@O_WRONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = call i32 @read(i32 %4, i32* %1, i32 4)
%8 = load i32, i32* %1
%9 = shl nsw i32 %8, 1
store i32 %9, i32* %1
%10 = call i32 @write(i32 %6, i32* %1, i32 4)
%11 = tail call i32 @close(i32 %4)
%12 = tail call i32 @close(i32 %6)
ret i32 0
}