#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*/ free(int *);
int /*<<< orphan*/ getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int *arr1, *arr2, i;
  arr1 = (int *)malloc(3 * sizeof(int));
  arr2 = (int *)malloc(3 * sizeof(int));
  printf("Please insert 3 integers for arr1:\n");
  for (i = 0; i < 3; i++) {
    scanf("%d", arr1 + i);
  }
  printf("Copying contents of arr1 to arr2...\n[Press Enter]\n");
  getchar();
  for (i = 0; i < 3; i++) {
    *(arr2 + i) = *(arr1 + i);
  }
  printf("arr2:\n");
  for (i = 0; i < 3; i++) {
    printf("%d\n", *(arr2 + i));
  }
  free(arr1);
  free(arr2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11c3 <main+0x73>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe74(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1190 <main+0x40>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    120d <main+0xbd>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11df <main+0x8f>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1253 <main+0x103>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1222 <main+0xd2>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0xc,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0xc,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6e(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
lea    0x4(%r14),%rsi
mov    %r15,%rdi
call   1080 <scanf@plt>
lea    0x8(%r14),%rsi
mov    %r15,%rdi
call   1080 <scanf@plt>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    (%r14),%eax
mov    %eax,(%rbx)
mov    0x4(%r14),%eax
mov    %eax,0x4(%rbx)
mov    0x8(%r14),%eax
mov    %eax,0x8(%rbx)
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%esi
lea    0xe13(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Please insert 3 integers for arr1:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"Copying contents of arr1 to arr2...\0A[Press Enter]\0A\00"
@.str.3 = [7 x i8] c"arr2:\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @malloc(i32 12)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %2
%7 = call i64 @malloc(i32 12)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32*, i32** %2
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %10
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (...) @getchar()
store i32 0, i32* %4
br label %25
25: ; preds = %38, %22
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i32*, i32** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = load i32*, i32** %3
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
br label %38
38: ; preds = %28
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %25
41: ; preds = %25
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %43
43: ; preds = %53, %41
%44 = load i32, i32* %4
%45 = icmp slt i32 %44, 3
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load i32*, i32** %3
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %46
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %43
56: ; preds = %43
%57 = load i32*, i32** %2
%58 = call i32 @free(i32* %57)
%59 = load i32*, i32** %3
%60 = call i32 @free(i32* %59)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [35 x i8] c"Please insert 3 integers for arr1:\00"
@str.5 = [50 x i8] c"Copying contents of arr1 to arr2...\0A[Press Enter]\00"
@str.6 = [6 x i8] c"arr2:\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 12)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i64 @malloc(i32 12)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = getelementptr inbounds i32, i32* %2, i64 1
%7 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds i32, i32* %2, i64 2
%9 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = inttoptr i64 %3 to i32*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.5, i64 0, i64 0))
%12 = tail call i32 (...) @getchar()
%13 = load i32, i32* %2
store i32 %13, i32* %10
%14 = load i32, i32* %6
%15 = getelementptr inbounds i32, i32* %10, i64 1
store i32 %14, i32* %15
%16 = load i32, i32* %8
%17 = getelementptr inbounds i32, i32* %10, i64 2
store i32 %16, i32* %17
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
%19 = load i32, i32* %10
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %15
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %17
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = tail call i32 @free(i32* %2)
%26 = tail call i32 @free(i32* %10)
ret i32 0
}