#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 */

/* Variables and functions */
int /*<<< orphan*/ execl(char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getpid();
int getppid();
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int i = 0;
  fprintf(stdout, "Father:%d, This:%d,  %d\n", getppid(), getpid(), ++i);
  execl(argv[0], argv[0], (char *)0);
  fprintf(stdout, "End program\n");
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <getppid@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
add    $0x1,%r8d
mov    %r8d,-0x14(%rbp)
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <execl@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x2e8f(%rip),%r15
mov    (%r15),%ebp
xor    %eax,%eax
call   1050 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe95(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
mov    %eax,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1060 <execl@plt>
mov    (%r15),%edi
lea    0xe84(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [25 x i8] c"Father:%d, This:%d, %d\0A\00"
@.str.1 = [13 x i8] c"End program\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = load i32, i32* @stdout
%8 = call i32 (...) @getppid()
%9 = call i32 (...) @getpid()
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 1
store i32 %11, i32* %6
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 %11)
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @execl(i8* %15, i8* %18, i8* null)
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [25 x i8] c"Father:%d, This:%d, %d\0A\00"
@.str.1 = [13 x i8] c"End program\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 (...) @getppid()
%5 = tail call i32 (...) @getpid()
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5, i32 1)
%7 = load i8*, i8** %1
%8 = tail call i32 @execl(i8* %7, i8* %7, i8* null)
%9 = load i32, i32* @stdout
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}