#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*/ print(char *);
int /*<<< orphan*/ printf(char *, float, float);
void ex5() {
  print("\n------------------------------\n");
  print("5. Seguindo atraves dos trechos de algoritmos abaixo, determine o "
        "valor final de X e de Y.");
  print("Em ambos os casos, considere os valores iniciais: X = 1.0 e Y = 1.0");
  float x = 1, y = 1, a, b;
  print("\nPrimeiro algoritmo:");
  print("\tA = X + 5.0\n\tB = Y + 3.0\n\tX = A + B\n\tY = X + A\n\tB = Y / 4.0 "
        "+ X\n\tA = B / 2. + Y\n\tX = X + A + B - Y\n\tY = Y + B");
  a = x + 5;
  b = y + 3;
  x = a + b;
  y = x + a;
  b = y / 4.0 + x;
  a = b / 2. + y;
  x = x + a + b - y;
  y = y + b;
  printf("Valores finais:\n\tx:%.2f\n\ty:%.2f\n", x, y);
  x = 1, y = 1, a = 0, b = 0;
  print("\nSegundo algoritmo:");
  print("\tX = X + Y\n\tX = X*2\n\tA = X + Y\n\tB = A - 5.0\n\tY = A\n\tB = B "
        "/ Y + 2.0\n\tX = (Y + A) / B\n\tY = Y / A + X /B");
  x = x + y;
  x = x * 2;
  a = x + y;
  b = a - 5.0;
  y = a;
  b = b / y + 2.0;
  x = (y + a) / b;
  y = y / a + x / b;
  printf("Valores finais:\n\tx:%.2f\n\ty:%.2f\n", x, y);
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xef9(%rip),%rdi
call   1040 <print@plt>
lea    0xf0e(%rip),%rdi
call   1040 <print@plt>
lea    0xf5d(%rip),%rdi
call   1040 <print@plt>
movss  0xec8(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xebb(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xf7b(%rip),%rdi
call   1040 <print@plt>
lea    0xf84(%rip),%rdi
call   1040 <print@plt>
movss  0xe9e(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe88(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe04(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
lea    0xf1d(%rip),%rdi
call   1030 <printf@plt>
movss  0xdc0(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xdb3(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xf08(%rip),%rdi
call   1040 <print@plt>
lea    0xf10(%rip),%rdi
call   1040 <print@plt>
movss  -0x4(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xd6b(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd31(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcfc(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
divss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
lea    0xcc9(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex5>:
push   %r14
push   %rbx
push   %rax
lea    0xee5(%rip),%r14
mov    %r14,%rdi
call   1040 <print@plt>
lea    0xef7(%rip),%rdi
call   1040 <print@plt>
lea    0xf46(%rip),%rdi
call   1040 <print@plt>
lea    0xf7e(%rip),%rdi
call   1040 <print@plt>
lea    0xf87(%rip),%rdi
call   1040 <print@plt>
lea    0xfea(%rip),%rbx
movss  0xe8e(%rip),%xmm0
movss  0xe8a(%rip),%xmm1
mov    %rbx,%rdi
call   1030 <printf@plt>
lea    0xfec(%rip),%rdi
call   1040 <print@plt>
lea    0xff4(%rip),%rdi
call   1040 <print@plt>
movss  0xe66(%rip),%xmm0
movss  0xe62(%rip),%xmm1
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <print@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [91 x i8] c"5. Seguindo atraves dos trechos de algoritmos abaixo, determine o valor final de X e de Y.\00"
@.str.2 = [68 x i8] c"Em ambos os casos, considere os valores iniciais: X = 1.0 e Y = 1.0\00"
@.str.3 = [21 x i8] c"\0APrimeiro algoritmo:\00"
@.str.4 = [111 x i8] c"\09A = X + 5.0\0A\09B = Y + 3.0\0A\09X = A + B\0A\09Y = X + A\0A\09B = Y / 4.0 + X\0A\09A = B / 2. + Y\0A\09X = X + A + B - Y\0A\09Y = Y + B\00"
@.str.5 = [33 x i8] c"Valores finais:\0A\09x:%.2f\0A\09y:%.2f\0A\00"
@.str.6 = [20 x i8] c"\0ASegundo algoritmo:\00"
@.str.7 = [103 x i8] c"\09X = X + Y\0A\09X = X*2\0A\09A = X + Y\0A\09B = A - 5.0\0A\09Y = A\0A\09B = B / Y + 2.0\0A\09X = (Y + A) / B\0A\09Y = Y / A + X /B\00"
define void @ex5() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @print(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @print(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
store float 1.000000e+00, float* %1
store float 1.000000e+00, float* %2
%8 = call i32 @print(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @print(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.4, i64 0, i64 0))
%10 = load float, float* %1
%11 = fadd float %10, 5.000000e+00
store float %11, float* %3
%12 = load float, float* %2
%13 = fadd float %12, 3.000000e+00
store float %13, float* %4
%14 = load float, float* %3
%15 = load float, float* %4
%16 = fadd float %14, %15
store float %16, float* %1
%17 = load float, float* %1
%18 = load float, float* %3
%19 = fadd float %17, %18
store float %19, float* %2
%20 = load float, float* %2
%21 = fpext float %20 to double
%22 = fdiv double %21, 4.000000e+00
%23 = load float, float* %1
%24 = fpext float %23 to double
%25 = fadd double %22, %24
%26 = fptrunc double %25 to float
store float %26, float* %4
%27 = load float, float* %4
%28 = fpext float %27 to double
%29 = fdiv double %28, 2.000000e+00
%30 = load float, float* %2
%31 = fpext float %30 to double
%32 = fadd double %29, %31
%33 = fptrunc double %32 to float
store float %33, float* %3
%34 = load float, float* %1
%35 = load float, float* %3
%36 = fadd float %34, %35
%37 = load float, float* %4
%38 = fadd float %36, %37
%39 = load float, float* %2
%40 = fsub float %38, %39
store float %40, float* %1
%41 = load float, float* %2
%42 = load float, float* %4
%43 = fadd float %41, %42
store float %43, float* %2
%44 = load float, float* %1
%45 = load float, float* %2
%46 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), float %44, float %45)
store float 1.000000e+00, float* %1
store float 1.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%47 = call i32 @print(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 @print(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.7, i64 0, i64 0))
%49 = load float, float* %1
%50 = load float, float* %2
%51 = fadd float %49, %50
store float %51, float* %1
%52 = load float, float* %1
%53 = fmul float %52, 2.000000e+00
store float %53, float* %1
%54 = load float, float* %1
%55 = load float, float* %2
%56 = fadd float %54, %55
store float %56, float* %3
%57 = load float, float* %3
%58 = fpext float %57 to double
%59 = fsub double %58, 5.000000e+00
%60 = fptrunc double %59 to float
store float %60, float* %4
%61 = load float, float* %3
store float %61, float* %2
%62 = load float, float* %4
%63 = load float, float* %2
%64 = fdiv float %62, %63
%65 = fpext float %64 to double
%66 = fadd double %65, 2.000000e+00
%67 = fptrunc double %66 to float
store float %67, float* %4
%68 = load float, float* %2
%69 = load float, float* %3
%70 = fadd float %68, %69
%71 = load float, float* %4
%72 = fdiv float %70, %71
store float %72, float* %1
%73 = load float, float* %2
%74 = load float, float* %3
%75 = fdiv float %73, %74
%76 = load float, float* %1
%77 = load float, float* %4
%78 = fdiv float %76, %77
%79 = fadd float %75, %78
store float %79, float* %2
%80 = load float, float* %1
%81 = load float, float* %2
%82 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), float %80, float %81)
%83 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [91 x i8] c"5. Seguindo atraves dos trechos de algoritmos abaixo, determine o valor final de X e de Y.\00"
@.str.2 = [68 x i8] c"Em ambos os casos, considere os valores iniciais: X = 1.0 e Y = 1.0\00"
@.str.3 = [21 x i8] c"\0APrimeiro algoritmo:\00"
@.str.4 = [111 x i8] c"\09A = X + 5.0\0A\09B = Y + 3.0\0A\09X = A + B\0A\09Y = X + A\0A\09B = Y / 4.0 + X\0A\09A = B / 2. + Y\0A\09X = X + A + B - Y\0A\09Y = Y + B\00"
@.str.5 = [33 x i8] c"Valores finais:\0A\09x:%.2f\0A\09y:%.2f\0A\00"
@.str.6 = [20 x i8] c"\0ASegundo algoritmo:\00"
@.str.7 = [103 x i8] c"\09X = X + Y\0A\09X = X*2\0A\09A = X + Y\0A\09B = A - 5.0\0A\09Y = A\0A\09B = B / Y + 2.0\0A\09X = (Y + A) / B\0A\09Y = Y / A + X /B\00"
define void @ex5() {
%1 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @print(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @print(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @print(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @print(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), float 3.100000e+01, float 3.000000e+01)
%7 = tail call i32 @print(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%8 = tail call i32 @print(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.7, i64 0, i64 0))
%9 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), float 5.000000e+00, float 3.500000e+00)
%10 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}