#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*/ printf(char *, ...);
int main() {
  int count = 10, num = 20;
  double total = 50.56;
  int *ptr1;
  double *ptr2;
  printf("Pointer Dereference Example 1\n\n");
  ptr1 = &count;
  printf("ptr1 = %d  count = %d\n\n", *ptr1, count);
  ptr1 = &num;
  printf("ptr1 = %d  num = %d\n\n", *ptr1, num);
  ptr2 = &total;
  printf("ptr2 = %2.2lf total = %2.2lf\n\n", *ptr2, total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x14,-0xc(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0xc(%rbp),%edx
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xeb4(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xed4(%rip),%rdi
mov    $0xa,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x14,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
movsd  0xe94(%rip),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Pointer Dereference Example 1\0A\0A\00"
@.str.1 = [24 x i8] c"ptr1 = %d count = %d\0A\0A\00"
@.str.2 = [22 x i8] c"ptr1 = %d num = %d\0A\0A\00"
@.str.3 = [31 x i8] c"ptr2 = %2.2lf total = %2.2lf\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i32*
%6 = alloca double*
store i32 0, i32* %1
store i32 10, i32* %2
store i32 20, i32* %3
store double 5.056000e+01, double* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32* %2, i32** %5
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %10)
store i32* %3, i32** %5
%12 = load i32*, i32** %5
%13 = load i32, i32* %12
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14)
store double* %4, double** %6
%16 = load double*, double** %6
%17 = load double, double* %16
%18 = load double, double* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %17, double %18)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"ptr1 = %d count = %d\0A\0A\00"
@.str.2 = [22 x i8] c"ptr1 = %d num = %d\0A\0A\00"
@.str.3 = [31 x i8] c"ptr2 = %2.2lf total = %2.2lf\0A\0A\00"
@str = [31 x i8] c"Pointer Dereference Example 1\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 10, i32 10)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 20, i32 20)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double 5.056000e+01, double 5.056000e+01)
ret i32 0
}