#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*/ rbuffer;
typedef scalar_t__ off_t;

/* Variables and functions */
size_t read(int, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, scalar_t__ *, scalar_t__ *);
int readoffset(int fdadm, off_t *o1, off_t *o2) {
  char rbuffer[50];
  size_t rres;
  int res = 0;
  *o1 = 0;
  *o2 = 0;
  rres = read(fdadm, rbuffer, sizeof(rbuffer));
  if (rres <= 0)
    goto RETURN;
  rbuffer[rres] = '\0';
  sscanf(rbuffer, "%ld%ld", o1, o2);
RETURN:
  return res;
}


x86 assembly (clang, -O0):
<readoffset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x32,%edx
call   1030 <read@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
ja     1175 <readoffset+0x55>
jmp    1196 <readoffset+0x76>
mov    -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe6f(%rip),%rsi
call   1040 <sscanf@plt>
mov    -0x5c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readoffset>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movq   $0x0,(%rsi)
movq   $0x0,(%rdx)
mov    %rsp,%rsi
mov    $0x32,%edx
call   1030 <read@plt>
test   %rax,%rax
je     1166 <readoffset+0x46>
movb   $0x0,(%rsp,%rax,1)
lea    0xea8(%rip),%rsi
mov    %rsp,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <sscanf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%ld%ld\00"
define i32 @readoffset(i32 %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca [50 x i8]
%8 = alloca i64
%9 = alloca i32
store i32 %0, i32* %4
store i64* %1, i64** %5
store i64* %2, i64** %6
store i32 0, i32* %9
%10 = load i64*, i64** %5
store i64 0, i64* %10
%11 = load i64*, i64** %6
store i64 0, i64* %11
%12 = load i32, i32* %4
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%14 = call i64 @read(i32 %12, i8* %13, i32 50)
store i64 %14, i64* %8
%15 = load i64, i64* %8
%16 = icmp ule i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %3
br label %25
18: ; preds = %3
%19 = load i64, i64* %8
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 %19
store i8 0, i8* %20
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%22 = load i64*, i64** %5
%23 = load i64*, i64** %6
%24 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64* %22, i64* %23)
br label %25
25: ; preds = %18, %17
%26 = load i32, i32* %9
ret i32 %26
}

LLVM IR (-O2):
@.str = [7 x i8] c"%ld%ld\00"
define i32 @readoffset(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
store i64 0, i64* %1
store i64 0, i64* %2
%6 = call i64 @read(i32 %0, i8* %5, i32 50)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %6
store i8 0, i8* %9
%10 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
br label %11
11: ; preds = %3, %8
ret i32 0
}