#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*/ abort_me();
int /*<<< orphan*/ exit(int);
int lseek(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
void check(int a, int b) {
  int end, result;
  end = lseek(a, 0, 2);
  if (lseek(b, 0, 1) != end) {
    printf("Error: file %d is not a dup of file %d\n", a, b);
    abort_me();
    exit(1);
  }
  result = lseek(b, 0, 0);
  if (lseek(a, 0, 1) != 0) {
    printf("Error: file %d is not a dup of file %d\n", a, b);
    abort_me();
    exit(1);
  }
  printf("OK\n");
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <lseek@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <lseek@plt>
cmp    -0xc(%rbp),%eax
je     119d <check+0x5d>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort_me@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <lseek@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <lseek@plt>
cmp    $0x0,%eax
je     11e9 <check+0xa9>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort_me@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %esi,%esi
mov    $0x2,%edx
call   1060 <lseek@plt>
mov    %eax,%ebx
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <lseek@plt>
cmp    %ebx,%eax
jne    11a8 <check+0x58>
mov    %r14d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <lseek@plt>
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <lseek@plt>
test   %eax,%eax
jne    11a8 <check+0x58>
lea    0xe89(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
lea    0xe51(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <abort_me@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Error: file %d is not a dup of file %d\0A\00"
@.str.1 = [4 x i8] c"OK\0A\00"
define void @check(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @lseek(i32 %7, i32 0, i32 2)
store i32 %8, i32* %5
%9 = load i32, i32* %4
%10 = call i32 @lseek(i32 %9, i32 0, i32 1)
%11 = load i32, i32* %5
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
%17 = call i32 (...) @abort_me()
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i32, i32* %4
%21 = call i32 @lseek(i32 %20, i32 0, i32 0)
store i32 %21, i32* %6
%22 = load i32, i32* %3
%23 = call i32 @lseek(i32 %22, i32 0, i32 1)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
%29 = call i32 (...) @abort_me()
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Error: file %d is not a dup of file %d\0A\00"
@str = [3 x i8] c"OK\00"
define void @check(i32 %0, i32 %1) {
%3 = tail call i32 @lseek(i32 %0, i32 0, i32 2)
%4 = tail call i32 @lseek(i32 %1, i32 0, i32 1)
%5 = icmp eq i32 %4, %3
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%8 = tail call i32 (...) @abort_me()
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = tail call i32 @lseek(i32 %1, i32 0, i32 0)
%12 = tail call i32 @lseek(i32 %0, i32 0, i32 1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%16 = tail call i32 (...) @abort_me()
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %10
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}