#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*/ fun(int, int *);
int /*<<< orphan*/ printf(char *, int, int, ...);
int main() {
  int np = 1, p = 1;
  int v[] = {1, 2, 3, 4};
  int *pv = &v[0];
  int i;
  printf("Before fun(): np=%d p=%d\n", np, p);
  fun(np, &p);
  printf("After fun(): np=%d p=%d\n", np, p);
  for (i = 0; i < 4; i++) {
    printf("v[%d]=%d\t &v[%d]=%p\n", i, *pv, i, pv);
    pv++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1030 <fun@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    11d8 <main+0xb8>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1196 <main+0x76>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x1,0xc(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xed0(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    $0x1,%edi
call   1030 <fun@plt>
mov    0xc(%rsp),%edx
lea    0xebf(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rbx
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%r8
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%r8
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1c(%rsp),%r8
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.v = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [26 x i8] c"Before fun(): np=%d p=%d\0A\00"
@.str.1 = [25 x i8] c"After fun(): np=%d p=%d\0A\00"
@.str.2 = [21 x i8] c"v[%d]=%d\09 &v[%d]=%p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 1, i32* %3
%7 = bitcast [4 x i32]* %4 to i8*
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
store i32* %8, i32** %5
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = call i32 @fun(i32 %12, i32* %3)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
store i32 0, i32* %6
br label %17
17: ; preds = %29, %0
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i32, i32* %6
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = load i32, i32* %6
%25 = load i32*, i32** %5
%26 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %23, i32 %24, i32* %25)
%27 = load i32*, i32** %5
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %5
br label %29
29: ; preds = %20
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %17
32: ; preds = %17
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@__const.main.v = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [26 x i8] c"Before fun(): np=%d p=%d\0A\00"
@.str.1 = [25 x i8] c"After fun(): np=%d p=%d\0A\00"
@.str.2 = [21 x i8] c"v[%d]=%d\09 &v[%d]=%p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast [4 x i32]* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%6 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, i32 1)
%7 = call i32 @fun(i32 1, i32* %1)
%8 = load i32, i32* %1
%9 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %8)
%10 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1, i32 0, i32* %5)
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%12 = load i32, i32* %11
%13 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %12, i32 1, i32* %11)
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%15 = load i32, i32* %14
%16 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %15, i32 2, i32* %14)
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%18 = load i32, i32* %17
%19 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %18, i32 3, i32* %17)
ret i32 0
}