#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 *malloc(int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main() {
  int n1 = 10;
  int n2 = 20;
  int *p;
  int *q;
  p = malloc(sizeof(int));
  *p = 30;
  q = p;
  printf("n1=%d n2=%d valor de p es %d el de q es %d\n", n1, n2, *p, *q);
  *q = 40;
  printf("n1=%d n2=%d valor de p es %d el de q es %d\n", n1, n2, *p, *q);
  q = &n2;
  p = q;
  printf("n1=%d n2=%d valor de p es %d el de q es %d\n", n1, n2, *p, *q);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x14,-0xc(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1e,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8d
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0x28,(%rax)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8d
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8d
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
lea    0xece(%rip),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x14,%edx
mov    $0x1e,%ecx
mov    $0x1e,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x14,%edx
mov    $0x28,%ecx
mov    $0x28,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x14,%edx
mov    $0x14,%ecx
mov    $0x14,%r8d
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"n1=%d n2=%d valor de p es %d el de q es %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32 0, i32* %1
store i32 10, i32* %2
store i32 20, i32* %3
%6 = call i32* @malloc(i32 4)
store i32* %6, i32** %4
%7 = load i32*, i32** %4
store i32 30, i32* %7
%8 = load i32*, i32** %4
store i32* %8, i32** %5
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = load i32*, i32** %4
%12 = load i32, i32* %11
%13 = load i32*, i32** %5
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10, i32 %12, i32 %14)
%16 = load i32*, i32** %5
store i32 40, i32* %16
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %20, i32 %22)
store i32* %3, i32** %5
%24 = load i32*, i32** %5
store i32* %24, i32** %4
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26, i32 %28, i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"n1=%d n2=%d valor de p es %d el de q es %d\0A\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 4)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 10, i32 20, i32 30, i32 30)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 10, i32 20, i32 40, i32 40)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 10, i32 20, i32 20, i32 20)
ret i32 0
}