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

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
char *strstr(char *, char *);
char *strtok(char *, char *);
int main() {
  FILE *fd;
  char str[100];
  char *istr;
  char *token;
  fd = fopen("/proc/self/status", "r");
  if (fd == NULL) {
    printf("Ошибка открытия файла\n");
    return 1;
  }
  while (!feof(fd)) {
    if (fgets(str, sizeof(str), fd)) {
      istr = strstr(str, "PPid");
      if (istr != NULL) {
        token = strtok(str, "\t");
        int i = 0;
        while (token != NULL) {
          if (i == 1) {
            printf("%s", token);
          }
          token = strtok(NULL, "\t");
          i++;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <main+0x4e>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12a4 <main+0x144>
jmp    11b3 <main+0x53>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d1 <main+0x71>
jmp    129d <main+0x13d>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1298 <main+0x138>
lea    -0x80(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1293 <main+0x133>
lea    -0x80(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x94(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     128e <main+0x12e>
cmpl   $0x1,-0x94(%rbp)
jne    1263 <main+0x103>
mov    -0x90(%rbp),%rsi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd5(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x90(%rbp)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1233 <main+0xd3>
jmp    1293 <main+0x133>
jmp    1298 <main+0x138>
jmp    11b3 <main+0x53>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
lea    0xe7c(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1241 <main+0xd1>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1256 <main+0xe6>
mov    %rsp,%r14
lea    0xe5a(%rip),%r15
lea    0xe58(%rip),%r12
lea    0xe53(%rip),%r13
jmp    11dc <main+0x6c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1254 <main+0xe4>
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11d0 <main+0x60>
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11d0 <main+0x60>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     11d0 <main+0x60>
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
je     11d0 <main+0x60>
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
nopl   (%rax)
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    1230 <main+0xc0>
jmp    11d0 <main+0x60>
lea    0xdd6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    1256 <main+0xe6>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"/proc/self/status\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [42 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D0\BE\D1\82\D0\BA\D1\80\D1\8B\D1\82\D0\B8\D1\8F \D1\84\D0\B0\D0\B9\D0\BB\D0\B0\0A\00"
@.str.3 = [5 x i8] c"PPid\00"
@.str.4 = [2 x i8] c"\09\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %48
12: ; preds = %0
br label %13
13: ; preds = %46, %12
%14 = load i32*, i32** %2
%15 = call i32 @feof(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %47
18: ; preds = %13
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = load i32*, i32** %2
%21 = call i64 @fgets(i8* %19, i32 100, i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %46
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%25 = call i8* @strstr(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %45
28: ; preds = %23
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%30 = call i8* @strtok(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %30, i8** %5
store i32 0, i32* %6
br label %31
31: ; preds = %40, %28
%32 = load i8*, i8** %5
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i8*, i8** %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %37, %34
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %41, i8** %5
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %31
44: ; preds = %31
br label %45
45: ; preds = %44, %23
br label %46
46: ; preds = %45, %18
br label %13
47: ; preds = %13
store i32 0, i32* %1
br label %48
48: ; preds = %47, %10
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [18 x i8] c"/proc/self/status\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [5 x i8] c"PPid\00"
@.str.4 = [2 x i8] c"\09\00"
@.str.5 = [3 x i8] c"%s\00"
@str = [41 x i8] c"\D0\9E\D1\88\D0\B8\D0\B1\D0\BA\D0\B0 \D0\BE\D1\82\D0\BA\D1\80\D1\8B\D1\82\D0\B8\D1\8F \D1\84\D0\B0\D0\B9\D0\BB\D0\B0\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %32
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %32
10: ; preds = %5, %29
%11 = call i64 @fgets(i8* %2, i32 100, i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %29, label %13
13: ; preds = %10
%14 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %29, label %16
16: ; preds = %13
%17 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %29, label %19
19: ; preds = %16
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %22, %26
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %26
29: ; preds = %26, %19, %22, %16, %13, %10
%30 = call i32 @feof(i32* %3)
%31 = icmp eq i32 %30, 0
br i1 %31, label %10, label %32
32: ; preds = %29, %5, %8
%33 = phi i32 [ 1, %8 ], [ 0, %5 ], [ 0, %29 ]
ret i32 %33
}