#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*/ outbuf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fwrite(char *, size_t, int, int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  int Err = 0;
  static size_t MAXBUF = 1024;
  static size_t MAXFILE = 131072;
  char sbuf[MAXBUF + 1];
  char outbuf[MAXFILE + 1];
  int len = 0;
  int tmp0 = getchar();
  int tmp1 = getchar();
  int tmp2 = getchar();
  int tmp3 = getchar();
  len = tmp3 << 8;
  len = len + tmp2;
  len = len << 8;
  len = len + tmp1;
  len = len << 8;
  len = len + tmp0;
  if ((len < 7) || (len > (int)MAXBUF))
    return 0;
  FILE *pFlog = NULL;
  pFlog = fopen("/home/oleg/Bin/App/NativeClient/nnacl_popen.log", "a");
  int i;
  for (i = 0; i < len; i++) {
    if (i >= (int)MAXBUF)
      break;
    outbuf[i] = (char)getchar();
  }
  outbuf[i] = '\0';
  outbuf[len - 2] = 0;
  sprintf(sbuf, "%s", (outbuf + 8));
  if (pFlog != NULL)
    fprintf(pFlog, "CMD:%s\n", sbuf);
  memset(outbuf, 0, sizeof(outbuf));
  FILE *pipe_writer = NULL;
  if ((pipe_writer = popen(sbuf, "r")) == NULL) {
    sprintf(outbuf + 4, "\"popen error\"");
  } else {
    char *xb = outbuf + 5;
    outbuf[4] = '\"';
    while ((fgets(sbuf, (int)MAXBUF, pipe_writer)) != NULL) {
      size_t lb = strlen(sbuf);
      for (; lb > 0; lb--) {
        if ((sbuf[lb]) < 0x20)
          sbuf[lb] = '\0';
        else
          break;
      }
      if (lb == 0)
        sbuf[lb] = '\0';
      if (strlen(xb) < (MAXFILE - MAXBUF)) {
        strcat(xb, sbuf);
        strcat(xb, "<br>");
      } else {
        strcat(xb, "<br>! Переполнение! <br>");
        break;
      }
    }
    pclose(pipe_writer);
    strcat(xb, "\"");
  }
  size_t outlen = strlen(outbuf + 4);
  if (outlen < 1) {
    sprintf(outbuf + 4, "\"popen return = 0 byte\"");
  } else {
    for (size_t j = 5; j < (outlen + 3); j++) {
      if (outbuf[j] == '\\')
        outbuf[j] = '/';
      if (outbuf[j] == '\"')
        outbuf[j] = '\'';
      if (outbuf[j] == '\t')
        outbuf[j] = ' ';
    }
  }
  outlen = strlen(outbuf + 4);
  tmp0 = (int)(outlen & 0xFFFFFFFF);
  outbuf[0] = (char)(tmp0 & 0xff);
  tmp0 = tmp0 >> 8;
  outbuf[1] = (char)(tmp0 & 0xff);
  tmp0 = tmp0 >> 8;
  outbuf[2] = (char)(tmp0 & 0xff);
  tmp0 = tmp0 >> 8;
  outbuf[3] = (char)(tmp0 & 0xff);
  outlen = strlen(outbuf + 4);
  outlen += 4;
  fwrite(outbuf, outlen, 1, stdout);
  if (pFlog)
    fclose(pFlog);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e99(%rip),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2e70(%rip),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,-0x3c(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,-0x40(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x7,-0x34(%rbp)
jl     12c3 <main+0x103>
mov    -0x34(%rbp),%eax
mov    0x2dc5(%rip),%rcx
cmp    %ecx,%eax
jle    12d6 <main+0x116>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    16dc <main+0x51c>
movq   $0x0,-0x50(%rbp)
lea    0xd1b(%rip),%rdi
lea    0xd44(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1346 <main+0x186>
mov    -0x54(%rbp),%eax
mov    0x2d6e(%rip),%rcx
cmp    %ecx,%eax
jl     131f <main+0x15f>
jmp    1346 <main+0x186>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
mov    %cl,%dl
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12fc <main+0x13c>
mov    -0x98(%rbp),%rdi
mov    -0x88(%rbp),%rdx
movslq -0x54(%rbp),%rax
movb   $0x0,(%rdx,%rax,1)
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
cltq
movb   $0x0,(%rdx,%rax,1)
add    $0x8,%rdx
lea    0xcbf(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
cmpq   $0x0,-0x50(%rbp)
je     139c <main+0x1dc>
mov    -0x98(%rbp),%rdx
mov    -0x50(%rbp),%rdi
lea    0xc9e(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    -0x98(%rbp),%rdi
movq   $0x0,-0x60(%rbp)
lea    0xc74(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    13fa <main+0x23a>
mov    -0x88(%rbp),%rdi
add    $0x4,%rdi
lea    0xc51(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1527 <main+0x367>
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x5,%rcx
mov    %rcx,-0x68(%rbp)
movb   $0x22,0x4(%rax)
mov    -0x98(%rbp),%rdi
mov    0x2c62(%rip),%rax
mov    %eax,%esi
mov    -0x60(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     150e <main+0x34e>
mov    -0x98(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jbe    1495 <main+0x2d5>
mov    -0x98(%rbp),%rax
mov    -0x70(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    147a <main+0x2ba>
mov    -0x98(%rbp),%rax
mov    -0x70(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    147f <main+0x2bf>
jmp    1495 <main+0x2d5>
jmp    1484 <main+0x2c4>
mov    -0x70(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x70(%rbp)
jmp    1443 <main+0x283>
cmpq   $0x0,-0x70(%rbp)
jne    14af <main+0x2ef>
mov    -0x98(%rbp),%rax
mov    -0x70(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x68(%rbp),%rdi
call   1040 <strlen@plt>
mov    0x2bc9(%rip),%rcx
sub    0x2bba(%rip),%rcx
cmp    %rcx,%rax
jae    14f4 <main+0x334>
mov    -0x98(%rbp),%rsi
mov    -0x68(%rbp),%rdi
call   10c0 <strcat@plt>
mov    -0x68(%rbp),%rdi
lea    0xb83(%rip),%rsi
call   10c0 <strcat@plt>
jmp    1509 <main+0x349>
mov    -0x68(%rbp),%rdi
lea    0xb4e(%rip),%rsi
call   10c0 <strcat@plt>
jmp    150e <main+0x34e>
jmp    1410 <main+0x250>
mov    -0x60(%rbp),%rdi
call   1050 <pclose@plt>
mov    -0x68(%rbp),%rdi
lea    0xb66(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x88(%rbp),%rdi
add    $0x4,%rdi
call   1040 <strlen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x1,-0x78(%rbp)
jae    1564 <main+0x3a4>
mov    -0x88(%rbp),%rdi
add    $0x4,%rdi
lea    0xb1a(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1611 <main+0x451>
movq   $0x5,-0x80(%rbp)
mov    -0x80(%rbp),%rax
mov    -0x78(%rbp),%rcx
add    $0x3,%rcx
cmp    %rcx,%rax
jae    160c <main+0x44c>
mov    -0x88(%rbp),%rax
mov    -0x80(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    15a8 <main+0x3e8>
mov    -0x88(%rbp),%rax
mov    -0x80(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
mov    -0x80(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    15cf <main+0x40f>
mov    -0x88(%rbp),%rax
mov    -0x80(%rbp),%rcx
movb   $0x27,(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
mov    -0x80(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    15f6 <main+0x436>
mov    -0x88(%rbp),%rax
mov    -0x80(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    15fb <main+0x43b>
mov    -0x80(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
jmp    156c <main+0x3ac>
jmp    1611 <main+0x451>
mov    -0x88(%rbp),%rdi
add    $0x4,%rdi
call   1040 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    %rax,-0x78(%rbp)
movabs $0xffffffff,%rax
and    -0x78(%rbp),%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %al,(%rdi)
mov    -0x38(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %al,0x1(%rdi)
mov    -0x38(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %al,0x2(%rdi)
mov    -0x38(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
and    $0xff,%eax
mov    %al,0x3(%rdi)
add    $0x4,%rdi
call   1040 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rsi
mov    0x2932(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   10e0 <fwrite@plt>
cmpq   $0x0,-0x50(%rbp)
je     16ce <main+0x50e>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20418,%rsp
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %eax,%r12d
shl    $0x8,%r12d
add    %ebp,%r12d
shl    $0x8,%r12d
add    %r15d,%r12d
shl    $0x8,%r12d
lea    (%r12,%r14,1),%eax
add    $0xfffffbff,%eax
cmp    $0xfffffc06,%eax
jb     1517 <main+0x357>
add    %r14d,%r12d
lea    0xdd8(%rip),%rdi
lea    0xe01(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
mov    %r12d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %al,0x410(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1240 <main+0x80>
movb   $0x0,0x410(%rsp,%rbp,1)
add    $0xfffffffe,%r12d
movb   $0x0,0x410(%rsp,%r12,1)
lea    0x418(%rsp),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
test   %r14,%r14
je     1293 <main+0xd3>
lea    0xdaa(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
call   10a0 <fprintf@plt>
lea    0x410(%rsp),%rdi
xor    %esi,%esi
mov    $0x20001,%edx
call   1070 <memset@plt>
lea    0xd8c(%rip),%rsi
mov    %rsp,%rdi
call   10b0 <popen@plt>
test   %rax,%rax
je     1361 <main+0x1a1>
mov    %rax,%r15
lea    0x415(%rsp),%r12
movb   $0x22,0x414(%rsp)
22
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1396 <main+0x1d6>
mov    %rsp,%rbx
lea    0xd75(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
je     1320 <main+0x160>
nopl   (%rax)
cmpb   $0x1f,(%rsp,%rax,1)
jg     1324 <main+0x164>
movb   $0x0,(%rsp,%rax,1)
add    $0xffffffffffffffff,%rax
jne    1310 <main+0x150>
movb   $0x0,(%rsp)
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    $0x1fc00,%rax
jae    1387 <main+0x1c7>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1300 <main+0x140>
jmp    1396 <main+0x1d6>
movabs $0x22726f72726520,%rax
mov    %rax,0x41a(%rsp)
movabs $0x65206e65706f7022,%rax
6e 20 65
mov    %rax,0x414(%rsp)
jmp    13ad <main+0x1ed>
lea    0xcbc(%rip),%rsi
mov    %r12,%rdi
call   10d0 <strcat@plt>
mov    %r15,%rdi
call   1060 <pclose@plt>
lea    0xce0(%rip),%rsi
mov    %r12,%rdi
call   10d0 <strcat@plt>
lea    0x414(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
je     1409 <main+0x249>
lea    -0x3(%rax),%rcx
cmp    $0xfffffffffffffff9,%rcx
ja     14d4 <main+0x314>
mov    $0x5,%ecx
cmp    $0x3,%rax
jne    1427 <main+0x267>
test   $0x1,%al
je     14d4 <main+0x314>
mov    0x410(%rsp,%rcx,1),%al
cmp    $0x5c,%al
je     14c7 <main+0x307>
cmp    $0x22,%al
je     14cb <main+0x30b>
cmp    $0x9,%al
jne    14d4 <main+0x314>
mov    $0x20,%al
jmp    14cd <main+0x30d>
movups 0xc5f(%rip),%xmm0
movups %xmm0,0x0(%rbp)
movabs $0x22657479622030,%rax
mov    %rax,0x10(%rbp)
jmp    14d4 <main+0x314>
mov    %rax,%rdx
add    $0xfffffffffffffffe,%rdx
and    $0xfffffffffffffffe,%rdx
neg    %rdx
mov    $0x5,%ecx
jmp    145b <main+0x29b>
nopl   0x0(%rax)
mov    $0x27,%bl
mov    %bl,0x411(%rsp,%rcx,1)
lea    (%rdx,%rcx,1),%rsi
add    $0x2,%rsi
add    $0x2,%rcx
cmp    $0x5,%rsi
je     13db <main+0x21b>
movzbl 0x410(%rsp,%rcx,1),%ebx
cmp    $0x9,%bl
je     1480 <main+0x2c0>
cmp    $0x5c,%bl
je     1490 <main+0x2d0>
cmp    $0x22,%bl
jne    1499 <main+0x2d9>
mov    $0x27,%bl
jmp    1492 <main+0x2d2>
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%bl
jmp    1492 <main+0x2d2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2f,%bl
mov    %bl,0x410(%rsp,%rcx,1)
movzbl 0x411(%rsp,%rcx,1),%ebx
cmp    $0x5c,%bl
je     14c0 <main+0x300>
cmp    $0x22,%bl
je     1440 <main+0x280>
cmp    $0x9,%bl
jne    1449 <main+0x289>
mov    $0x20,%bl
jmp    1442 <main+0x282>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2f,%bl
jmp    1442 <main+0x282>
mov    $0x2f,%al
jmp    14cd <main+0x30d>
mov    $0x27,%al
mov    %al,0x410(%rsp,%rcx,1)
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,0x410(%rsp)
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x4(%rax),%rsi
mov    0x2aea(%rip),%rax
mov    (%rax),%ecx
lea    0x410(%rsp),%rdi
mov    $0x1,%edx
call   10e0 <fwrite@plt>
test   %r14,%r14
je     1517 <main+0x357>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.MAXBUF = internal global i64 1024
@main.MAXFILE = internal global i64 131072
@.str = [48 x i8] c"/home/oleg/Bin/App/NativeClient/nnacl_popen.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [8 x i8] c"CMD:%s\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [14 x i8] c"\22popen error\22\00"
@.str.6 = [5 x i8] c"<br>\00"
@.str.7 = [37 x i8] c"<br>! \D0\9F\D0\B5\D1\80\D0\B5\D0\BF\D0\BE\D0\BB\D0\BD\D0\B5\D0\BD\D0\B8\D0\B5! <br>\00"
@.str.8 = [2 x i8] c"\22\00"
@.str.9 = [24 x i8] c"\22popen return = 0 byte\22\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%23 = load i64, i64* @main.MAXBUF
%24 = add i64 %23, 1
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %7
%26 = alloca i8, i64 %24
store i64 %24, i64* %8
%27 = load i64, i64* @main.MAXFILE
%28 = add i64 %27, 1
%29 = alloca i8, i64 %28
store i64 %28, i64* %9
store i32 0, i32* %10
%30 = call i32 (...) @getchar()
store i32 %30, i32* %11
%31 = call i32 (...) @getchar()
store i32 %31, i32* %12
%32 = call i32 (...) @getchar()
store i32 %32, i32* %13
%33 = call i32 (...) @getchar()
store i32 %33, i32* %14
%34 = load i32, i32* %14
%35 = shl i32 %34, 8
store i32 %35, i32* %10
%36 = load i32, i32* %10
%37 = load i32, i32* %13
%38 = add nsw i32 %36, %37
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = shl i32 %39, 8
store i32 %40, i32* %10
%41 = load i32, i32* %10
%42 = load i32, i32* %12
%43 = add nsw i32 %41, %42
store i32 %43, i32* %10
%44 = load i32, i32* %10
%45 = shl i32 %44, 8
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = load i32, i32* %11
%48 = add nsw i32 %46, %47
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = icmp slt i32 %49, 7
br i1 %50, label %56, label %51
51: ; preds = %2
%52 = load i32, i32* %10
%53 = load i64, i64* @main.MAXBUF
%54 = trunc i64 %53 to i32
%55 = icmp sgt i32 %52, %54
br i1 %55, label %56, label %57
56: ; preds = %51, %2
store i32 0, i32* %3
store i32 1, i32* %15
br label %243
57: ; preds = %51
store i32* null, i32** %16
%58 = call i32* @fopen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %58, i32** %16
store i32 0, i32* %17
br label %59
59: ; preds = %75, %57
%60 = load i32, i32* %17
%61 = load i32, i32* %10
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %78
63: ; preds = %59
%64 = load i32, i32* %17
%65 = load i64, i64* @main.MAXBUF
%66 = trunc i64 %65 to i32
%67 = icmp sge i32 %64, %66
br i1 %67, label %68, label %69
68: ; preds = %63
br label %78
69: ; preds = %63
%70 = call i32 (...) @getchar()
%71 = trunc i32 %70 to i8
%72 = load i32, i32* %17
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %29, i64 %73
store i8 %71, i8* %74
br label %75
75: ; preds = %69
%76 = load i32, i32* %17
%77 = add nsw i32 %76, 1
store i32 %77, i32* %17
br label %59
78: ; preds = %68, %59
%79 = load i32, i32* %17
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %29, i64 %80
store i8 0, i8* %81
%82 = load i32, i32* %10
%83 = sub nsw i32 %82, 2
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %29, i64 %84
store i8 0, i8* %85
%86 = getelementptr inbounds i8, i8* %29, i64 8
%87 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %86)
%88 = load i32*, i32** %16
%89 = icmp ne i32* %88, null
br i1 %89, label %90, label %93
90: ; preds = %78
%91 = load i32*, i32** %16
%92 = call i32 @fprintf(i32* %91, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %93
93: ; preds = %90, %78
%94 = trunc i64 %28 to i32
%95 = call i32 @memset(i8* %29, i32 0, i32 %94)
store i32* null, i32** %18
%96 = call i32* @popen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %96, i32** %18
%97 = icmp eq i32* %96, null
br i1 %97, label %98, label %101
98: ; preds = %93
%99 = getelementptr inbounds i8, i8* %29, i64 4
%100 = call i32 (i8*, i8*, ...) @sprintf(i8* %99, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %156
101: ; preds = %93
%102 = getelementptr inbounds i8, i8* %29, i64 5
store i8* %102, i8** %19
%103 = getelementptr inbounds i8, i8* %29, i64 4
store i8 34, i8* %103
br label %104
104: ; preds = %150, %101
%105 = load i64, i64* @main.MAXBUF
%106 = trunc i64 %105 to i32
%107 = load i32*, i32** %18
%108 = call i32* @fgets(i8* %26, i32 %106, i32* %107)
%109 = icmp ne i32* %108, null
br i1 %109, label %110, label %151
110: ; preds = %104
%111 = call i64 @strlen(i8* %26)
store i64 %111, i64* %20
br label %112
112: ; preds = %126, %110
%113 = load i64, i64* %20
%114 = icmp ugt i64 %113, 0
br i1 %114, label %115, label %129
115: ; preds = %112
%116 = load i64, i64* %20
%117 = getelementptr inbounds i8, i8* %26, i64 %116
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp slt i32 %119, 32
br i1 %120, label %121, label %124
121: ; preds = %115
%122 = load i64, i64* %20
%123 = getelementptr inbounds i8, i8* %26, i64 %122
store i8 0, i8* %123
br label %125
124: ; preds = %115
br label %129
125: ; preds = %121
br label %126
126: ; preds = %125
%127 = load i64, i64* %20
%128 = add i64 %127, -1
store i64 %128, i64* %20
br label %112
129: ; preds = %124, %112
%130 = load i64, i64* %20
%131 = icmp eq i64 %130, 0
br i1 %131, label %132, label %135
132: ; preds = %129
%133 = load i64, i64* %20
%134 = getelementptr inbounds i8, i8* %26, i64 %133
store i8 0, i8* %134
br label %135
135: ; preds = %132, %129
%136 = load i8*, i8** %19
%137 = call i64 @strlen(i8* %136)
%138 = load i64, i64* @main.MAXFILE
%139 = load i64, i64* @main.MAXBUF
%140 = sub i64 %138, %139
%141 = icmp ult i64 %137, %140
br i1 %141, label %142, label %147
142: ; preds = %135
%143 = load i8*, i8** %19
%144 = call i32 @strcat(i8* %143, i8* %26)
%145 = load i8*, i8** %19
%146 = call i32 @strcat(i8* %145, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %150
147: ; preds = %135
%148 = load i8*, i8** %19
%149 = call i32 @strcat(i8* %148, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %151
150: ; preds = %142
br label %104
151: ; preds = %147, %104
%152 = load i32*, i32** %18
%153 = call i32 @pclose(i32* %152)
%154 = load i8*, i8** %19
%155 = call i32 @strcat(i8* %154, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %156
156: ; preds = %151, %98
%157 = getelementptr inbounds i8, i8* %29, i64 4
%158 = call i64 @strlen(i8* %157)
store i64 %158, i64* %21
%159 = load i64, i64* %21
%160 = icmp ult i64 %159, 1
br i1 %160, label %161, label %164
161: ; preds = %156
%162 = getelementptr inbounds i8, i8* %29, i64 4
%163 = call i32 (i8*, i8*, ...) @sprintf(i8* %162, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %202
164: ; preds = %156
store i64 5, i64* %22
br label %165
165: ; preds = %198, %164
%166 = load i64, i64* %22
%167 = load i64, i64* %21
%168 = add i64 %167, 3
%169 = icmp ult i64 %166, %168
br i1 %169, label %170, label %201
170: ; preds = %165
%171 = load i64, i64* %22
%172 = getelementptr inbounds i8, i8* %29, i64 %171
%173 = load i8, i8* %172
%174 = sext i8 %173 to i32
%175 = icmp eq i32 %174, 92
br i1 %175, label %176, label %179
176: ; preds = %170
%177 = load i64, i64* %22
%178 = getelementptr inbounds i8, i8* %29, i64 %177
store i8 47, i8* %178
br label %179
179: ; preds = %176, %170
%180 = load i64, i64* %22
%181 = getelementptr inbounds i8, i8* %29, i64 %180
%182 = load i8, i8* %181
%183 = sext i8 %182 to i32
%184 = icmp eq i32 %183, 34
br i1 %184, label %185, label %188
185: ; preds = %179
%186 = load i64, i64* %22
%187 = getelementptr inbounds i8, i8* %29, i64 %186
store i8 39, i8* %187
br label %188
188: ; preds = %185, %179
%189 = load i64, i64* %22
%190 = getelementptr inbounds i8, i8* %29, i64 %189
%191 = load i8, i8* %190
%192 = sext i8 %191 to i32
%193 = icmp eq i32 %192, 9
br i1 %193, label %194, label %197
194: ; preds = %188
%195 = load i64, i64* %22
%196 = getelementptr inbounds i8, i8* %29, i64 %195
store i8 32, i8* %196
br label %197
197: ; preds = %194, %188
br label %198
198: ; preds = %197
%199 = load i64, i64* %22
%200 = add i64 %199, 1
store i64 %200, i64* %22
br label %165
201: ; preds = %165
br label %202
202: ; preds = %201, %161
%203 = getelementptr inbounds i8, i8* %29, i64 4
%204 = call i64 @strlen(i8* %203)
store i64 %204, i64* %21
%205 = load i64, i64* %21
%206 = and i64 %205, 4294967295
%207 = trunc i64 %206 to i32
store i32 %207, i32* %11
%208 = load i32, i32* %11
%209 = and i32 %208, 255
%210 = trunc i32 %209 to i8
%211 = getelementptr inbounds i8, i8* %29, i64 0
store i8 %210, i8* %211
%212 = load i32, i32* %11
%213 = ashr i32 %212, 8
store i32 %213, i32* %11
%214 = load i32, i32* %11
%215 = and i32 %214, 255
%216 = trunc i32 %215 to i8
%217 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %216, i8* %217
%218 = load i32, i32* %11
%219 = ashr i32 %218, 8
store i32 %219, i32* %11
%220 = load i32, i32* %11
%221 = and i32 %220, 255
%222 = trunc i32 %221 to i8
%223 = getelementptr inbounds i8, i8* %29, i64 2
store i8 %222, i8* %223
%224 = load i32, i32* %11
%225 = ashr i32 %224, 8
store i32 %225, i32* %11
%226 = load i32, i32* %11
%227 = and i32 %226, 255
%228 = trunc i32 %227 to i8
%229 = getelementptr inbounds i8, i8* %29, i64 3
store i8 %228, i8* %229
%230 = getelementptr inbounds i8, i8* %29, i64 4
%231 = call i64 @strlen(i8* %230)
store i64 %231, i64* %21
%232 = load i64, i64* %21
%233 = add i64 %232, 4
store i64 %233, i64* %21
%234 = load i64, i64* %21
%235 = load i32, i32* @stdout
%236 = call i32 @fwrite(i8* %29, i64 %234, i32 1, i32 %235)
%237 = load i32*, i32** %16
%238 = icmp ne i32* %237, null
br i1 %238, label %239, label %242
239: ; preds = %202
%240 = load i32*, i32** %16
%241 = call i32 @fclose(i32* %240)
br label %242
242: ; preds = %239, %202
store i32 0, i32* %3
store i32 1, i32* %15
br label %243
243: ; preds = %242, %56
%244 = load i8*, i8** %7
%245 = load i32, i32* %3
ret i32 %245
}

LLVM IR (-O2):
@.str = [48 x i8] c"/home/oleg/Bin/App/NativeClient/nnacl_popen.log\00"
@.str.1 = [2 x i8] c"a\00"
@.str.3 = [8 x i8] c"CMD:%s\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [14 x i8] c"\22popen error\22\00"
@.str.6 = [5 x i8] c"<br>\00"
@.str.7 = [37 x i8] c"<br>! \D0\9F\D0\B5\D1\80\D0\B5\D0\BF\D0\BE\D0\BB\D0\BD\D0\B5\D0\BD\D0\B8\D0\B5! <br>\00"
@.str.8 = [2 x i8] c"\22\00"
@.str.9 = [24 x i8] c"\22popen return = 0 byte\22\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1025 x i8]
%4 = alloca [131073 x i8]
%5 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @getchar()
%8 = tail call i32 (...) @getchar()
%9 = tail call i32 (...) @getchar()
%10 = tail call i32 (...) @getchar()
%11 = shl i32 %10, 8
%12 = add nsw i32 %11, %9
%13 = shl i32 %12, 8
%14 = add nsw i32 %13, %8
%15 = shl i32 %14, 8
%16 = add i32 %15, %7
%17 = add i32 %16, -1025
%18 = icmp ult i32 %17, -1018
br i1 %18, label %139, label %19
19: ; preds = %2
%20 = tail call i32* @fopen(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = zext i32 %16 to i64
br label %22
22: ; preds = %19, %22
%23 = phi i64 [ 0, %19 ], [ %27, %22 ]
%24 = tail call i32 (...) @getchar()
%25 = trunc i32 %24 to i8
%26 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 %23
store i8 %25, i8* %26
%27 = add nuw nsw i64 %23, 1
%28 = icmp eq i64 %27, %21
br i1 %28, label %29, label %22
29: ; preds = %22
%30 = zext i32 %16 to i64
%31 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 %30
store i8 0, i8* %31
%32 = add nsw i32 %16, -2
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 %33
store i8 0, i8* %34
%35 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 8
%36 = call i8* @strcpy(i8* %6, i8* %35)
%37 = icmp eq i32* %20, null
br i1 %37, label %40, label %38
38: ; preds = %29
%39 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %40
40: ; preds = %38, %29
%41 = call i32 @memset(i8* %5, i32 0, i32 131073)
%42 = call i32* @popen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 4
br label %76
46: ; preds = %40
%47 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 5
%48 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 4
store i8 34, i8* %48
%49 = call i32* @fgets(i8* %6, i32 1024, i32* %42)
%50 = icmp eq i32* %49, null
br i1 %50, label %73, label %51
51: ; preds = %46, %68
%52 = call i64 @strlen(i8* %6)
%53 = icmp eq i64 %52, 0
br i1 %53, label %62, label %54
54: ; preds = %51, %59
%55 = phi i64 [ %60, %59 ], [ %52, %51 ]
%56 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = icmp slt i8 %57, 32
br i1 %58, label %59, label %63
59: ; preds = %54
store i8 0, i8* %56
%60 = add i64 %55, -1
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %54
62: ; preds = %59, %51
store i8 0, i8* %6
br label %63
63: ; preds = %54, %62
%64 = call i64 @strlen(i8* %47)
%65 = icmp ult i64 %64, 130048
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @strcat(i8* %47, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %73
68: ; preds = %63
%69 = call i32 @strcat(i8* %47, i8* %6)
%70 = call i32 @strcat(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%71 = call i32* @fgets(i8* %6, i32 1024, i32* %42)
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %51
73: ; preds = %68, %46, %66
%74 = call i32 @pclose(i32* %42)
%75 = call i32 @strcat(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %76
76: ; preds = %73, %44
%77 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 4
%78 = call i64 @strlen(i8* %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %89, label %80
80: ; preds = %76
%81 = add i64 %78, -3
%82 = icmp ult i64 %81, -6
br i1 %82, label %83, label %121
83: ; preds = %80
%84 = and i64 %78, 1
%85 = icmp eq i64 %78, 3
br i1 %85, label %111, label %86
86: ; preds = %83
%87 = add i64 %78, -2
%88 = and i64 %87, -2
br label %90
89: ; preds = %76
br label %121
90: ; preds = %107, %86
%91 = phi i64 [ 5, %86 ], [ %108, %107 ]
%92 = phi i64 [ 0, %86 ], [ %109, %107 ]
%93 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 %91
%94 = load i8, i8* %93
switch i8 %94, label %99 [
i8 92, label %97
i8 34, label %95
i8 9, label %96
]
95: ; preds = %90
br label %97
96: ; preds = %90
br label %97
97: ; preds = %90, %96, %95
%98 = phi i8 [ 39, %95 ], [ 32, %96 ], [ 47, %90 ]
store i8 %98, i8* %93
br label %99
99: ; preds = %97, %90
%100 = add nuw i64 %91, 1
%101 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 %100
%102 = load i8, i8* %101
switch i8 %102, label %107 [
i8 92, label %105
i8 34, label %104
i8 9, label %103
]
103: ; preds = %99
br label %105
104: ; preds = %99
br label %105
105: ; preds = %104, %103, %99
%106 = phi i8 [ 39, %104 ], [ 32, %103 ], [ 47, %99 ]
store i8 %106, i8* %101
br label %107
107: ; preds = %105, %99
%108 = add nuw i64 %91, 2
%109 = add i64 %92, 2
%110 = icmp eq i64 %109, %88
br i1 %110, label %111, label %90
111: ; preds = %107, %83
%112 = phi i64 [ 5, %83 ], [ %108, %107 ]
%113 = icmp eq i64 %84, 0
br i1 %113, label %121, label %114
114: ; preds = %111
%115 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 %112
%116 = load i8, i8* %115
switch i8 %116, label %121 [
i8 92, label %119
i8 34, label %118
i8 9, label %117
]
117: ; preds = %114
br label %119
118: ; preds = %114
br label %119
119: ; preds = %118, %117, %114
%120 = phi i8 [ 39, %118 ], [ 32, %117 ], [ 47, %114 ]
store i8 %120, i8* %115
br label %121
121: ; preds = %111, %119, %114, %80, %89
%122 = call i64 @strlen(i8* %77)
%123 = trunc i64 %122 to i8
store i8 %123, i8* %5
%124 = lshr i64 %122, 8
%125 = trunc i64 %124 to i8
%126 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 1
store i8 %125, i8* %126
%127 = lshr i64 %122, 16
%128 = trunc i64 %127 to i8
%129 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 2
store i8 %128, i8* %129
%130 = lshr i64 %122, 24
%131 = trunc i64 %130 to i8
%132 = getelementptr inbounds [131073 x i8], [131073 x i8]* %4, i64 0, i64 3
store i8 %131, i8* %132
%133 = call i64 @strlen(i8* %77)
%134 = add i64 %133, 4
%135 = load i32, i32* @stdout
%136 = call i32 @fwrite(i8* %5, i64 %134, i32 1, i32 %135)
br i1 %37, label %139, label %137
137: ; preds = %121
%138 = call i32 @fclose(i32* %20)
br label %139
139: ; preds = %121, %137, %2
ret i32 0
}