#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*/ s;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int O_CREAT;
int O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  int fd, size;
  char s[] = "Linux Programmer!\n";
  char buffer[80];
  fd = open("/tmp/temp", O_WRONLY | O_CREAT);
  write(fd, s, sizeof(s));
  close(fd);
  fd = open("/tmp/temp", O_RDONLY);
  size = read(fd, buffer, sizeof(buffer));
  close(fd);
  printf("%s", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe94(%rip),%ax
mov    %ax,-0x10(%rbp)
mov    0xe8c(%rip),%al
mov    %al,-0xe(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
mov    0x2e5f(%rip),%rax
or     (%rax),%esi
lea    0xe71(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x13,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
lea    0xe40(%rip),%rdi
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x50,%edx
call   1060 <read@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
lea    -0x70(%rbp),%rsi
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
movaps 0xea3(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xa2172,0xf(%rsp)
mov    0x2e58(%rip),%rax
mov    0x2e81(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe91(%rip),%rbx
mov    %rbx,%rdi
call   1070 <open@plt>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x13,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <open@plt>
mov    %eax,%ebx
lea    0x20(%rsp),%rbp
mov    %eax,%edi
mov    %rbp,%rsi
mov    $0x50,%edx
call   1060 <read@plt>
mov    %ebx,%edi
call   1050 <close@plt>
lea    0xe46(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.s = [19 x i8] c"Linux Programmer!\0A\00"
@.str = [10 x i8] c"/tmp/temp\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [19 x i8]
%5 = alloca [80 x i8]
store i32 0, i32* %1
%6 = bitcast [19 x i8]* %4 to i8*
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %7, %8
%10 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%13 = call i32 @write(i32 %11, i8* %12, i32 19)
%14 = load i32, i32* %2
%15 = call i32 @close(i32 %14)
%16 = load i32, i32* @O_RDONLY
%17 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %16)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%20 = call i32 @read(i32 %18, i8* %19, i32 80)
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = call i32 @close(i32 %21)
%23 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [19 x i8] c"Linux Programmer!\0A\00"
@.str = [10 x i8] c"/tmp/temp\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_RDONLY = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [19 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [19 x i8], [19 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_CREAT
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @write(i32 %8, i8* %3, i32 19)
%10 = tail call i32 @close(i32 %8)
%11 = load i32, i32* @O_RDONLY
%12 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @read(i32 %12, i8* %4, i32 80)
%14 = tail call i32 @close(i32 %12)
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}