#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 *, int, int, int, int, int, float);
int /*<<< orphan*/ scanf(char *, int *);
void ex6() {
  print("\n------------------------------\n");
  print("6. Elaborar um algoritmo para ler a base e a altura de um triangulo e "
        "imprimir sua area dada por: area = 1/2 * base * altura");
  int base, altura;
  float area;
  print("Digite o valor da base do triangulo:");
  scanf("%d", &base);
  print("Digite o valor da altura do triangulo:");
  scanf("%d", &altura);
  area = (base * altura) / 2;
  printf("Base: %d\nAltura: %d\nArea: (%d * %d) / 2 = %d / 2 = %.2f", base,
         altura, base, altura, base * altura, area);
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <print@plt>
lea    0xed6(%rip),%rdi
call   1040 <print@plt>
lea    0xf47(%rip),%rdi
call   1040 <print@plt>
lea    0xf60(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf53(%rip),%rdi
call   1040 <print@plt>
lea    0xf44(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0x4(%rbp),%r9d
imul   -0x8(%rbp),%r9d
movss  -0xc(%rbp),%xmm0
lea    0xf2b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex6>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%r14
mov    %r14,%rdi
call   1040 <print@plt>
lea    0xed7(%rip),%rdi
call   1040 <print@plt>
lea    0xf48(%rip),%rdi
call   1040 <print@plt>
lea    0xf61(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf50(%rip),%rdi
call   1040 <print@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%edx
mov    %edx,%r9d
imul   %ecx,%r9d
mov    %r9d,%eax
shr    $0x1f,%eax
add    %r9d,%eax
sar    %eax
cvtsi2ss %eax,%xmm0
lea    0xf43(%rip),%rdi
mov    %ecx,%esi
mov    %edx,%r8d
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <print@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [125 x i8] c"6. Elaborar um algoritmo para ler a base e a altura de um triangulo e imprimir sua area dada por: area = 1/2 * base * altura\00"
@.str.2 = [37 x i8] c"Digite o valor da base do triangulo:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [39 x i8] c"Digite o valor da altura do triangulo:\00"
@.str.5 = [56 x i8] c"Base: %d\0AAltura: %d\0AArea: (%d * %d) / 2 = %d / 2 = %.2f\00"
define void @ex6() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @print(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @print(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%8 = call i32 @print(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = mul nsw i32 %10, %11
%13 = sdiv i32 %12, 2
%14 = sitofp i32 %13 to float
store float %14, float* %3
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = mul nsw i32 %19, %20
%22 = load float, float* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i32 %15, i32 %16, i32 %17, i32 %18, i32 %21, float %22)
%24 = 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 = [125 x i8] c"6. Elaborar um algoritmo para ler a base e a altura de um triangulo e imprimir sua area dada por: area = 1/2 * base * altura\00"
@.str.2 = [37 x i8] c"Digite o valor da base do triangulo:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [39 x i8] c"Digite o valor da altura do triangulo:\00"
@.str.5 = [56 x i8] c"Base: %d\0AAltura: %d\0AArea: (%d * %d) / 2 = %d / 2 = %.2f\00"
define void @ex6() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @print(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 @print(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%9 = call i32 @print(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = mul nsw i32 %12, %11
%14 = sdiv i32 %13, 2
%15 = sitofp i32 %14 to float
%16 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0), i32 %11, i32 %12, i32 %11, i32 %12, i32 %13, float %15)
%17 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}