#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void ex1() {
  int num1, num2;
  printf("Informe o primeiro numero: ");
  scanf("%d", &num1);
  printf("Informe o segundo numero: ");
  scanf("%d", &num2);
  if (num1 < num2) {
    float media = (num1 + num2) / 2.;
    printf("Media dos numeros entre %d e %d = %.2f", num1, num2, media);
  } else if (num1 > num2) {
    int count = (num1 - num2) / 2;
    if (num1 % 2 == 0 || num2 % 2 == 0)
      count++;
    printf("Quantidade de numeros pares entre %d e %d = %d", num2, num1, count);
  } else {
    printf("Voce informou dois numeros iguais.");
  }
}


x86 assembly (clang, -O0):
<ex1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf55(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <ex1+0x91>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe7e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    122e <ex1+0x10e>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    121b <ex1+0xfb>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f6 <ex1+0xd6>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ff <ex1+0xdf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <ex1+0x109>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <ex1+0x10e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex1>:
push   %rbx
sub    $0x10,%rsp
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf58(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%edx
mov    %eax,%ecx
sub    %edx,%ecx
jge    1199 <ex1+0x79>
lea    (%rdx,%rax,1),%ecx
cvtsi2sd %ecx,%xmm0
mulsd  0xe81(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11d8 <ex1+0xb8>
jle    11ca <ex1+0xaa>
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
sar    %esi
test   $0x1,%al
sete   %cl
test   $0x1,%dl
sete   %bl
or     %cl,%bl
movzbl %bl,%ecx
add    %esi,%ecx
lea    0xea9(%rip),%rdi
mov    %edx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11d8 <ex1+0xb8>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Informe o primeiro numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Informe o segundo numero: \00"
@.str.3 = [39 x i8] c"Media dos numeros entre %d e %d = %.2f\00"
@.str.4 = [47 x i8] c"Quantidade de numeros pares entre %d e %d = %d\00"
@.str.5 = [35 x i8] c"Voce informou dois numeros iguais.\00"
define void @ex1() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %0
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = add nsw i32 %13, %14
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 2.000000e+00
%18 = fptrunc double %17 to float
store float %18, float* %3
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = load float, float* %3
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %20, double %22)
br label %51
24: ; preds = %0
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %48
28: ; preds = %24
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = sub nsw i32 %29, %30
%32 = sdiv i32 %31, 2
store i32 %32, i32* %4
%33 = load i32, i32* %1
%34 = srem i32 %33, 2
%35 = icmp eq i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %28
%37 = load i32, i32* %2
%38 = srem i32 %37, 2
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36, %28
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %43
43: ; preds = %40, %36
%44 = load i32, i32* %2
%45 = load i32, i32* %1
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
br label %50
48: ; preds = %24
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %43
br label %51
51: ; preds = %50, %12
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Informe o primeiro numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Informe o segundo numero: \00"
@.str.3 = [39 x i8] c"Media dos numeros entre %d e %d = %.2f\00"
@.str.4 = [47 x i8] c"Quantidade de numeros pares entre %d e %d = %d\00"
@.str.5 = [35 x i8] c"Voce informou dois numeros iguais.\00"
define void @ex1() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %0
%13 = add nsw i32 %10, %9
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 5.000000e-01
%16 = fptrunc double %15 to float
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %10, double %17)
br label %34
19: ; preds = %0
%20 = icmp sgt i32 %9, %10
br i1 %20, label %21, label %32
21: ; preds = %19
%22 = sub nsw i32 %9, %10
%23 = sdiv i32 %22, 2
%24 = and i32 %9, 1
%25 = icmp eq i32 %24, 0
%26 = and i32 %10, 1
%27 = icmp eq i32 %26, 0
%28 = select i1 %25, i1 true, i1 %27
%29 = zext i1 %28 to i32
%30 = add nsw i32 %23, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %10, i32 %9, i32 %30)
br label %34
32: ; preds = %19
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %21, %32, %12
ret void
}