#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
long LONG_MAX;
long LONG_MIN;
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getpid();
int getppid();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
long strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  long int Number = 0;
  switch (argc) {
  case 1: {
    fprintf(stderr, "No argumnets\n");
    exit(EXIT_FAILURE);
    break;
  }
  case 2: {
    char *endptr = NULL;
    Number = strtol(argv[1], &endptr, 10);
    if (argv[1] + strlen(argv[1]) != endptr) {
      fprintf(stderr, "Uncorrect input data (found symbols).\n");
      exit(EXIT_FAILURE);
    }
    if (errno == 34 && (Number == LONG_MAX || Number == LONG_MIN)) {
      fprintf(stderr, "Too long for me.\n");
      exit(EXIT_FAILURE);
    }
    if (Number < 1) {
      fprintf(stderr, "Uncorrect interval (only from 1).\n");
      exit(EXIT_FAILURE);
    }
    break;
  }
  default: {
    fprintf(stderr, "Many arguments for me.\n");
    exit(EXIT_FAILURE);
  }
  }
  int TempVar = 1;
  FILE *OutFile = fopen("text.txt", "w");
  int status = 0;
  while (TempVar != Number + 1) {
    if (fork() == 0) {
      fprintf(OutFile, "%d %d %d\n", TempVar, getpid(), getppid());
      exit(EXIT_SUCCESS);
    }
    TempVar++;
  }
  fclose(OutFile);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x1,%eax
