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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ toolame_read_stat(int *);
int /*<<< orphan*/ usleep(double);
int main(int argc, char **argv) {
  int begin, length;
  int current;
  sscanf(argv[1], "%d", &begin);
  sscanf(argv[2], "%d", &length);
  while (1) {
    if (toolame_read_stat(&current) == 0) {
      printf("[P %f]\n", ((double)current / (double)length));
    }
    usleep(0.2 * 1000000);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea3(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
lea    -0x1c(%rbp),%rdi
call   1050 <toolame_read_stat@plt>
cmp    $0x0,%rax
jne    11b3 <main+0x73>
cvtsi2sdl -0x1c(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
movsd  0xe45(%rip),%xmm0
call   1060 <usleep@plt>
jmp    1186 <main+0x46>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xeb3(%rip),%r14
lea    0x14(%rsp),%rdx
mov    %r14,%rsi
call   1040 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0x10(%rsp),%rdx
mov    %r14,%rsi
call   1040 <sscanf@plt>
lea    0xc(%rsp),%rbx
lea    0xe8c(%rip),%r14
jmp    119d <main+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0xe68(%rip),%xmm0
call   1060 <usleep@plt>
mov    %rbx,%rdi
call   1050 <toolame_read_stat@plt>
test   %rax,%rax
jne    1190 <main+0x50>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0x10(%rsp),%xmm1
divsd  %xmm1,%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1190 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"[P %f]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %17
17: ; preds = %2, %27
%18 = call i64 @toolame_read_stat(i32* %8)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to double
%23 = load i32, i32* %7
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %25)
br label %27
27: ; preds = %20, %17
%28 = call i32 @usleep(double 2.000000e+05)
br label %17
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"[P %f]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %15
15: ; preds = %25, %2
%16 = call i64 @toolame_read_stat(i32* %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to double
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to double
%23 = fdiv double %20, %22
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %23)
br label %25
25: ; preds = %18, %15
%26 = call i32 @usleep(double 2.000000e+05)
br label %15
}