#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int proc(int **, int **);
main() {
  int *a, *b, *p, *q;
  a = (int *)malloc(sizeof(int));
  b = (int *)malloc(sizeof(int));
  (*a) = 0;
  (*b) = 1;
  p = a;
  q = b;
  printf("Before  proc :\n");
  printf("*a = %d, *b = %d,\n", *a, *b);
  printf("*p = %d, *q = %d.\n", *p, *q);
  *p = proc(&p, &q);
  printf("After  proc :\n");
  printf("*a = %d, *b = %d,\n", *a, *b);
  printf("*p = %d, *q = %d.\n", *p, *q);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <proc@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movl   $0x0,(%r14)
movl   $0x1,(%rax)
mov    %r14,0x8(%rsp)
mov    %rax,0x10(%rsp)
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%esi
mov    (%rbx),%edx
lea    0xe6c(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
mov    (%rbx),%edx
lea    0xe69(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <proc@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%esi
mov    (%rbx),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%esi
mov    0x10(%rsp),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Before proc :\0A\00"
@.str.1 = [19 x i8] c"*a = %d, *b = %d,\0A\00"
@.str.2 = [19 x i8] c"*p = %d, *q = %d.\0A\00"
@.str.3 = [15 x i8] c"After proc :\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = call i64 @malloc(i32 4)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %1
%7 = call i64 @malloc(i32 4)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %2
%9 = load i32*, i32** %1
store i32 0, i32* %9
%10 = load i32*, i32** %2
store i32 1, i32* %10
%11 = load i32*, i32** %1
store i32* %11, i32** %3
%12 = load i32*, i32** %2
store i32* %12, i32** %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%14 = load i32*, i32** %1
%15 = load i32, i32* %14
%16 = load i32*, i32** %2
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %17)
%19 = load i32*, i32** %3
%20 = load i32, i32* %19
%21 = load i32*, i32** %4
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %22)
%24 = call i32 @proc(i32** %3, i32** %4)
%25 = load i32*, i32** %3
store i32 %24, i32* %25
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32*, i32** %1
%28 = load i32, i32* %27
%29 = load i32*, i32** %2
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30)
%32 = load i32*, i32** %3
%33 = load i32, i32* %32
%34 = load i32*, i32** %4
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %33, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"*a = %d, *b = %d,\0A\00"
@.str.2 = [19 x i8] c"*p = %d, *q = %d.\0A\00"
@str = [15 x i8] c"Before proc :\00"
@str.4 = [14 x i8] c"After proc :\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = bitcast i32** %1 to i8*
%4 = bitcast i32** %2 to i8*
%5 = tail call i64 @malloc(i32 4)
%6 = inttoptr i64 %5 to i32*
%7 = tail call i64 @malloc(i32 4)
%8 = inttoptr i64 %7 to i32*
store i32 0, i32* %6
store i32 1, i32* %8
store i32* %6, i32** %1
store i32* %8, i32** %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* %6
%11 = load i32, i32* %8
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14)
%16 = call i32 @proc(i32** %1, i32** %2)
%17 = load i32*, i32** %1
store i32 %16, i32* %17
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
%19 = load i32, i32* %6
%20 = load i32, i32* %8
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20)
%22 = load i32*, i32** %1
%23 = load i32, i32* %22
%24 = load i32*, i32** %2
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %25)
ret i32 0
}