#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int arr1[30], arr2[30], i, num;
  printf("\nEnter no of elements :");
  scanf("%d", &num);
  printf("\nEnter the values :");
  for (i = 0; i < num; i++) {
    scanf("%d", &arr1[i]);
  }
  for (i = 0; i < num; i++) {
    arr2[i] = arr1[i];
  }
  printf("The copied array is :");
  for (i = 0; i < num; i++)
    printf("\narr2[%d] = %d", i, arr2[i]);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
lea    -0x108(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x104(%rbp)
mov    -0x104(%rbp),%eax
cmp    -0x108(%rbp),%eax
jge    11af <main+0x8f>
movslq -0x104(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb8(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    116b <main+0x4b>
movl   $0x0,-0x104(%rbp)
mov    -0x104(%rbp),%eax
cmp    -0x108(%rbp),%eax
jge    11f8 <main+0xd8>
movslq -0x104(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%ecx
movslq -0x104(%rbp),%rax
mov    %ecx,-0x100(%rbp,%rax,4)
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    11b9 <main+0x99>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x104(%rbp)
mov    -0x104(%rbp),%eax
cmp    -0x108(%rbp),%eax
jge    1258 <main+0x138>
mov    -0x104(%rbp),%esi
movslq -0x104(%rbp),%rax
mov    -0x100(%rbp,%rax,4),%edx
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1210 <main+0xf0>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c9 <main+0x99>
lea    0x90(%rsp),%r15
xor    %ebx,%ebx
lea    0xecd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1190 <main+0x60>
mov    %eax,%edx
test   %edx,%edx
jle    11c9 <main+0x99>
shl    $0x2,%rdx
lea    0x10(%rsp),%rdi
lea    0x90(%rsp),%rsi
call   1040 <memcpy@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    120e <main+0xde>
lea    0xe5d(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <main+0xc0>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0AEnter no of elements :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AEnter the values :\00"
@.str.3 = [22 x i8] c"The copied array is :\00"
@.str.4 = [15 x i8] c"\0Aarr2[%d] = %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i32]
%3 = alloca [30 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %9
21: ; preds = %9
store i32 0, i32* %4
br label %22
22: ; preds = %34, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [30 x i32], [30 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %32
store i32 %30, i32* %33
br label %34
34: ; preds = %26
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %22
37: ; preds = %22
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %39
39: ; preds = %50, %37
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %53
43: ; preds = %39
%44 = load i32, i32* %4
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 %48)
br label %50
50: ; preds = %43
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %39
53: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"\0AEnter no of elements :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AEnter the values :\00"
@.str.3 = [22 x i8] c"The copied array is :\00"
@.str.4 = [15 x i8] c"\0Aarr2[%d] = %d\00"
define i32 @main() {
%1 = alloca [30 x i32]
%2 = bitcast [30 x i32]* %1 to i8*
%3 = alloca [30 x i32]
%4 = bitcast [30 x i32]* %3 to i8*
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br i1 %11, label %17, label %25
12: ; preds = %17
%13 = icmp sgt i32 %22, 0
br i1 %13, label %14, label %25
14: ; preds = %12
%15 = zext i32 %22 to i64
%16 = shl nuw nsw i64 %15, 2
br label %25
17: ; preds = %0, %17
%18 = phi i64 [ %21, %17 ], [ 0, %0 ]
%19 = getelementptr inbounds [30 x i32], [30 x i32]* %1, i64 0, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = add nuw nsw i64 %18, 1
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %17, label %12
25: ; preds = %0, %14, %12
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%27 = load i32, i32* %5
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %25, %29
%30 = phi i64 [ %35, %29 ], [ 0, %25 ]
%31 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = trunc i64 %30 to i32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %33, i32 %32)
%35 = add nuw nsw i64 %30, 1
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %29, label %39
39: ; preds = %29, %25
ret i32 0
}