#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*/ p;
typedef int /*<<< orphan*/ d;
typedef int /*<<< orphan*/ c;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ free(void **);
int /*<<< orphan*/ getchar();
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char *a;
  int *b;
  float *c;
  double *d;
  void *p;
  int i = 7;
  float f = 23.5;
  void **ptr1;
  char *str1[] = {"tests1", "tests2", "tests3", "tests4", "tests5"};
  char *ptr2;
  int *ptr3;
  char str[5] = "test";
  printf("pointer size: a=%d, b=%d, c=%d, d=%d, p=%d\n", sizeof(a), sizeof(b),
         sizeof(c), sizeof(d), sizeof(p));
  printf("data    size: a=%d, b=%d, c=%d, d=%d\n", sizeof(*a), sizeof(*b),
         sizeof(*c), sizeof(*d));
  p = &i;
  printf("i contains: %d\n", *((int *)p));
  p = &f;
  printf("f contains: %f\n", *((float *)p));
  ptr2 = malloc(strlen(str) + 1);
  ptr3 = malloc(sizeof(int));
  strcpy(ptr2, str);
  *ptr3 = i;
  ptr1 = malloc(5 * sizeof(void *));
  ptr1[0] = ptr2;
  ptr1[1] = ptr3;
  printf("%s\n", (char *)ptr1[0]);
  printf("%d\n", *((int *)ptr1[1]));
  free(ptr1[0]);
  free(ptr1[1]);
  free(ptr1);
  printf("Press any key to end...");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7,-0x34(%rbp)
