#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 pid_t;

/* Variables and functions */
int fork();
int getpid();
int getppid();
int /*<<< orphan*/ printf(char *, int);
int main() {
  pid_t pid;
  pid = fork();
  int i;
  if (pid == 0) {
    printf("id сына: %d\n", getpid());
    printf("id отца: %d\n", getppid());
    for (i = 0; i < 10; i++) {
      printf("%d\n", i * 2);
    }
    return 0;
  }
  printf("id отца: %d\n", getpid());
  printf("id сына: %d\n", pid);
  for (i = 100; i > 90; i--) {
    printf("%d\n", i / 2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11ca <main+0x8a>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getppid@plt>
mov    %eax,%esi
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11be <main+0x7e>
mov    -0xc(%rbp),%esi
shl    $0x1,%esi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1194 <main+0x54>
movl   $0x0,-0x4(%rbp)
jmp    122d <main+0xed>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
movl   $0x64,-0xc(%rbp)
cmpl   $0x5a,-0xc(%rbp)
jle    1226 <main+0xe6>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11f5 <main+0xb5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fork@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
test   %ebp,%ebp
je     11c6 <main+0x86>
lea    0xea6(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
movl   $0x2d,0x14(%rsp)
movl   $0x2e,0x10(%rsp)
movl   $0x2f,0x8(%rsp)
mov    $0x30,%r14d
mov    $0x31,%ebp
mov    $0x32,%ebx
mov    $0x31,%r13d
mov    $0x30,%r15d
movl   $0x2f,0x4(%rsp)
movl   $0x2e,0xc(%rsp)
jmp    1228 <main+0xe8>
lea    0xe33(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getppid@plt>
lea    0xe2f(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
movl   $0x12,0x14(%rsp)
movl   $0x10,0xc(%rsp)
movl   $0xe,0x10(%rsp)
movl   $0xc,0x4(%rsp)
movl   $0xa,0x8(%rsp)
mov    $0x8,%r15d
mov    $0x6,%r14d
mov    $0x4,%r13d
mov    $0x2,%ebp
lea    0xdef(%rip),%r12
mov    %r12,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x8(%rsp),%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x4(%rsp),%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0xc(%rsp),%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    0x14(%rsp),%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"id \D1\81\D1\8B\D0\BD\D0\B0: %d\0A\00"
@.str.1 = [17 x i8] c"id \D0\BE\D1\82\D1\86\D0\B0: %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @fork()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %0
%8 = call i32 (...) @getpid()
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 (...) @getppid()
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %10)
store i32 0, i32* %3
br label %12
12: ; preds = %19, %7
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %3
%17 = mul nsw i32 %16, 2
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %15
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %12
22: ; preds = %12
store i32 0, i32* %1
br label %39
23: ; preds = %0
%24 = call i32 (...) @getpid()
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %26)
store i32 100, i32* %3
br label %28
28: ; preds = %35, %23
%29 = load i32, i32* %3
%30 = icmp sgt i32 %29, 90
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* %3
%33 = sdiv i32 %32, 2
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %31
%36 = load i32, i32* %3
%37 = add nsw i32 %36, -1
store i32 %37, i32* %3
br label %28
38: ; preds = %28
store i32 0, i32* %1
br label %39
39: ; preds = %38, %22
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [17 x i8] c"id \D1\81\D1\8B\D0\BD\D0\B0: %d\0A\00"
@.str.1 = [17 x i8] c"id \D0\BE\D1\82\D1\86\D0\B0: %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, 0
%3 = tail call i32 (...) @getpid()
br i1 %2, label %4, label %8
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %3)
%6 = tail call i32 (...) @getppid()
%7 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %11
8: ; preds = %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %11
11: ; preds = %8, %4
%12 = phi i32 [ 50, %8 ], [ 0, %4 ]
%13 = phi i32 [ 49, %8 ], [ 2, %4 ]
%14 = phi i32 [ 49, %8 ], [ 4, %4 ]
%15 = phi i32 [ 48, %8 ], [ 6, %4 ]
%16 = phi i32 [ 48, %8 ], [ 8, %4 ]
%17 = phi i32 [ 47, %8 ], [ 10, %4 ]
%18 = phi i32 [ 47, %8 ], [ 12, %4 ]
%19 = phi i32 [ 46, %8 ], [ 14, %4 ]
%20 = phi i32 [ 46, %8 ], [ 16, %4 ]
%21 = phi i32 [ 45, %8 ], [ 18, %4 ]
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}