#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 */
scalar_t__ aEncoder_read_stat(int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_msg(int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(double);
int main(int argc, char **argv) {
  int begin, length;
  int current;
  if (argc != 3) {
    fprintf(stderr,
            "This is ripperX plugin for the ISO encoder version 2. Syntax is\n"
            "ripperX_plugin-encoder beginning_sector length_in_sector\n");
    exit(1);
  }
  sscanf(argv[1], "%d", &begin);
  sscanf(argv[2], "%d", &length);
  print_msg(length, 0);
  while (1) {
    if (aEncoder_read_stat(&current) == 0)
      print_msg(length, current);
    usleep(0.5 * 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)
cmpl   $0x3,-0x8(%rbp)
je     119f <main+0x3f>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xed4(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xebc(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x18(%rbp),%edi
xor    %esi,%esi
call   1050 <print_msg@plt>
lea    -0x1c(%rbp),%rdi
call   1070 <aEncoder_read_stat@plt>
cmp    $0x0,%rax
jne    11f7 <main+0x97>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <print_msg@plt>
movsd  0xe01(%rip),%xmm0
call   1080 <usleep@plt>
jmp    11d9 <main+0x79>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    11d9 <main+0x79>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xf08(%rip),%r14
lea    0x14(%rsp),%rdx
mov    %r14,%rsi
call   1040 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0xc(%rsp),%rdx
mov    %r14,%rsi
call   1040 <sscanf@plt>
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1050 <print_msg@plt>
lea    0x10(%rsp),%rbx
jmp    11bd <main+0x5d>
nopw   0x0(%rax,%rax,1)
movsd  0xe48(%rip),%xmm0
call   1080 <usleep@plt>
mov    %rbx,%rdi
call   1070 <aEncoder_read_stat@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
call   1050 <print_msg@plt>
jmp    11b0 <main+0x50>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [122 x i8] c"This is ripperX plugin for the ISO encoder version 2. Syntax is\0AripperX_plugin-encoder beginning_sector length_in_sector\0A\00"
@.str.1 = [3 x i8] c"%d\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 i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%24 = load i32, i32* %7
%25 = call i32 @print_msg(i32 %24, i32 0)
br label %26
26: ; preds = %15, %33
%27 = call i64 @aEncoder_read_stat(i32* %8)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @print_msg(i32 %30, i32 %31)
br label %33
33: ; preds = %29, %26
%34 = call i32 @usleep(double 5.000000e+05)
br label %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [122 x i8] c"This is ripperX plugin for the ISO encoder version 2. Syntax is\0AripperX_plugin-encoder beginning_sector length_in_sector\0A\00"
@.str.1 = [3 x i8] c"%d\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 = icmp eq i32 %0, 3
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([122 x i8], [122 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%21 = load i32, i32* %4
%22 = call i32 @print_msg(i32 %21, i32 0)
br label %23
23: ; preds = %30, %14
%24 = call i64 @aEncoder_read_stat(i32* %5)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @print_msg(i32 %27, i32 %28)
br label %30
30: ; preds = %26, %23
%31 = call i32 @usleep(double 5.000000e+05)
br label %23
}