#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int escolha, x1, x2, y1, y2, z1, z2;
  printf("Produto Escalar de Dois Vetores!\nO seu vetor possui 1, 2 ou 3 "
         "coordenadas?\n");
  scanf("%d", &escolha);
  while ((escolha != 2) && (escolha != 3) && (escolha != 1)) {
    printf("Numero de coordenadas invalida\nO seu vetor possui UMA (1), DUAS "
           "(2) ou TRES (3) coordenadas?\n");
    scanf("%d", &escolha);
  }
  switch (escolha) {
  case 1:
    printf("Seu vetor possui 2 coordenadas, digite a coordenada X do primeiro "
           "vetor!\n");
    scanf("%d", &x1);
    printf("Digite a coordenada X do segundo vetor!\n");
    scanf("%d", &x2);
    printf("O produto escalar do seu vetor é: %d", ((x1 * x2)));
    break;
  case 2:
    printf("Seu vetor possui 2 coordenadas, digite as coordenadas X e Y do "
           "primeiro vetor!\n");
    scanf("%d"
          "%d",
          &x1, &y1);
    printf("Digite as coordenadas X e Y do segundo vetor!\n");
    scanf("%d"
          "%d",
          &x2, &y2);
    printf("O produto escalar do seu vetor é: %d", ((x1 * x2) + (y1 * y2)));
    break;
  case 3:
    printf("Seu vetor possui 3 coordenadas, digite as coordenadas X, Y e Z do "
           "primeiro vetor!\n");
    scanf("%d"
          "%d"
          "%d",
          &x1, &y1, &z1);
    printf("Digite as coordenadas X, Y e Z do segundo vetor!\n");
    scanf("%d"
          "%d",
          &x2, &y2, &z2);
    printf("O produto escalar do seu vetor é: %d",
           ((x1 * x2) + (y1 * y2) + (z1 * z2)));
    break;
  }
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfec(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     1187 <main+0x57>
xor    %eax,%eax
cmpl   $0x3,-0x8(%rbp)
mov    %al,-0x21(%rbp)
je     1187 <main+0x57>
cmpl   $0x1,-0x8(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1197 <main+0x67>
jmp    11bc <main+0x8c>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf94(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
jmp    115f <main+0x2f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     11f2 <main+0xc2>
jmp    11d0 <main+0xa0>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     124c <main+0x11c>
jmp    11e1 <main+0xb1>
mov    -0x28(%rbp),%eax
sub    $0x3,%eax
je     12b7 <main+0x187>
jmp    132e <main+0x1fe>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf39(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf19(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132e <main+0x1fe>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfb6(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf92(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
add    %eax,%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    132e <main+0x1fe>
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf49(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
add    %eax,%esi
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
add    %eax,%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%r14
lea    0x1c(%rsp),%rbx
lea    0x1081(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x1c(%rsp),%eax
cmp    $0x1,%eax
je     119e <main+0x5e>
cmp    $0x2,%eax
je     11e9 <main+0xa9>
cmp    $0x3,%eax
je     1246 <main+0x106>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1170 <main+0x30>
lea    0xfd3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe72(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xffa(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
imul   0x8(%rsp),%esi
jmp    12b7 <main+0x177>
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2c(%rip),%rbx
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf33(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
imul   0x8(%rsp),%eax
mov    0xc(%rsp),%esi
imul   0x10(%rsp),%esi
add    %eax,%esi
jmp    12b7 <main+0x177>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xdcd(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x18(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
lea    0xda6(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x14(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
imul   0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
imul   0x10(%rsp),%ecx
add    %eax,%ecx
mov    0x14(%rsp),%esi
imul   0x18(%rsp),%esi
add    %ecx,%esi
lea    0xd42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [76 x i8] c"Produto Escalar de Dois Vetores!\0AO seu vetor possui 1, 2 ou 3 coordenadas?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [94 x i8] c"Numero de coordenadas invalida\0AO seu vetor possui UMA (1), DUAS (2) ou TRES (3) coordenadas?\0A\00"
@.str.3 = [74 x i8] c"Seu vetor possui 2 coordenadas, digite a coordenada X do primeiro vetor!\0A\00"
@.str.4 = [41 x i8] c"Digite a coordenada X do segundo vetor!\0A\00"
@.str.5 = [38 x i8] c"O produto escalar do seu vetor \C3\A9: %d\00"
@.str.6 = [80 x i8] c"Seu vetor possui 2 coordenadas, digite as coordenadas X e Y do primeiro vetor!\0A\00"
@.str.7 = [5 x i8] c"%d%d\00"
@.str.8 = [47 x i8] c"Digite as coordenadas X e Y do segundo vetor!\0A\00"
@.str.9 = [83 x i8] c"Seu vetor possui 3 coordenadas, digite as coordenadas X, Y e Z do primeiro vetor!\0A\00"
@.str.10 = [7 x i8] c"%d%d%d\00"
@.str.11 = [50 x i8] c"Digite as coordenadas X, Y e Z do segundo vetor!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %22, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 1
br label %20
20: ; preds = %17, %14, %11
%21 = phi i1 [ false, %14 ], [ false, %11 ], [ %19, %17 ]
br i1 %21, label %22, label %25
22: ; preds = %20
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %11
25: ; preds = %20
%26 = load i32, i32* %2
switch i32 %26, label %66 [
i32 1, label %27
i32 2, label %36
i32 3, label %49
]
27: ; preds = %25
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = mul nsw i32 %32, %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %66
36: ; preds = %25
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %3, i32* %5)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
%40 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %4, i32* %6)
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = mul nsw i32 %41, %42
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = mul nsw i32 %44, %45
%47 = add nsw i32 %43, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %47)
br label %66
49: ; preds = %25
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.9, i64 0, i64 0))
%51 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32* %3, i32* %5, i32* %7)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.11, i64 0, i64 0))
%53 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %4, i32* %6, i32* %8)
%54 = load i32, i32* %3
%55 = load i32, i32* %4
%56 = mul nsw i32 %54, %55
%57 = load i32, i32* %5
%58 = load i32, i32* %6
%59 = mul nsw i32 %57, %58
%60 = add nsw i32 %56, %59
%61 = load i32, i32* %7
%62 = load i32, i32* %8
%63 = mul nsw i32 %61, %62
%64 = add nsw i32 %60, %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %25, %49, %36, %27
%67 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [38 x i8] c"O produto escalar do seu vetor \C3\A9: %d\00"
@.str.7 = [5 x i8] c"%d%d\00"
@.str.10 = [7 x i8] c"%d%d%d\00"
@str = [75 x i8] c"Produto Escalar de Dois Vetores!\0AO seu vetor possui 1, 2 ou 3 coordenadas?\00"
@str.12 = [82 x i8] c"Seu vetor possui 3 coordenadas, digite as coordenadas X, Y e Z do primeiro vetor!\00"
@str.13 = [49 x i8] c"Digite as coordenadas X, Y e Z do segundo vetor!\00"
@str.14 = [79 x i8] c"Seu vetor possui 2 coordenadas, digite as coordenadas X e Y do primeiro vetor!\00"
@str.15 = [46 x i8] c"Digite as coordenadas X e Y do segundo vetor!\00"
@str.16 = [73 x i8] c"Seu vetor possui 2 coordenadas, digite a coordenada X do primeiro vetor!\00"
@str.17 = [40 x i8] c"Digite a coordenada X do segundo vetor!\00"
@str.18 = [93 x i8] c"Numero de coordenadas invalida\0AO seu vetor possui UMA (1), DUAS (2) ou TRES (3) coordenadas?\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %19, %0
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
switch i32 %18, label %19 [
i32 1, label %21
i32 2, label %29
i32 3, label %41
]
19: ; preds = %16
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @str.18, i64 0, i64 0))
br label %16
21: ; preds = %16
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.16, i64 0, i64 0))
%23 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.17, i64 0, i64 0))
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = mul nsw i32 %27, %26
br label %57
29: ; preds = %16
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str.14, i64 0, i64 0))
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %2, i32* %4)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.15, i64 0, i64 0))
%33 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %3, i32* %5)
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = mul nsw i32 %35, %34
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = mul nsw i32 %38, %37
%40 = add nsw i32 %39, %36
br label %57
41: ; preds = %16
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.12, i64 0, i64 0))
%43 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32* %2, i32* %4, i32* %6)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.13, i64 0, i64 0))
%45 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %3, i32* %5, i32* %7)
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = mul nsw i32 %47, %46
%49 = load i32, i32* %4
%50 = load i32, i32* %5
%51 = mul nsw i32 %50, %49
%52 = add nsw i32 %51, %48
%53 = load i32, i32* %6
%54 = load i32, i32* %7
%55 = mul nsw i32 %54, %53
%56 = add nsw i32 %52, %55
br label %57
57: ; preds = %41, %29, %21
%58 = phi i32 [ %56, %41 ], [ %40, %29 ], [ %28, %21 ]
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i32 %58)
%60 = call i32 (...) @getch()
ret i32 0
}