#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*/ ckpt_and_exit();
int getpid();
int /*<<< orphan*/ getpwnam(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("Starting up, my pid is %d\n", getpid());
  if (argc > 1 && argv[1][0] == 'Y') {
    printf("Doing getpwnam()\n");
    getpwnam("foobar");
  } else {
    printf("Skipping getpwnam()\n");
  }
  printf("Checkpoint and exit...\n");
  ckpt_and_exit();
  printf("Returned from checkpoint and exit\n");
  printf("Exiting\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11aa <main+0x6a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x59,%eax
jne    11aa <main+0x6a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1050 <getpwnam@plt>
jmp    11b8 <main+0x78>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <ckpt_and_exit@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x2,%ebp
jl     1197 <main+0x47>
mov    0x8(%rbx),%rax
cmpb   $0x59,(%rax)
jne    1197 <main+0x47>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
call   1060 <getpwnam@plt>
jmp    11a3 <main+0x53>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <ckpt_and_exit@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Starting up, my pid is %d\0A\00"
@.str.1 = [18 x i8] c"Doing getpwnam()\0A\00"
@.str.2 = [7 x i8] c"foobar\00"
@.str.3 = [21 x i8] c"Skipping getpwnam()\0A\00"
@.str.4 = [24 x i8] c"Checkpoint and exit...\0A\00"
@.str.5 = [35 x i8] c"Returned from checkpoint and exit\0A\00"
@.str.6 = [9 x i8] c"Exiting\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 = call i32 (...) @getpid()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %21
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 89
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @getpwnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %23
21: ; preds = %10, %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 (...) @ckpt_and_exit()
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Starting up, my pid is %d\0A\00"
@.str.2 = [7 x i8] c"foobar\00"
@str = [20 x i8] c"Skipping getpwnam()\00"
@str.7 = [23 x i8] c"Checkpoint and exit...\00"
@str.8 = [34 x i8] c"Returned from checkpoint and exit\00"
@str.9 = [8 x i8] c"Exiting\00"
@str.10 = [17 x i8] c"Doing getpwnam()\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 89
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
%13 = tail call i32 @getpwnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %16
14: ; preds = %6, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0))
%18 = tail call i32 (...) @ckpt_and_exit()
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.8, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}