#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*/ printFArray(float *, int, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, float *);
void ex2() {
  float a[10], b[10], dif[10];
  for (int i = 0; i < 10; i++) {
    printf("Informe o elemento n%d do vetor A: ", i);
    scanf("%f", &a[i]);
    printf("Informe o elemento n%d do vetor B: ", i);
    scanf("%f", &b[i]);
    dif[i] = a[i] - b[i];
  }
  printFArray(a, 10, "Vetor A:");
  printFArray(b, 10, "Vetor B:");
  printFArray(dif, 10, "Vetor Diferenca:");
}


x86 assembly (clang, -O0):
<ex2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x94(%rbp)
cmpl   $0xa,-0x94(%rbp)
jge    11f0 <ex2+0xc0>
mov    -0x94(%rbp),%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
movslq -0x94(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea7(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x94(%rbp),%esi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
movslq -0x94(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe77(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x94(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
movslq -0x94(%rbp),%rax
subss  -0x60(%rbp,%rax,4),%xmm0
movslq -0x94(%rbp),%rax
movss  %xmm0,-0x90(%rbp,%rax,4)
ff ff
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1145 <ex2+0x15>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
lea    0xe4b(%rip),%rdx
call   1050 <printFArray@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
lea    0xe3f(%rip),%rdx
call   1050 <printFArray@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%esi
lea    0xe30(%rip),%rdx
call   1050 <printFArray@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
xor    %ebx,%ebx
lea    0xeb8(%rip),%r14
lea    0xed5(%rip),%r12
lea    0xed1(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    (%rsp,%rbx,1),%rsi
add    $0x30,%rsi
mov    %r12,%rdi
call   1040 <scanf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    (%rsp,%rbx,1),%rsi
mov    %r12,%rdi
call   1040 <scanf@plt>
movss  0x30(%rsp,%rbx,1),%xmm0
subss  (%rsp,%rbx,1),%xmm0
movss  %xmm0,0x60(%rsp,%rbx,1)
add    $0x1,%ebp
add    $0x4,%rbx
cmp    $0x28,%rbx
jne    1160 <ex2+0x30>
lea    0xe96(%rip),%rdx
lea    0x30(%rsp),%rdi
mov    $0xa,%esi
call   1050 <printFArray@plt>
lea    0xe89(%rip),%rdx
mov    %rsp,%rdi
mov    $0xa,%esi
call   1050 <printFArray@plt>
lea    0xe7e(%rip),%rdx
lea    0x60(%rsp),%rdi
mov    $0xa,%esi
call   1050 <printFArray@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Informe o elemento n%d do vetor A: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [36 x i8] c"Informe o elemento n%d do vetor B: \00"
@.str.3 = [9 x i8] c"Vetor A:\00"
@.str.4 = [9 x i8] c"Vetor B:\00"
@.str.5 = [17 x i8] c"Vetor Diferenca:\00"
define void @ex2() {
%1 = alloca [10 x float]
%2 = alloca [10 x float]
%3 = alloca [10 x float]
%4 = alloca i32
store i32 0, i32* %4
br label %5
5: ; preds = %33, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = load i32, i32* %4
%10 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %13)
%15 = load i32, i32* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %19)
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 %22
%24 = load float, float* %23
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %26
%28 = load float, float* %27
%29 = fsub float %24, %28
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 %31
store float %29, float* %32
br label %33
33: ; preds = %8
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %5
36: ; preds = %5
%37 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 0
%38 = call i32 @printFArray(float* %37, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%39 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%40 = call i32 @printFArray(float* %39, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%41 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%42 = call i32 @printFArray(float* %41, i32 10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Informe o elemento n%d do vetor A: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [36 x i8] c"Informe o elemento n%d do vetor B: \00"
@.str.3 = [9 x i8] c"Vetor A:\00"
@.str.4 = [9 x i8] c"Vetor B:\00"
@.str.5 = [17 x i8] c"Vetor Diferenca:\00"
define void @ex2() {
%1 = alloca [10 x float]
%2 = alloca [10 x float]
%3 = alloca [10 x float]
%4 = bitcast [10 x float]* %1 to i8*
%5 = bitcast [10 x float]* %2 to i8*
%6 = bitcast [10 x float]* %3 to i8*
br label %14
7: ; preds = %14
%8 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 0
%9 = call i32 @printFArray(float* %8, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%10 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 0
%11 = call i32 @printFArray(float* %10, i32 10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%12 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 0
%13 = call i32 @printFArray(float* %12, i32 10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
ret void
14: ; preds = %0, %14
%15 = phi i64 [ 0, %0 ], [ %27, %14 ]
%16 = trunc i64 %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 %15
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%21 = getelementptr inbounds [10 x float], [10 x float]* %2, i64 0, i64 %15
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %21)
%23 = load float, float* %18
%24 = load float, float* %21
%25 = fsub float %23, %24
%26 = getelementptr inbounds [10 x float], [10 x float]* %3, i64 0, i64 %15
store float %25, float* %26
%27 = add nuw nsw i64 %15, 1
%28 = icmp eq i64 %27, 10
br i1 %28, label %7, label %14
}