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

/* Variables and functions */
int atoi(char *);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
char *strstr(char *, char *);
int main(int argv) {
  char buffer[20000];
  int i;
  char c;
  char *cc;
  int letter_ya;
  FILE *fp;
  if (argv >= 2) {
    printf("This is filtr for munin plugin \"plugin_balderdash_mud.sh\" by "
           "prool\nProol: http://prool.kharkov.org http://mud.kharkov.org "
           "proolix <dog> gmail <dot> com\nExit: control D TWICE!!!\n");
    return 2;
  }
  letter_ya = 0;
  for (i = 0; i < 20000; i++)
    buffer[i] = 0;
  i = 0;
  while (1) {
    c = getchar();
    if (c == -1) {
      if (letter_ya == 1)
        break;
      else
        letter_ya = 1;
    } else
      letter_ya = 0;
    buffer[i++] = c;
    if (i >= (20000 - 1))
      break;
  }
  cc = strstr(buffer, "ÎÁÈÏÄÉÔÓÑ");
  if (cc)
    i = atoi(cc + strlen("ÎÁÈÏÄÉÔÓÑ") + 1);
  else
    i = 0;
  printf("sow.value %i\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1189 <main+0x39>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    12dc <main+0x18c>
movl   $0x0,-0x4e44(%rbp)
movl   $0x0,-0x4e34(%rbp)
cmpl   $0x4e20,-0x4e34(%rbp)
jge    11d0 <main+0x80>
movslq -0x4e34(%rbp),%rax
movb   $0x0,-0x4e30(%rbp,%rax,1)
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e34(%rbp)
jmp    119d <main+0x4d>
movl   $0x0,-0x4e34(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x4e35(%rbp)
movsbl -0x4e35(%rbp),%eax
cmp    $0xffffffff,%eax
jne    1218 <main+0xc8>
cmpl   $0x1,-0x4e44(%rbp)
jne    1209 <main+0xb9>
jmp    125c <main+0x10c>
movl   $0x1,-0x4e44(%rbp)
jmp    1222 <main+0xd2>
movl   $0x0,-0x4e44(%rbp)
mov    -0x4e35(%rbp),%cl
mov    -0x4e34(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x4e34(%rbp)
cltq
mov    %cl,-0x4e30(%rbp,%rax,1)
cmpl   $0x4e1f,-0x4e34(%rbp)
jl     1257 <main+0x107>
jmp    125c <main+0x10c>
jmp    11da <main+0x8a>
lea    -0x4e30(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x4e40(%rbp)
cmpq   $0x0,-0x4e40(%rbp)
je     12be <main+0x16e>
mov    -0x4e40(%rbp),%rax
mov    %rax,-0x4e58(%rbp)
lea    0xe19(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x4e58(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4e34(%rbp)
jmp    12c8 <main+0x178>
movl   $0x0,-0x4e34(%rbp)
mov    -0x4e34(%rbp),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x4e60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x4e28,%rsp
cmp    $0x1,%edi
jle    1194 <main+0x24>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebp
jmp    1225 <main+0xb5>
mov    %rsp,%rdi
mov    $0x4e20,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11c2 <main+0x52>
nopl   0x0(%rax)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %ecx,%ebp
cmp    $0x4e1f,%rbx
je     11dc <main+0x6c>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    $0x0,%ecx
cmp    $0xff,%al
jne    11b0 <main+0x40>
mov    $0x1,%ecx
cmp    $0x1,%ebp
jne    11b0 <main+0x40>
lea    0xe1d(%rip),%rsi
mov    %rsp,%rdi
call   1090 <strstr@plt>
xor    %ebp,%ebp
mov    $0x0,%esi
test   %rax,%rax
je     1217 <main+0xa7>
mov    %rax,%rbx
lea    0xdff(%rip),%rdi
call   1040 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
call   1080 <atoi@plt>
mov    %eax,%esi
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%eax
add    $0x4e28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [178 x i8] c"This is filtr for munin plugin \22plugin_balderdash_mud.sh\22 by prool\0AProol: http://prool.kharkov.org http://mud.kharkov.org proolix <dog> gmail <dot> com\0AExit: control D TWICE!!!\0A\00"
@.str.1 = [19 x i8] c"\C3\8E\C3\81\C3\88\C3\8F\C3\84\C3\89\C3\94\C3\93\C3\91\00"
@.str.2 = [14 x i8] c"sow.value %i\0A\00"
define i32 @main(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20000 x i8]
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %2
store i32 %0, i32* %3
%10 = load i32, i32* %3
%11 = icmp sge i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %2
br label %64
14: ; preds = %1
store i32 0, i32* %8
store i32 0, i32* %5
br label %15
15: ; preds = %22, %14
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 20000
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [20000 x i8], [20000 x i8]* %4, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %18
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %15
25: ; preds = %15
store i32 0, i32* %5
br label %26
26: ; preds = %25, %47
%27 = call signext i8 (...) @getchar()
store i8 %27, i8* %6
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %35
34: ; preds = %31
br label %48
35: ; preds = %31
store i32 1, i32* %8
br label %36
36: ; preds = %35
br label %38
37: ; preds = %26
store i32 0, i32* %8
br label %38
38: ; preds = %37, %36
%39 = load i8, i8* %6
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds [20000 x i8], [20000 x i8]* %4, i64 0, i64 %42
store i8 %39, i8* %43
%44 = load i32, i32* %5
%45 = icmp sge i32 %44, 19999
br i1 %45, label %46, label %47
46: ; preds = %38
br label %48
47: ; preds = %38
br label %26
48: ; preds = %46, %34
%49 = getelementptr inbounds [20000 x i8], [20000 x i8]* %4, i64 0, i64 0
%50 = call i8* @strstr(i8* %49, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i8* %50, i8** %7
%51 = load i8*, i8** %7
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %60
53: ; preds = %48
%54 = load i8*, i8** %7
%55 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = call i32 @atoi(i8* %58)
store i32 %59, i32* %5
br label %61
60: ; preds = %48
store i32 0, i32* %5
br label %61
61: ; preds = %60, %53
%62 = load i32, i32* %5
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %61, %12
%65 = load i32, i32* %2
ret i32 %65
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"\C3\8E\C3\81\C3\88\C3\8F\C3\84\C3\89\C3\94\C3\93\C3\91\00"
@.str.2 = [14 x i8] c"sow.value %i\0A\00"
@str = [177 x i8] c"This is filtr for munin plugin \22plugin_balderdash_mud.sh\22 by prool\0AProol: http://prool.kharkov.org http://mud.kharkov.org proolix <dog> gmail <dot> com\0AExit: control D TWICE!!!\00"
define i32 @main(i32 %0) {
%2 = alloca [20000 x i8]
%3 = getelementptr inbounds [20000 x i8], [20000 x i8]* %2, i64 0, i64 0
%4 = icmp sgt i32 %0, 1
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = getelementptr inbounds [20000 x i8], [20000 x i8]* %2, i64 0, i64 0
br label %9
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([177 x i8], [177 x i8]* @str, i64 0, i64 0))
br label %33
9: ; preds = %5, %16
%10 = phi i64 [ 0, %5 ], [ %18, %16 ]
%11 = phi i32 [ 0, %5 ], [ %17, %16 ]
%12 = tail call signext i8 (...) @getchar()
%13 = icmp eq i8 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = icmp eq i32 %11, 1
br i1 %15, label %21, label %16
16: ; preds = %9, %14
%17 = phi i32 [ 1, %14 ], [ 0, %9 ]
%18 = add nuw nsw i64 %10, 1
%19 = getelementptr inbounds [20000 x i8], [20000 x i8]* %2, i64 0, i64 %10
store i8 %12, i8* %19
%20 = icmp eq i64 %18, 19999
br i1 %20, label %21, label %9
21: ; preds = %16, %14
%22 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %30, label %24
24: ; preds = %21
%25 = call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i32 @atoi(i8* %28)
br label %30
30: ; preds = %21, %24
%31 = phi i32 [ %29, %24 ], [ 0, %21 ]
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %7
%34 = phi i32 [ 2, %7 ], [ 0, %30 ]
ret i32 %34
}