#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 */
typedef int /*<<< orphan*/ px;
typedef int /*<<< orphan*/ not_a_pointer;

/* Variables and functions */
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int x = 0;
  printf("%p\n", &x);
  int *px = NULL, not_a_pointer = 0;
  px = &x;
  printf("%p\n", (void *)px);
  printf("%lu, %lu\n", sizeof(px), sizeof(not_a_pointer));
  printf("%d\n", *px);
  (*px)++;
  printf("%d\n", *px);
  printf("%d\n", x);
  int x_array[20] = {0};
  for (int xx = 0; xx < 20; xx++) {
    x_array[xx] = 20 - xx;
  }
  int *x_ptr = x_array;
  int arr[10] = {0};
  int(*ptr_to_arr)[10] = &arr;
  char c_arr[] = "foobarbazquirk";
  int i_arr[10] = {0};
  int *ptr = i_arr;
  printf("%lu, %lu, %lu\n", sizeof i_arr, sizeof ptr, sizeof *ptr);
  printf("%d\n", *(x_ptr + 1));
  printf("%d\n", x_array[1]);
  int *my_ptr = malloc(sizeof(*my_ptr) * 20);
  for (int xx = 0; xx < 20; xx++) {
    *(my_ptr + xx) = 20 - xx;
  }
  printf("%d\n", *(my_ptr + 21));
  free(my_ptr);
  const char *my_str = "This is my very own string";
  printf("%c\n", *my_str);
  char foo[] = "foo";
  foo[0] = 'a';
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
mov    $0x8,%esi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0x14,-0x74(%rbp)
jge    122f <main+0xef>
mov    $0x14,%ecx
sub    -0x74(%rbp),%ecx
movslq -0x74(%rbp),%rax
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1207 <main+0xc7>
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    0xda9(%rip),%rax
mov    %rax,-0xc7(%rbp)
mov    0xda4(%rip),%eax
mov    %eax,-0xbf(%rbp)
mov    0xd9b(%rip),%ax
mov    %ax,-0xbb(%rbp)
mov    0xd90(%rip),%al
mov    %al,-0xb9(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    -0xf0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
lea    0xd63(%rip),%rdi
mov    $0x28,%esi
mov    $0x8,%edx
mov    $0x4,%ecx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x80(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x6c(%rbp),%esi
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,-0x100(%rbp)
movl   $0x0,-0x104(%rbp)
cmpl   $0x14,-0x104(%rbp)
jge    1348 <main+0x208>
mov    $0x14,%edx
sub    -0x104(%rbp),%edx
mov    -0x100(%rbp),%rax
movslq -0x104(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    130b <main+0x1cb>
mov    -0x100(%rbp),%rax
mov    0x54(%rax),%esi
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x100(%rbp),%rdi
call   1030 <free@plt>
lea    0xcb3(%rip),%rax
mov    %rax,-0x110(%rbp)
mov    -0x110(%rbp),%rax
movsbl (%rax),%esi
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xcad(%rip),%eax
mov    %eax,-0x114(%rbp)
movb   $0x61,-0x114(%rbp)
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xf0d(%rip),%r14
lea    0x4(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x8,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xecf(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
add    $0x1,%esi
mov    %esi,0x4(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x28,%esi
mov    $0x8,%edx
mov    $0x4,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x13,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x13,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movaps 0xdff(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe05(%rip),%xmm0
movups %xmm0,0x10(%rax)
movaps 0xe0a(%rip),%xmm0
movups %xmm0,0x20(%rax)
movaps 0xe0f(%rip),%xmm0
movups %xmm0,0x30(%rax)
movaps 0xe14(%rip),%xmm0
movups %xmm0,0x40(%rax)
mov    0x54(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe1b(%rip),%rdi
mov    $0x54,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%p\0A\00"
@.str.1 = [10 x i8] c"%lu, %lu\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@__const.main.c_arr = [15 x i8] c"foobarbazquirk\00"
@.str.3 = [15 x i8] c"%lu, %lu, %lu\0A\00"
@.str.4 = [27 x i8] c"This is my very own string\00"
@.str.5 = [4 x i8] c"%c\0A\00"
@__const.main.foo = [4 x i8] c"foo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [20 x i32]
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [10 x i32]
%9 = alloca [10 x i32]*
%10 = alloca [15 x i8]
%11 = alloca [10 x i32]
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca [4 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32* null, i32** %3
store i32 0, i32* %4
store i32* %2, i32** %3
%18 = load i32*, i32** %3
%19 = bitcast i32* %18 to i8*
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 8, i64 4)
%22 = load i32*, i32** %3
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %3
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
%28 = load i32*, i32** %3
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = bitcast [20 x i32]* %5 to i8*
store i32 0, i32* %6
br label %34
34: ; preds = %43, %0
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 20
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i32, i32* %6
%39 = sub nsw i32 20, %38
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 %41
store i32 %39, i32* %42
br label %43
43: ; preds = %37
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %34
46: ; preds = %34
%47 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 0
store i32* %47, i32** %7
%48 = bitcast [10 x i32]* %8 to i8*
store [10 x i32]* %8, [10 x i32]** %9
%49 = bitcast [15 x i8]* %10 to i8*
%50 = bitcast [10 x i32]* %11 to i8*
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i64 0, i64 0
store i32* %51, i32** %12
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 40, i64 8, i64 4)
%53 = load i32*, i32** %7
%54 = getelementptr inbounds i32, i32* %53, i64 1
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [20 x i32], [20 x i32]* %5, i64 0, i64 1
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = call i32* @malloc(i32 80)
store i32* %60, i32** %13
store i32 0, i32* %14
br label %61
61: ; preds = %71, %46
%62 = load i32, i32* %14
%63 = icmp slt i32 %62, 20
br i1 %63, label %64, label %74
64: ; preds = %61
%65 = load i32, i32* %14
%66 = sub nsw i32 20, %65
%67 = load i32*, i32** %13
%68 = load i32, i32* %14
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
store i32 %66, i32* %70
br label %71
71: ; preds = %64
%72 = load i32, i32* %14
%73 = add nsw i32 %72, 1
store i32 %73, i32* %14
br label %61
74: ; preds = %61
%75 = load i32*, i32** %13
%76 = getelementptr inbounds i32, i32* %75, i64 21
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %77)
%79 = load i32*, i32** %13
%80 = call i32 @free(i32* %79)
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8** %15
%81 = load i8*, i8** %15
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = bitcast [4 x i8]* %16 to i8*
%86 = getelementptr inbounds [4 x i8], [4 x i8]* %16, i64 0, i64 0
store i8 97, i8* %86
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%p\0A\00"
@.str.1 = [10 x i8] c"%lu, %lu\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [15 x i8] c"%lu, %lu, %lu\0A\00"
@.str.5 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 8, i64 4)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 40, i64 8, i64 4)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 19)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 19)
%16 = call i32* @malloc(i32 80)
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 20, i32 19, i32 18, i32 17>, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %16, i64 4
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 16, i32 15, i32 14, i32 13>, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %16, i64 8
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 12, i32 11, i32 10, i32 9>, <4 x i32>* %21
%22 = getelementptr inbounds i32, i32* %16, i64 12
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 8, i32 7, i32 6, i32 5>, <4 x i32>* %23
%24 = getelementptr inbounds i32, i32* %16, i64 16
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> <i32 4, i32 3, i32 2, i32 1>, <4 x i32>* %25
%26 = getelementptr inbounds i32, i32* %16, i64 21
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = call i32 @free(i32* %16)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 84)
ret i32 0
}