#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 O_CREAT;
int O_EXCL;
int O_RDWR;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  char buf1[] = "abcdefghijklmnop";
  char buf2[] = "ABCDEFGHIJKLMNOP";
  int fd = open("data.txt", O_RDWR | O_CREAT | O_EXCL, 0755);
  write(fd, buf1, 16);
  lseek(fd, 32, SEEK_CUR);
  write(fd, buf2, 16);
  close(fd);
  system("vi data.txt");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe95(%rip),%al
mov    %al,-0x10(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe96(%rip),%al
mov    %al,-0x30(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    0x2e4b(%rip),%rax
or     (%rax),%esi
mov    0x2e12(%rip),%rax
or     (%rax),%esi
lea    0xe75(%rip),%rdi
mov    $0x1ed,%edx
call   1070 <open@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    -0x44(%rbp),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1050 <lseek@plt>
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
lea    0xe1e(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movb   $0x0,0x30(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e68(%rip),%rax
mov    0x2e79(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
movb   $0x0,0x10(%rsp)
mov    0x2e39(%rip),%rax
or     (%rax),%esi
lea    0xe9c(%rip),%rdi
mov    $0x1ed,%edx
call   1070 <open@plt>
mov    %eax,%ebx
lea    0x20(%rsp),%rsi
mov    %eax,%edi
mov    $0x10,%edx
call   1030 <write@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0x20,%esi
call   1050 <lseek@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
lea    0xe4a(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.buf1 = [17 x i8] c"abcdefghijklmnop\00"
@__const.main.buf2 = [17 x i8] c"ABCDEFGHIJKLMNOP\00"
@.str = [9 x i8] c"data.txt\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@SEEK_CUR = global i32 0
@.str.1 = [12 x i8] c"vi data.txt\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [17 x i8]
%3 = alloca [17 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [17 x i8]* %2 to i8*
%6 = bitcast [17 x i8]* %3 to i8*
%7 = load i32, i32* @O_RDWR
%8 = load i32, i32* @O_CREAT
%9 = or i32 %7, %8
%10 = load i32, i32* @O_EXCL
%11 = or i32 %9, %10
%12 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %11, i32 493)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%15 = call i32 @write(i32 %13, i8* %14, i32 16)
%16 = load i32, i32* %4
%17 = load i32, i32* @SEEK_CUR
%18 = call i32 @lseek(i32 %16, i32 32, i32 %17)
%19 = load i32, i32* %4
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%21 = call i32 @write(i32 %19, i8* %20, i32 16)
%22 = load i32, i32* %4
%23 = call i32 @close(i32 %22)
%24 = call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf1 = [17 x i8] c"abcdefghijklmnop\00"
@__const.main.buf2 = [17 x i8] c"ABCDEFGHIJKLMNOP\00"
@.str = [9 x i8] c"data.txt\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@SEEK_CUR = global i32 0
@.str.1 = [12 x i8] c"vi data.txt\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = alloca [17 x i8]
%3 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_CREAT
%7 = or i32 %6, %5
%8 = load i32, i32* @O_EXCL
%9 = or i32 %7, %8
%10 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 493)
%11 = call i32 @write(i32 %10, i8* %3, i32 16)
%12 = load i32, i32* @SEEK_CUR
%13 = tail call i32 @lseek(i32 %10, i32 32, i32 %12)
%14 = call i32 @write(i32 %10, i8* %4, i32 16)
%15 = tail call i32 @close(i32 %10)
%16 = tail call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}