#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_RDWR;
int O_TRUNC;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ ftruncate(int, int);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ unlink(char *);
main() {
  int *buf;
  int fd = open("conftest.trunc", O_RDWR | O_CREAT | O_TRUNC, 0666);
  ftruncate(fd, 7663);
  unlink("conftest.trunc");
  if (lseek(fd, 0, SEEK_END) == 7663) {
    exit(0);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    0x2e89(%rip),%rax
or     (%rax),%esi
mov    0x2e78(%rip),%rax
or     (%rax),%esi
lea    0xe7f(%rip),%rdi
mov    $0x1b6,%edx
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1def,%esi
call   1040 <ftruncate@plt>
lea    0xe5e(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x14(%rbp),%edi
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0x1def,%eax
jne    11cc <main+0x7c>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e7e(%rip),%rax
mov    0x2e97(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e84(%rip),%rax
or     (%rax),%esi
lea    0xe8b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1b6,%edx
call   1060 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x1def,%esi
call   1040 <ftruncate@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0x1def,%eax
jne    11b8 <main+0x68>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"conftest.trunc\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@SEEK_END = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_RDWR
%5 = load i32, i32* @O_CREAT
%6 = or i32 %4, %5
%7 = load i32, i32* @O_TRUNC
%8 = or i32 %6, %7
%9 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %8, i32 438)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @ftruncate(i32 %10, i32 7663)
%12 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* %3
%14 = load i32, i32* @SEEK_END
%15 = call i32 @lseek(i32 %13, i32 0, i32 %14)
%16 = icmp eq i32 %15, 7663
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %0
%20 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [15 x i8] c"conftest.trunc\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@SEEK_END = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = load i32, i32* @O_CREAT
%3 = or i32 %2, %1
%4 = load i32, i32* @O_TRUNC
%5 = or i32 %3, %4
%6 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5, i32 438)
%7 = tail call i32 @ftruncate(i32 %6, i32 7663)
%8 = tail call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @lseek(i32 %6, i32 0, i32 %9)
%11 = icmp eq i32 %10, 7663
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = tail call i32 @exit(i32 0)
unreachable
14: ; preds = %0
%15 = tail call i32 @exit(i32 1)
unreachable
}