#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 */
scalar_t__ NatCheck();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getpid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int main() {
  fprintf(stderr, "Attach to me: %d\n", getpid());
  if (NatCheck()) {
    printf("NaT bit correctly set\n");
    return 0;
  } else {
    printf("NaT bit incorrectly cleared!\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%edx
lea    0xe92(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <NatCheck@plt>
cmp    $0x0,%rax
je     119c <main+0x5c>
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11af <main+0x6f>
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e98(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xea8(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1050 <NatCheck@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
lea    0xe9b(%rip),%rax
lea    0xeb1(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Attach to me: %d\0A\00"
@.str.1 = [23 x i8] c"NaT bit correctly set\0A\00"
@.str.2 = [30 x i8] c"NaT bit incorrectly cleared!\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @stderr
%3 = call i32 (...) @getpid()
%4 = call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i64 (...) @NatCheck()
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %11
11: ; preds = %9, %7
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Attach to me: %d\0A\00"
@str = [29 x i8] c"NaT bit incorrectly cleared!\00"
@str.3 = [22 x i8] c"NaT bit correctly set\00"
define i32 @main() {
%1 = load i32, i32* @stderr
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i64 (...) @NatCheck()
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0)
%7 = zext i1 %5 to i32
%8 = tail call i32 @puts(i8* dereferenceable(1) %6)
ret i32 %7
}