#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 *, double *, char *);
int lame_read_stat(double *current) {
  char temp[4096];
  int bytes_read;
  char percent = '\0';
  bytes_read = read(0, (void *)temp, sizeof(temp) - 1);
  if (bytes_read > 0) {
    temp[bytes_read] = '\0';
    sscanf(temp, " %*d/%*d ( %lg%c", current, &percent);
    *current /= 100;
  }
  return (percent == '%') ? 0 : -1;
}


x86 assembly (clang, -O0):
<lame_read_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x1015(%rbp)
lea    -0x1010(%rbp),%rsi
xor    %edi,%edi
mov    $0xfff,%edx
call   1030 <read@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
jle    11a1 <lame_read_stat+0x81>
movslq -0x1014(%rbp),%rax
movb   $0x0,-0x1010(%rbp,%rax,1)
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8b(%rip),%rsi
lea    -0x1015(%rbp),%rcx
call   1040 <sscanf@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe67(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsbl -0x1015(%rbp),%edx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x25,%edx
cmove  %ecx,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lame_read_stat>:
push   %rbx
sub    $0x1010,%rsp
mov    %rdi,%rbx
movb   $0x0,0xf(%rsp)
lea    0x10(%rsp),%rsi
xor    %edi,%edi
mov    $0xfff,%edx
call   1030 <read@plt>
test   %eax,%eax
jle    1183 <lame_read_stat+0x63>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xeb5(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xf(%rsp),%rcx
mov    %rbx,%rdx
call   1040 <sscanf@plt>
movsd  (%rbx),%xmm0
divsd  0xe8f(%rip),%xmm0
movsd  %xmm0,(%rbx)
xor    %eax,%eax
cmpb   $0x25,0xf(%rsp)
setne  %al
neg    %eax
jmp    1188 <lame_read_stat+0x68>
mov    $0xffffffff,%eax
add    $0x1010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c" %*d/%*d ( %lg%c\00"
define i32 @lame_read_stat(double* %0) {
%2 = alloca double*
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = alloca i8
store double* %0, double** %2
store i8 0, i8* %5
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = call i32 @read(i32 0, i8* %6, i32 4095)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %1
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %12
store i8 0, i8* %13
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%15 = load double*, double** %2
%16 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double* %15, i8* %5)
%17 = load double*, double** %2
%18 = load double, double* %17
%19 = fdiv double %18, 1.000000e+02
store double %19, double* %17
br label %20
20: ; preds = %10, %1
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 37
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 0, i32 -1
ret i32 %25
}

LLVM IR (-O2):
@.str = [17 x i8] c" %*d/%*d ( %lg%c\00"
define i32 @lame_read_stat(double* %0) {
%2 = alloca [4096 x i8]
%3 = alloca i8
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
store i8 0, i8* %3
%5 = call i32 @read(i32 0, i8* %4, i32 4095)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = zext i32 %5 to i64
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 %8
store i8 0, i8* %9
%10 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double* %0, i8* %3)
%11 = load double, double* %0
%12 = fdiv double %11, 1.000000e+02
store double %12, double* %0
%13 = load i8, i8* %3
%14 = icmp ne i8 %13, 37
%15 = sext i1 %14 to i32
br label %16
16: ; preds = %7, %1
%17 = phi i32 [ %15, %7 ], [ -1, %1 ]
ret i32 %17
}