#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 *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
char getchar();
int /*<<< orphan*/ printf(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 + 9);
  else
    i = 0;
  printf("vmudtest.value %i\n", i);
  fp = fopen("/tmp/file3.txt", "a");
  if (fp != NULL) {
    fprintf(fp, "vmudtest.value %i\n", i);
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     11a9 <main+0x39>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    132a <main+0x1ba>
movl   $0x0,-0x4e44(%rbp)
movl   $0x0,-0x4e34(%rbp)
cmpl   $0x4e20,-0x4e34(%rbp)
jge    11f0 <main+0x80>
movslq -0x4e34(%rbp),%rax
movb   $0x0,-0x4e30(%rbp,%rax,1)
mov    -0x4e34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e34(%rbp)
jmp    11bd <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    1238 <main+0xc8>
cmpl   $0x1,-0x4e44(%rbp)
jne    1229 <main+0xb9>
jmp    127c <main+0x10c>
movl   $0x1,-0x4e44(%rbp)
jmp    1242 <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     1277 <main+0x107>
jmp    127c <main+0x10c>
jmp    11fa <main+0x8a>
lea    -0x4e30(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x4e40(%rbp)
cmpq   $0x0,-0x4e40(%rbp)
je     12bf <main+0x14f>
mov    -0x4e40(%rbp),%rdi
add    $0x9,%rdi
call   1080 <atoi@plt>
mov    %eax,-0x4e34(%rbp)
jmp    12c9 <main+0x159>
movl   $0x0,-0x4e34(%rbp)
mov    -0x4e34(%rbp),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf2(%rip),%rdi
lea    0xdfa(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x4e50(%rbp)
cmpq   $0x0,-0x4e50(%rbp)
je     132a <main+0x1ba>
mov    -0x4e50(%rbp),%rdi
mov    -0x4e34(%rbp),%edx
lea    0xdaa(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x4e50(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x4e20,%rsp
cmp    $0x1,%edi
jle    11b7 <main+0x27>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%r14d
jmp    126a <main+0xda>
mov    %rsp,%rdi
mov    $0x4e20,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11e2 <main+0x52>
nopl   0x0(%rax)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %ecx,%ebp
cmp    $0x4e1f,%rbx
je     11fc <main+0x6c>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    $0x0,%ecx
cmp    $0xff,%al
jne    11d0 <main+0x40>
mov    $0x1,%ecx
cmp    $0x1,%ebp
jne    11d0 <main+0x40>
lea    0xdfd(%rip),%rsi
mov    %rsp,%rdi
call   10b0 <strstr@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %rax,%rax
je     1226 <main+0x96>
add    $0x9,%rax
mov    %rax,%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
lea    0xde4(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde7(%rip),%rdi
lea    0xdef(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     126a <main+0xda>
mov    %rax,%rbx
lea    0xdb9(%rip),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x4e20,%rsp
pop    %rbx
pop    %r14
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 = [17 x i8] c"\C3\93\C3\8D\C3\85\C3\92\C3\94\C3\8E\C3\99\C3\88\00"
@.str.2 = [19 x i8] c"vmudtest.value %i\0A\00"
@.str.3 = [15 x i8] c"/tmp/file3.txt\00"
@.str.4 = [2 x i8] c"a\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 %70
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 ([17 x i8], [17 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 %57
53: ; preds = %48
%54 = load i8*, i8** %7
%55 = getelementptr inbounds i8, i8* %54, i64 9
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %5
br label %58
57: ; preds = %48
store i32 0, i32* %5
br label %58
58: ; preds = %57, %53
%59 = load i32, i32* %5
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %59)
%61 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %61, i32** %9
%62 = load i32*, i32** %9
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %70
64: ; preds = %58
%65 = load i32*, i32** %9
%66 = load i32, i32* %5
%67 = call i32 @fprintf(i32* %65, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %66)
%68 = load i32*, i32** %9
%69 = call i32 @fclose(i32* %68)
br label %70
70: ; preds = %12, %64, %58
%71 = load i32, i32* %2
ret i32 %71
}

LLVM IR (-O2):
@.str.1 = [17 x i8] c"\C3\93\C3\8D\C3\85\C3\92\C3\94\C3\8E\C3\99\C3\88\00"
@.str.2 = [19 x i8] c"vmudtest.value %i\0A\00"
@.str.3 = [15 x i8] c"/tmp/file3.txt\00"
@.str.4 = [2 x i8] c"a\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 %35
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 ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %22, i64 9
%26 = call i32 @atoi(i8* %25)
br label %27
27: ; preds = %21, %24
%28 = phi i32 [ %26, %24 ], [ 0, %21 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %35, label %32
32: ; preds = %27
%33 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%34 = call i32 @fclose(i32* %30)
br label %35
35: ; preds = %27, %32, %7
%36 = phi i32 [ 2, %7 ], [ 0, %32 ], [ 0, %27 ]
ret i32 %36
}