movss  0xe6f(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
lea    0xe57(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe4f(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe4b(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe47(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe44(%rip),%eax
mov    %eax,-0x85(%rbp)
mov    0xe3c(%rip),%al
mov    %al,-0x81(%rbp)
lea    0xe30(%rip),%rdi
mov    $0x8,%r9d
mov    %r9,%rsi
mov    %r9,%rdx
mov    %r9,%rcx
mov    %r9,%r8
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    $0x1,%esi
mov    $0x4,%ecx
mov    $0x8,%r8d
mov    %rcx,%rdx
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x34(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe21(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    -0x85(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rdi
lea    -0x85(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x34(%rbp),%ecx
mov    -0x80(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x28,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x78(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x80(%rbp),%rcx
mov    -0x40(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x74736574,0x8(%rsp)
74
lea    0xe80(%rip),%rdi
mov    $0x8,%esi
mov    $0x8,%edx
mov    $0x8,%ecx
mov    $0x8,%r8d
mov    $0x8,%r9d
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    $0x4,%ecx
mov    $0x8,%r8d
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe86(%rip),%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe83(%rip),%rdi
movsd  0xe0c(%rip),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
movl   $0x7,(%rbx)
mov    $0x28,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %r14,(%rax)
mov    %rbx,0x8(%rax)
mov    %r14,%rdi
call   1050 <puts@plt>
mov    (%rbx),%esi
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"tests1\00"
@.str.1 = [7 x i8] c"tests2\00"
@.str.2 = [7 x i8] c"tests3\00"
@.str.3 = [7 x i8] c"tests4\00"
@.str.4 = [7 x i8] c"tests5\00"
@__const.main.str = [5 x i8] c"test\00"
@.str.5 = [44 x i8] c"pointer size: a=%d, b=%d, c=%d, d=%d, p=%d\0A\00"
@.str.6 = [38 x i8] c"data size: a=%d, b=%d, c=%d, d=%d\0A\00"
@.str.7 = [16 x i8] c"i contains: %d\0A\00"
@.str.8 = [16 x i8] c"f contains: %f\0A\00"
@.str.9 = [4 x i8] c"%s\0A\00"
@.str.10 = [4 x i8] c"%d\0A\00"
@.str.11 = [24 x i8] c"Press any key to end...\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca float*
%5 = alloca double*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca float
%9 = alloca i8**
%10 = alloca [5 x i8*]
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca [5 x i8]
store i32 0, i32* %1
store i32 7, i32* %7
store float 2.350000e+01, float* %8
%14 = bitcast [5 x i8*]* %10 to i8*
%15 = bitcast i8* %14 to [5 x i8*]*
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %15, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %15, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %15, i32 0, i32 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %15, i32 0, i32 3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %15, i32 0, i32 4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %20
%21 = bitcast [5 x i8]* %13 to i8*
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i64 8, i64 8, i64 8, i64 8, i64 8)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i64 1, i64 4, i64 4, i64 8)
%24 = bitcast i32* %7 to i8*
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = bitcast i8* %25 to i32*
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 %27)
%29 = bitcast float* %8 to i8*
store i8* %29, i8** %6
%30 = load i8*, i8** %6
%31 = bitcast i8* %30 to float*
%32 = load float, float* %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double %33)
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = add nsw i32 %36, 1
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %11
%39 = call i8* @malloc(i32 4)
%40 = bitcast i8* %39 to i32*
store i32* %40, i32** %12
%41 = load i8*, i8** %11
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0, i64 0
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i32, i32* %7
%45 = load i32*, i32** %12
store i32 %44, i32* %45
%46 = call i8* @malloc(i32 40)
%47 = bitcast i8* %46 to i8**
store i8** %47, i8*** %9
%48 = load i8*, i8** %11
%49 = load i8**, i8*** %9
%50 = getelementptr inbounds i8*, i8** %49, i64 0
store i8* %48, i8** %50
%51 = load i32*, i32** %12
%52 = bitcast i32* %51 to i8*
%53 = load i8**, i8*** %9
%54 = getelementptr inbounds i8*, i8** %53, i64 1
store i8* %52, i8** %54
%55 = load i8**, i8*** %9
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %57)
%59 = load i8**, i8*** %9
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = bitcast i8* %61 to i32*
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %63)
%65 = load i8**, i8*** %9
%66 = getelementptr inbounds i8*, i8** %65, i64 0
%67 = load i8*, i8** %66
%68 = bitcast i8* %67 to i8**
%69 = call i32 @free(i8** %68)
%70 = load i8**, i8*** %9
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
%73 = bitcast i8* %72 to i8**
%74 = call i32 @free(i8** %73)
%75 = load i8**, i8*** %9
%76 = call i32 @free(i8** %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%78 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [5 x i8] c"test\00"
@.str.5 = [44 x i8] c"pointer size: a=%d, b=%d, c=%d, d=%d, p=%d\0A\00"
@.str.6 = [38 x i8] c"data size: a=%d, b=%d, c=%d, d=%d\0A\00"
@.str.7 = [16 x i8] c"i contains: %d\0A\00"
@.str.8 = [16 x i8] c"f contains: %f\0A\00"
@.str.10 = [4 x i8] c"%d\0A\00"
@.str.11 = [24 x i8] c"Press any key to end...\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i64 8, i64 8, i64 8, i64 8, i64 8)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i64 1, i64 4, i64 4, i64 8)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 7)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), double 2.350000e+01)
%7 = call i32 @strlen(i8* %2)
%8 = add nsw i32 %7, 1
%9 = call i8* @malloc(i32 %8)
%10 = call dereferenceable_or_null(4) i8* @malloc(i32 4)
%11 = bitcast i8* %10 to i32*
%12 = call i32 @strcpy(i8* %9, i8* %2)
store i32 7, i32* %11
%13 = call dereferenceable_or_null(40) i8* @malloc(i32 40)
%14 = bitcast i8* %13 to i8**
store i8* %9, i8** %14
%15 = getelementptr inbounds i8*, i8** %14, i64 1
store i8* %10, i8** %15
%16 = call i32 @puts(i8* dereferenceable(1) %9)
%17 = load i32, i32* %11
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %17)
%19 = bitcast i8* %9 to i8**
%20 = call i32 @free(i8** %19)
%21 = bitcast i8* %10 to i8**
%22 = call i32 @free(i8** %21)
%23 = call i32 @free(i8** %14)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.11, i64 0, i64 0))
%25 = call i32 (...) @getchar()
ret i32 0
}