#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 */
double atof(char *);
int read(int /*<<< orphan*/, void *, int);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int lame_read_stat(double *current) {
  char temp[4096];
  char string[100];
  char *string1;
  int bytes_read;
  bytes_read = read(0, (void *)temp, sizeof(temp));
  if (bytes_read > 16) {
    sscanf(&temp[16], "%s%%)|", string);
    *current = atof(string) / 100.0;
    return (0);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<lame_read_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1090,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1010(%rbp),%rsi
xor    %edi,%edi
mov    $0x1000,%edx
call   1040 <read@plt>
mov    %eax,-0x108c(%rbp)
cmpl   $0x10,-0x108c(%rbp)
jle    11af <lame_read_stat+0x7f>
lea    -0x1010(%rbp),%rdi
add    $0x10,%rdi
lea    -0x1080(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1050 <sscanf@plt>
lea    -0x1080(%rbp),%rdi
call   1030 <atof@plt>
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11b6 <lame_read_stat+0x86>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lame_read_stat>:
push   %r14
push   %rbx
sub    $0x1078,%rsp
mov    %rdi,%rbx
lea    0x70(%rsp),%rsi
xor    %edi,%edi
mov    $0x1000,%edx
call   1040 <read@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x11,%ecx
jl     118a <lame_read_stat+0x5a>
lea    0x80(%rsp),%rdi
lea    0xe9f(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdx
call   1050 <sscanf@plt>
mov    %r14,%rdi
call   1030 <atof@plt>
divsd  0xe7c(%rip),%xmm0
movsd  %xmm0,(%rbx)
xor    %eax,%eax
add    $0x1078,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%s%%)|\00"
define i32 @lame_read_stat(double* nocapture writeonly %0) {
%2 = alloca [4096 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i32 @read(i32 0, i8* %4, i32 4096)
%7 = icmp sgt i32 %6, 16
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 16
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %5)
%11 = call double @atof(i8* %5)
%12 = fdiv double %11, 1.000000e+02
store double %12, double* %0
br label %13
13: ; preds = %1, %8
%14 = phi i32 [ 0, %8 ], [ -1, %1 ]
ret i32 %14
}