#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 getenvid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
void parent() {
  int *test0 = (int *)0x500;
  while (1) {
    printf("parent: %lx %d\n", test0, *test0);
    *test0 = 1000;
    printf("parent: %lx %d\n", test0, *test0);
    test0++;
    printf("%d %d %d %d %d %d %d %d %d %d\n", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    sleep(100);
    printf("%u\n", getenvid());
  }
}


x86 assembly (clang, -O0):
<parent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x500,%eax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movl   $0x3e8,(%rax)
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x8(%rbp)
lea    0xe7e(%rip),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    $0x3,%r8d
mov    $0x4,%r9d
movl   $0x5,(%rsp)
movl   $0x6,0x8(%rsp)
movl   $0x7,0x10(%rsp)
movl   $0x8,0x18(%rsp)
movl   $0x9,0x20(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x64,%edi
call   1050 <sleep@plt>
mov    $0x0,%al
call   1040 <getenvid@plt>
mov    %eax,%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1141 <parent+0x11>

x86 assembly (clang, -O2):
<parent>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x500,%ebx
lea    0xebc(%rip),%r14
lea    0xec5(%rip),%r15
lea    0xedd(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x3e8,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3e8,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x4,%rbx
sub    $0x8,%rsp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    $0x3,%r8d
mov    $0x4,%r9d
xor    %eax,%eax
push   $0x9
push   $0x8
push   $0x7
push   $0x6
push   $0x5
call   1030 <printf@plt>
add    $0x30,%rsp
mov    $0x64,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
call   1040 <getenvid@plt>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1160 <parent+0x30>

LLVM IR (-O0):
@.str = [16 x i8] c"parent: %lx %d\0A\00"
@.str.1 = [31 x i8] c"%d %d %d %d %d %d %d %d %d %d\0A\00"
@.str.2 = [4 x i8] c"%u\0A\00"
define void @parent() {
%1 = alloca i32*
store i32* inttoptr (i64 1280 to i32*), i32** %1
br label %2
2: ; preds = %0, %2
%3 = load i32*, i32** %1
%4 = load i32*, i32** %1
%5 = load i32, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %3, i32 %5)
%7 = load i32*, i32** %1
store i32 1000, i32* %7
%8 = load i32*, i32** %1
%9 = load i32*, i32** %1
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %8, i32 %10)
%12 = load i32*, i32** %1
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9)
%15 = call i32 @sleep(i32 100)
%16 = call i32 (...) @getenvid()
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %2
}

LLVM IR (-O2):
@.str = [16 x i8] c"parent: %lx %d\0A\00"
@.str.1 = [31 x i8] c"%d %d %d %d %d %d %d %d %d %d\0A\00"
@.str.2 = [4 x i8] c"%u\0A\00"
define void @parent() {
br label %1
1: ; preds = %1, %0
%2 = phi i32* [ inttoptr (i64 1280 to i32*), %0 ], [ %6, %1 ]
%3 = load i32, i32* %2
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %2, i32 %3)
store i32 1000, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %2, i32 1000)
%6 = getelementptr inbounds i32, i32* %2, i64 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9)
%8 = tail call i32 @sleep(i32 100)
%9 = tail call i32 (...) @getenvid()
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %1
}