#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 */
unsigned int atoi(char *);
int read(int /*<<< orphan*/, void *, int);
int l3enc_read_stat(unsigned int *percent) {
  char temp[4096];
  char *string1;
  int bytes_read;
  bytes_read = read(0, (void *)temp, sizeof(temp));
  if (bytes_read > 22) {
    string1 = temp + 22;
    string1[3] = 0;
    *percent = atoi(string1);
    return (0);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<l3enc_read_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1010(%rbp),%rsi
xor    %edi,%edi
mov    $0x1000,%edx
call   1030 <read@plt>
mov    %eax,-0x101c(%rbp)
cmpl   $0x16,-0x101c(%rbp)
jle    1192 <l3enc_read_stat+0x72>
lea    -0x1010(%rbp),%rax
add    $0x16,%rax
mov    %rax,-0x1018(%rbp)
mov    -0x1018(%rbp),%rax
movb   $0x0,0x3(%rax)
mov    -0x1018(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1199 <l3enc_read_stat+0x79>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l3enc_read_stat>:
push   %rbx
sub    $0x1000,%rsp
mov    %rdi,%rbx
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x1000,%edx
call   1030 <read@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x17,%ecx
jl     1159 <l3enc_read_stat+0x39>
lea    0x16(%rsp),%rdi
movb   $0x0,0x19(%rsp)
call   1040 <atoi@plt>
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @l3enc_read_stat(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [4096 x i8]
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%8 = call i32 @read(i32 0, i8* %7, i32 4096)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 22
br i1 %10, label %11, label %19
11: ; preds = %1
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds i8, i8* %12, i64 22
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 3
store i8 0, i8* %15
%16 = load i8*, i8** %5
%17 = call i32 @atoi(i8* %16)
%18 = load i32*, i32** %3
store i32 %17, i32* %18
store i32 0, i32* %2
br label %20
19: ; preds = %1
store i32 -1, i32* %2
br label %20
20: ; preds = %19, %11
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
define i32 @l3enc_read_stat(i32* nocapture writeonly %0) {
%2 = alloca [4096 x i8]
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 0, i8* %3, i32 4096)
%5 = icmp sgt i32 %4, 22
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 22
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 25
store i8 0, i8* %8
%9 = call i32 @atoi(i8* %7)
store i32 %9, i32* %0
br label %10
10: ; preds = %1, %6
%11 = phi i32 [ 0, %6 ], [ -1, %1 ]
ret i32 %11
}