#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*/ fprintf(int /*<<< orphan*/, char *, int, ...);
int getpid();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  fprintf(stderr, "Process %d is alive\n", getpid());
  fprintf(stderr, "Process %d exiting with exit code %d\n", getpid(),
          -getpid());
  return (-getpid());
}


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)
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
sub    %eax,%ecx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2eb6(%rip),%rbp
mov    0x0(%rbp),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xec5(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <getpid@plt>
neg    %eax
lea    0xeb3(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
neg    %eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Process %d is alive\0A\00"
@.str.1 = [38 x i8] c"Process %d exiting with exit code %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @stderr
%7 = call i32 (...) @getpid()
%8 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stderr
%10 = call i32 (...) @getpid()
%11 = call i32 (...) @getpid()
%12 = sub nsw i32 0, %11
%13 = call i32 (i32, i8*, i32, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
%14 = call i32 (...) @getpid()
%15 = sub nsw i32 0, %14
ret i32 %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Process %d is alive\0A\00"
@.str.1 = [38 x i8] c"Process %d exiting with exit code %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @stderr
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 (...) @getpid()
%9 = sub nsw i32 0, %8
%10 = tail call i32 (i32, i8*, i32, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %9)
%11 = tail call i32 (...) @getpid()
%12 = sub nsw i32 0, %11
ret i32 %12
}