#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, int);
void int_copy(int *ptrA, int *ptrB, int nbr) {
  int *pA = ptrA;
  int *pB = ptrB;
  for (int i = 0; i < nbr; ++i) {
    printf("*(pB + %d)\t%d\n", i, *(pB + i));
    *pA++ = *pB++;
  }
}


x86 assembly (clang, -O0):
<int_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1190 <int_copy+0x80>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113a <int_copy+0x2a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1164 <int_copy+0x54>
mov    %rsi,%r13
mov    %rdi,%r14
mov    %edx,%r12d
shl    $0x2,%r12
xor    %ebx,%ebx
lea    0xecb(%rip),%r15
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,2),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    0x0(%r13,%rbx,1),%eax
mov    %eax,(%r14,%rbx,1)
add    $0x1,%ebp
add    $0x4,%rbx
cmp    %rbx,%r12
jne    1140 <int_copy+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"*(pB + %d)\09%d\0A\00"
define void @int_copy(i32* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %8
7: ; preds = %8, %3
ret void
8: ; preds = %5, %8
%9 = phi i64 [ 0, %5 ], [ %19, %8 ]
%10 = phi i32* [ %1, %5 ], [ %16, %8 ]
%11 = phi i32* [ %0, %5 ], [ %18, %8 ]
%12 = getelementptr inbounds i32, i32* %10, i64 %9
%13 = load i32, i32* %12
%14 = trunc i64 %9 to i32
%15 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %13)
%16 = getelementptr inbounds i32, i32* %10, i64 1
%17 = load i32, i32* %10
%18 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %17, i32* %11
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %7, label %8
}