#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*/ exit(int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ sleep(int);
void child_code(int i) {
  sleep(i);
  printf("Hello from child %d.\n", i);
  char *x = malloc(sizeof(char));
  static char y = 'a';
  printf("Child %d put x in the heap at %p and y in static at %p.\n", i, x, &y);
  free(x);
  exit(i);
}


x86 assembly (clang, -O0):
<child_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <sleep@plt>
mov    -0x4(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe86(%rip),%rdi
lea    0x2eb1(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<child_code>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1070 <sleep@plt>
lea    0xe9e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe97(%rip),%rdi
lea    0x2ec2(%rip),%rcx
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Hello from child %d.\0A\00"
@child_code.y = internal global i8 97
@.str.1 = [57 x i8] c"Child %d put x in the heap at %p and y in static at %p.\0A\00"
define void @child_code(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @sleep(i32 %4)
%6 = load i32, i32* %2
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i8* @malloc(i32 1)
store i8* %8, i8** %3
%9 = load i32, i32* %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %9, i8* %10, i8* @child_code.y)
%12 = load i8*, i8** %3
%13 = call i32 @free(i8* %12)
%14 = load i32, i32* %2
%15 = call i32 @exit(i32 %14)
unreachable
}

LLVM IR (-O2):
@.str = [22 x i8] c"Hello from child %d.\0A\00"
@child_code.y = internal global i8 97
@.str.1 = [57 x i8] c"Child %d put x in the heap at %p and y in static at %p.\0A\00"
define void @child_code(i32 %0) {
%2 = tail call i32 @sleep(i32 %0)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %0, i8* %4, i8* @child_code.y)
%6 = tail call i32 @free(i8* %4)
%7 = tail call i32 @exit(i32 %0)
unreachable
}