#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 *);
main() {
  int arr[4];
  int temp, i;
  printf("Please insert 4 integers:\n");
  for (i = 0; i < 4; i++) {
    scanf("%d", &arr[i]);
  }
  for (i = 0; i < 4; i++) {
    printf("arr[%d]: %d\n", i, arr[i]);
  }
  temp = arr[0];
  arr[0] = arr[1];
  arr[1] = temp;
  printf("\n");
  temp = arr[2];
  arr[2] = arr[3];
  arr[3] = temp;
  for (i = 0; i < 4; i++) {
    printf("arr[%d]: %d\n", i, arr[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1177 <main+0x57>
movslq -0x28(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb7(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1144 <main+0x24>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    11af <main+0x8f>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117e <main+0x5e>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1219 <main+0xf9>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e8 <main+0xc8>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0xea8(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    (%rsp),%edx
lea    0xe6f(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
rolq   $0x20,(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
rolq   $0x20,0x8(%rsp)
mov    (%rsp),%edx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"arr[%d]: %d\0A\00"
@str = [26 x i8] c"Please insert 4 integers:\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%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 2
%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 3
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = load i32, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %12)
%14 = load i32, i32* %6
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %14)
%16 = load i32, i32* %8
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %16)
%18 = load i32, i32* %10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %18)
%20 = load i32, i32* %4
%21 = load i32, i32* %6
store i32 %21, i32* %4
store i32 %20, i32* %6
%22 = call i32 @putchar(i32 10)
%23 = load i32, i32* %8
%24 = load i32, i32* %10
store i32 %24, i32* %8
store i32 %23, i32* %10
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 %25)
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 %27)
%29 = load i32, i32* %8
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 %29)
%31 = load i32, i32* %10
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %31)
ret i32 0
}