#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 scalar_t__ ssize_t;
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ poffset(char *, scalar_t__, scalar_t__);
int /*<<< orphan*/ strlen(char *);
scalar_t__ write(int, char *, int /*<<< orphan*/);
int printoffset(int fdadm, off_t o1, off_t o2) {
  ssize_t wres;
  off_t sres;
  char rbuffer[50];
  int res = -1;
  poffset(rbuffer, o1, o2);
  sres = lseek(fdadm, 0, SEEK_SET);
  if (sres < 0)
    goto RETURN;
  wres = write(fdadm, rbuffer, strlen(rbuffer));
  if (wres < 0)
    goto RETURN;
  res = 0;
RETURN:
  return res;
}


x86 assembly (clang, -O0):
<printoffset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xffffffff,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <poffset@plt>
mov    -0x4(%rbp),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    1195 <printoffset+0x55>
jmp    11d5 <printoffset+0x95>
mov    -0x4(%rbp),%eax
mov    %eax,-0x74(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    11ce <printoffset+0x8e>
jmp    11d5 <printoffset+0x95>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printoffset>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
mov    %rsp,%rdi
call   1060 <poffset@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
test   %rax,%rax
js     1185 <printoffset+0x45>
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
sar    $0x3f,%rax
jmp    118a <printoffset+0x4a>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @printoffset(i32 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [50 x i8]
%10 = alloca i32
store i32 %0, i32* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i32 -1, i32* %10
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%12 = load i64, i64* %5
%13 = load i64, i64* %6
%14 = call i32 @poffset(i8* %11, i64 %12, i64 %13)
%15 = load i32, i32* %4
%16 = load i32, i32* @SEEK_SET
%17 = call i64 @lseek(i32 %15, i32 0, i32 %16)
store i64 %17, i64* %8
%18 = load i64, i64* %8
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %3
br label %31
21: ; preds = %3
%22 = load i32, i32* %4
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%24 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i64 @write(i32 %22, i8* %23, i32 %25)
store i64 %26, i64* %7
%27 = load i64, i64* %7
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %21
br label %31
30: ; preds = %21
store i32 0, i32* %10
br label %31
31: ; preds = %30, %29, %20
%32 = load i32, i32* %10
ret i32 %32
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @printoffset(i32 %0, i64 %1, i64 %2) {
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%6 = call i32 @poffset(i8* %5, i64 %1, i64 %2)
%7 = load i32, i32* @SEEK_SET
%8 = call i64 @lseek(i32 %0, i32 0, i32 %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = call i32 @strlen(i8* %5)
%12 = call i64 @write(i32 %0, i8* %5, i32 %11)
%13 = ashr i64 %12, 63
%14 = trunc i64 %13 to i32
br label %15
15: ; preds = %10, %3
%16 = phi i32 [ -1, %3 ], [ %14, %10 ]
ret i32 %16
}