je     11d3 <main+0x43>
jmp    11c2 <main+0x32>
mov    -0x38(%rbp),%eax
sub    $0x2,%eax
je     11f9 <main+0x69>
jmp    1304 <main+0x174>
mov    0x2dfe(%rip),%rax
movslq (%rax),%rdi
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
cmp    -0x20(%rbp),%rax
je     1270 <main+0xe0>
mov    0x2d87(%rip),%rax
movslq (%rax),%rdi
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2d51(%rip),%rax
cmpl   $0x22,(%rax)
jne    12ce <main+0x13e>
mov    -0x18(%rbp),%rax
mov    0x2d45(%rip),%rcx
cmp    (%rcx),%rax
je     12a8 <main+0x118>
mov    -0x18(%rbp),%rax
mov    0x2d49(%rip),%rcx
cmp    (%rcx),%rax
jne    12ce <main+0x13e>
mov    0x2d29(%rip),%rax
movslq (%rax),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
cmpq   $0x1,-0x18(%rbp)
jge    12ff <main+0x16f>
mov    0x2cf8(%rip),%rax
movslq (%rax),%rdi
lea    0xd5d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    132a <main+0x19a>
mov    0x2ccd(%rip),%rax
movslq (%rax),%rdi
lea    0xd55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movl   $0x1,-0x24(%rbp)
lea    0xd4a(%rip),%rdi
lea    0xd4c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movslq -0x24(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
je     13cb <main+0x23b>
mov    $0x0,%al
call   10b0 <fork@plt>
cmp    $0x0,%rax
jne    13bd <main+0x22d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1090 <getppid@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%edx
mov    -0x44(%rbp),%ecx
mov    %eax,%r8d
lea    0xce5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    134f <main+0x1bf>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
je     11d0 <main+0x30>
mov    0x2e25(%rip),%rax
cmp    $0x1,%edi
jne    124f <main+0xaf>
movslq (%rax),%rcx
lea    0xe3a(%rip),%rdi
mov    $0xd,%esi
jmp    1276 <main+0xd6>
mov    %rsi,%rbx
movq   $0x0,(%rsp)
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
add    %rbx,%rax
cmp    (%rsp),%rax
jne    1260 <main+0xc0>
mov    0x2dbb(%rip),%rax
cmpl   $0x22,(%rax)
jne    1232 <main+0x92>
mov    0x2db7(%rip),%rax
cmp    (%rax),%r15
je     12cf <main+0x12f>
mov    0x2dbf(%rip),%rax
cmp    (%rax),%r15
je     12cf <main+0x12f>
test   %r15,%r15
jg     128e <main+0xee>
mov    0x2d9a(%rip),%rax
movslq (%rax),%rcx
lea    0xdff(%rip),%rdi
mov    $0x22,%esi
jmp    1276 <main+0xd6>
movslq (%rax),%rcx
lea    0xe11(%rip),%rdi
mov    $0x17,%esi
jmp    1276 <main+0xd6>
mov    0x2d71(%rip),%rax
movslq (%rax),%rcx
lea    0xd9d(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xded(%rip),%rdi
lea    0xdef(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
je     12e7 <main+0x147>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    12b0 <main+0x110>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    1312 <main+0x172>
mov    0x2d02(%rip),%rax
movslq (%rax),%rcx
lea    0xd55(%rip),%rdi
mov    $0x11,%esi
jmp    1276 <main+0xd6>
add    $0x1,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <getppid@plt>
lea    0xd8c(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [14 x i8] c"No argumnets\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [39 x i8] c"Uncorrect input data (found symbols).\0A\00"
@errno = global i32 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.2 = [18 x i8] c"Too long for me.\0A\00"
@.str.3 = [35 x i8] c"Uncorrect interval (only from 1).\0A\00"
@.str.4 = [24 x i8] c"Many arguments for me.\0A\00"
@.str.5 = [9 x i8] c"text.txt\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [10 x i8] c"%d %d %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
%11 = load i32, i32* %4
switch i32 %11, label %71 [
i32 1, label %12
i32 2, label %19
]
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
store i8* null, i8** %7
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strtol(i8* %22, i8** %7, i32 10)
store i64 %23, i64* %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strlen(i8* %29)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %26, i64 %31
%33 = load i8*, i8** %7
%34 = icmp ne i8* %32, %33
br i1 %34, label %35, label %42
35: ; preds = %19
%36 = load i32, i32* @stderr
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %19
%43 = load i32, i32* @errno
%44 = icmp eq i32 %43, 34
br i1 %44, label %45, label %60
45: ; preds = %42
%46 = load i64, i64* %6
%47 = load i64, i64* @LONG_MAX
%48 = icmp eq i64 %46, %47
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i64, i64* %6
%51 = load i64, i64* @LONG_MIN
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %60
53: ; preds = %49, %45
%54 = load i32, i32* @stderr
%55 = sext i32 %54 to i64
%56 = inttoptr i64 %55 to i32*
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %49, %42
%61 = load i64, i64* %6
%62 = icmp slt i64 %61, 1
br i1 %62, label %63, label %70
63: ; preds = %60
%64 = load i32, i32* @stderr
%65 = sext i32 %64 to i64
%66 = inttoptr i64 %65 to i32*
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %60
br label %78
71: ; preds = %2
%72 = load i32, i32* @stderr
%73 = sext i32 %72 to i64
%74 = inttoptr i64 %73 to i32*
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %70
store i32 1, i32* %8
%79 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %79, i32** %9
store i32 0, i32* %10
br label %80
80: ; preds = %97, %78
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = load i64, i64* %6
%84 = add nsw i64 %83, 1
%85 = icmp ne i64 %82, %84
br i1 %85, label %86, label %100
86: ; preds = %80
%87 = call i64 (...) @fork()
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = load i32*, i32** %9
%91 = load i32, i32* %8
%92 = call i32 (...) @getpid()
%93 = call i32 (...) @getppid()
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %91, i32 %92, i32 %93)
%95 = load i32, i32* @EXIT_SUCCESS
%96 = call i32 @exit(i32 %95)
unreachable
97: ; preds = %86
%98 = load i32, i32* %8
%99 = add nsw i32 %98, 1
store i32 %99, i32* %8
br label %80
100: ; preds = %80
%101 = load i32*, i32** %9
%102 = call i32 @fclose(i32* %101)
%103 = load i32, i32* @EXIT_SUCCESS
%104 = call i32 @exit(i32 %103)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"No argumnets\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [39 x i8] c"Uncorrect input data (found symbols).\0A\00"
@errno = global i32 0
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str.2 = [18 x i8] c"Too long for me.\0A\00"
@.str.3 = [35 x i8] c"Uncorrect interval (only from 1).\0A\00"
@.str.4 = [24 x i8] c"Many arguments for me.\0A\00"
@.str.5 = [9 x i8] c"text.txt\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [10 x i8] c"%d %d %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
switch i32 %0, label %56 [
i32 1, label %4
i32 2, label %11
]
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 13, i64 1, i32* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strtol(i8* %14, i8** %3, i32 10)
%16 = load i8*, i8** %13
%17 = tail call i32 @strlen(i8* %16)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8*, i8** %3
%21 = icmp eq i8* %19, %20
br i1 %21, label %29, label %22
22: ; preds = %11
%23 = load i32, i32* @stderr
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i32*
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i64 38, i64 1, i32* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %11
%30 = load i32, i32* @errno
%31 = icmp eq i32 %30, 34
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = load i64, i64* @LONG_MAX
%34 = icmp eq i64 %15, %33
%35 = load i64, i64* @LONG_MIN
%36 = icmp eq i64 %15, %35
%37 = select i1 %34, i1 true, i1 %36
br i1 %37, label %38, label %45
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to i32*
%42 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 17, i64 1, i32* %41)
%43 = load i32, i32* @EXIT_FAILURE
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %32, %29
%46 = icmp slt i64 %15, 1
br i1 %46, label %47, label %54
47: ; preds = %45
%48 = load i32, i32* @stderr
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i32*
%51 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i64 34, i64 1, i32* %50)
%52 = load i32, i32* @EXIT_FAILURE
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %45
%55 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %63
56: ; preds = %2
%57 = load i32, i32* @stderr
%58 = sext i32 %57 to i64
%59 = inttoptr i64 %58 to i32*
%60 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 23, i64 1, i32* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = tail call i32 @exit(i32 %61)
unreachable
63: ; preds = %54, %74
%64 = phi i64 [ 1, %54 ], [ %75, %74 ]
%65 = tail call i64 (...) @fork()
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %74
67: ; preds = %63
%68 = trunc i64 %64 to i32
%69 = tail call i32 (...) @getpid()
%70 = tail call i32 (...) @getppid()
%71 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %68, i32 %69, i32 %70)
%72 = load i32, i32* @EXIT_SUCCESS
%73 = tail call i32 @exit(i32 %72)
unreachable
74: ; preds = %63
%75 = add nuw i64 %64, 1
%76 = icmp eq i64 %15, %64
br i1 %76, label %77, label %63
77: ; preds = %74
%78 = tail call i32 @fclose(i32* %55)
%79 = load i32, i32* @EXIT_SUCCESS
%80 = tail call i32 @exit(i32 %79)
unreachable
}