#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(void) {
  int arrayA[4] = {};
  int arrayB[4] = {};
  int i, temp;
  printf("input arrayA: a b c d\n");
  for (i = 0; i < 4; i++) {
    scanf("%d", &arrayA[i]);
  }
  printf("input arrayB: a b c d\n");
  for (i = 0; i < 4; i++) {
    scanf("%d", &arrayB[i]);
  }
  for (i = 0; i < 4; i++) {
    temp = arrayA[i];
    arrayA[i] = arrayB[i];
    arrayB[i] = temp;
  }
  printf("\nafter switch,arrayA:\n");
  for (i = 0; i < 4; i++) {
    printf("%d ", arrayA[i]);
  }
  printf("\nafter switch,arrayB:\n");
  for (i = 0; i < 4; i++) {
    printf("%d ", arrayB[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11a7 <main+0x77>
movslq -0x34(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe83(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1174 <main+0x44>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    11ef <main+0xbf>
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe3b(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11bc <main+0x8c>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1234 <main+0x104>
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x38(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x38(%rbp),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11f6 <main+0xc6>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    1277 <main+0x147>
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1249 <main+0x119>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x4,-0x34(%rbp)
jge    12ba <main+0x18a>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    128c <main+0x15c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movaps (%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
movaps %xmm0,0x10(%rsp)
movaps %xmm1,(%rsp)
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%esi
lea    0xe14(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"input arrayA: a b c d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"input arrayB: a b c d\0A\00"
@.str.3 = [23 x i8] c"\0Aafter switch,arrayA:\0A\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [23 x i8] c"\0Aafter switch,arrayB:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca [4 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [4 x i32]* %2 to i8*
%7 = bitcast [4 x i32]* %3 to i8*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %9
20: ; preds = %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %22
22: ; preds = %30, %20
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 4
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %25
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %22
33: ; preds = %22
store i32 0, i32* %4
br label %34
34: ; preds = %53, %33
%35 = load i32, i32* %4
%36 = icmp slt i32 %35, 4
br i1 %36, label %37, label %56
37: ; preds = %34
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %39
%41 = load i32, i32* %40
store i32 %41, i32* %5
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %47
store i32 %45, i32* %48
%49 = load i32, i32* %5
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %51
store i32 %49, i32* %52
br label %53
53: ; preds = %37
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %34
56: ; preds = %34
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %58
58: ; preds = %67, %56
%59 = load i32, i32* %4
%60 = icmp slt i32 %59, 4
br i1 %60, label %61, label %70
61: ; preds = %58
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %61
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %58
70: ; preds = %58
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %4
br label %72
72: ; preds = %81, %70
%73 = load i32, i32* %4
%74 = icmp slt i32 %73, 4
br i1 %74, label %75, label %84
75: ; preds = %72
%76 = load i32, i32* %4
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %75
%82 = load i32, i32* %4
%83 = add nsw i32 %82, 1
store i32 %83, i32* %4
br label %72
84: ; preds = %72
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d \00"
@str = [22 x i8] c"input arrayA: a b c d\00"
@str.6 = [22 x i8] c"input arrayB: a b c d\00"
@str.7 = [22 x i8] c"\0Aafter switch,arrayA:\00"
@str.8 = [22 x i8] c"\0Aafter switch,arrayB:\00"
define i32 @main() {
%1 = alloca <4 x i32>
%2 = alloca <4 x i32>
%3 = bitcast <4 x i32>* %1 to i8*
%4 = bitcast <4 x i32>* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 2
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 3
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
%15 = getelementptr inbounds <4 x i32>, <4 x i32>* %2, i64 0, i64 0
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds <4 x i32>, <4 x i32>* %2, i64 0, i64 1
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds <4 x i32>, <4 x i32>* %2, i64 0, i64 2
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds <4 x i32>, <4 x i32>* %2, i64 0, i64 3
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = load <4 x i32>, <4 x i32>* %2
%24 = load <4 x i32>, <4 x i32>* %1
store <4 x i32> %23, <4 x i32>* %1
store <4 x i32> %24, <4 x i32>* %2
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %8
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %10
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %12
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%35 = load i32, i32* %15
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %17
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %19
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %21
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
ret i32 0
}