#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*/ SEEK_CUR;
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  FILE *fp;
  char ran[16] = "abcdefghijklmnop";
  int fd;
  fp = fopen("test", "w+");
  fd = fileno(fp);
  write(fd, ran, 16);
  lseek(fd, 32, SEEK_CUR);
  write(fd, ran, 16);
  system("vi test");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    -0x34(%rbp),%edi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1050 <lseek@plt>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
lea    0xe35(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xea2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xead(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0x20,%esi
call   1050 <lseek@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   1030 <write@plt>
lea    0xe57(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.ran = [16 x i8] c"abcdefghijklmnop"
@.str = [5 x i8] c"test\00"
@.str.1 = [3 x i8] c"w+\00"
@SEEK_CUR = global i32 0
@.str.2 = [8 x i8] c"vi test\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [16 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [16 x i8]* %7 to i8*
%10 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = call i32 @fileno(i32* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%15 = call i32 @write(i32 %13, i8* %14, i32 16)
%16 = load i32, i32* %8
%17 = load i32, i32* @SEEK_CUR
%18 = call i32 @lseek(i32 %16, i32 32, i32 %17)
%19 = load i32, i32* %8
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%21 = call i32 @write(i32 %19, i8* %20, i32 16)
%22 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.ran = [16 x i8] c"abcdefghijklmnop"
@.str = [5 x i8] c"test\00"
@.str.1 = [3 x i8] c"w+\00"
@SEEK_CUR = global i32 0
@.str.2 = [8 x i8] c"vi test\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @fileno(i32* %5)
%7 = call i32 @write(i32 %6, i8* %4, i32 16)
%8 = load i32, i32* @SEEK_CUR
%9 = tail call i32 @lseek(i32 %6, i32 32, i32 %8)
%10 = call i32 @write(i32 %6, i8* %4, i32 16)
%11 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}