#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*/ temp;

/* Variables and functions */
int read(int /*<<< orphan*/, void *, int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *, unsigned int *);
int /*<<< orphan*/ strip_nulls(char *, int);
int gogo_read_stat(unsigned int *current, unsigned int *length) {
  char temp[1024];
  int bytes_read;
  bytes_read = read(0, (void *)temp, sizeof(temp));
  if (bytes_read) {
    strip_nulls(temp, bytes_read);
    sscanf(temp, "{ %u/ %u}", current, length);
    return (0);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<gogo_read_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x420(%rbp),%rsi
xor    %edi,%edi
mov    $0x400,%edx
call   1040 <read@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     11a2 <gogo_read_stat+0x72>
lea    -0x420(%rbp),%rdi
mov    -0x424(%rbp),%esi
call   1030 <strip_nulls@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe6f(%rip),%rsi
call   1050 <sscanf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <gogo_read_stat+0x79>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gogo_read_stat>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x400,%edx
call   1040 <read@plt>
test   %eax,%eax
je     117d <gogo_read_stat+0x4d>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <strip_nulls@plt>
lea    0xe93(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <sscanf@plt>
jmp    1182 <gogo_read_stat+0x52>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"{ %u/ %u}\00"
define i32 @gogo_read_stat(i32* %0, i32* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @read(i32 0, i8* %4, i32 1024)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @strip_nulls(i8* %4, i32 %5)
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %0, i32* %1)
br label %10
10: ; preds = %2, %7
%11 = phi i32 [ 0, %7 ], [ -1, %2 ]
ret i32 %11
}