#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 EXIT_SUCCESS;
int /*<<< orphan*/ imprimir_vetor(int, int, int, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ troca_blocos(int, int, int, int *);
int main(int argc, char **argv) {
  int n = 0;
  printf("Digite o tamanho do vetor: ");
  scanf("%d", &n);
  int vet[n];
  printf("Digite os elementos do vetor:\n");
  for (int i = 0; i < n; i++) {
    scanf("%d", &vet[i]);
  }
  int p = 0, q = 0, r = 0;
  printf("Digite p, q e r: ");
  scanf("%d %d %d", &p, &q, &r);
  printf("Vetor original:\n");
  imprimir_vetor(p, q, r, n, vet);
  troca_blocos(p, q, r, vet);
  printf("Vetor com subvetores trocados:\n");
  imprimir_vetor(p, r - (q - p), r, n, vet);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
xor    %eax,%eax
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ec <main+0xac>
mov    -0x40(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b5 <main+0x75>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
lea    0xe39(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%r8
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1040 <imprimir_vetor@plt>
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1060 <troca_blocos@plt>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%r8
mov    -0x30(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%eax
sub    -0x30(%rbp),%eax
sub    %eax,%esi
mov    -0x38(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1040 <imprimir_vetor@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,-0x2c(%rbp)
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11de <main+0x8e>
lea    0xe7a(%rip),%r15
mov    %r14,%r13
xor    %ebx,%ebx
nop
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     11c0 <main+0x70>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x30(%rbp),%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
mov    %r14,%r8
call   1050 <imprimir_vetor@plt>
mov    -0x38(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    %r14,%rcx
call   1070 <troca_blocos@plt>
lea    0xe14(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%edi
mov    -0x30(%rbp),%edx
lea    (%rdx,%rdi,1),%esi
sub    -0x34(%rbp),%esi
mov    -0x2c(%rbp),%ecx
mov    %r14,%r8
call   1050 <imprimir_vetor@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Digite o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Digite os elementos do vetor:\0A\00"
@.str.3 = [18 x i8] c"Digite p, q e r: \00"
@.str.4 = [9 x i8] c"%d %d %d\00"
@.str.5 = [17 x i8] c"Vetor original:\0A\00"
@.str.6 = [32 x i8] c"Vetor com subvetores trocados:\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%15 = load i32, i32* %6
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %7
%18 = alloca i32, i64 %16
store i64 %16, i64* %8
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %9
br label %20
20: ; preds = %29, %2
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %18, i64 %26
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %27)
br label %29
29: ; preds = %24
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %20
32: ; preds = %20
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %11, i32* %12)
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = load i32, i32* %12
%39 = load i32, i32* %6
%40 = call i32 @imprimir_vetor(i32 %36, i32 %37, i32 %38, i32 %39, i32* %18)
%41 = load i32, i32* %10
%42 = load i32, i32* %11
%43 = load i32, i32* %12
%44 = call i32 @troca_blocos(i32 %41, i32 %42, i32 %43, i32* %18)
%45 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%46 = load i32, i32* %10
%47 = load i32, i32* %12
%48 = load i32, i32* %11
%49 = load i32, i32* %10
%50 = sub nsw i32 %48, %49
%51 = sub nsw i32 %47, %50
%52 = load i32, i32* %12
%53 = load i32, i32* %6
%54 = call i32 @imprimir_vetor(i32 %46, i32 %51, i32 %52, i32 %53, i32* %18)
%55 = load i32, i32* @EXIT_SUCCESS
store i32 %55, i32* %3
%56 = load i8*, i8** %7
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [28 x i8] c"Digite o tamanho do vetor: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [18 x i8] c"Digite p, q e r: \00"
@.str.4 = [9 x i8] c"%d %d %d\00"
@EXIT_SUCCESS = global i32 0
@str = [30 x i8] c"Digite os elementos do vetor:\00"
@str.7 = [16 x i8] c"Vetor original:\00"
@str.8 = [31 x i8] c"Vetor com subvetores trocados:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
%13 = alloca i32, i64 %11
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = icmp sgt i32 %15, 0
br i1 %16, label %42, label %17
17: ; preds = %42, %2
%18 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%19 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%20 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.7, i64 0, i64 0))
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = load i32, i32* %3
%28 = call i32 @imprimir_vetor(i32 %24, i32 %25, i32 %26, i32 %27, i32* %13)
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = call i32 @troca_blocos(i32 %29, i32 %30, i32 %31, i32* %13)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%34 = load i32, i32* %4
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = add i32 %35, %34
%38 = sub i32 %37, %36
%39 = load i32, i32* %3
%40 = call i32 @imprimir_vetor(i32 %34, i32 %38, i32 %35, i32 %39, i32* %13)
%41 = load i32, i32* @EXIT_SUCCESS
ret i32 %41
42: ; preds = %2, %42
%43 = phi i64 [ %46, %42 ], [ 0, %2 ]
%44 = getelementptr inbounds i32, i32* %13, i64 %43
%45 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %44)
%46 = add nuw nsw i64 %43, 1
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %42, label %17
}