#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 /*<<< orphan*/ scanf(char *, int *);
void ex2() {
  print("\n------------------------------\n");
  print("Verifique se o algoritmo abaixo esta correto. Se nao, explique o(s) "
        "erro(s) e corrija-o(s).");
  int a, b, c, menor;
  printf("Digite o primeiro numero: ");
  scanf("%d", &a);
  printf("Digite o segundo numero: ");
  scanf("%d", &b);
  printf("Digite o terceiro numero: ");
  scanf("%d", &c);
  if (a < b && b < c)
    menor = a;
  else {
    if (c < a && a < b)
      menor = c;
    else if (b < c)
      menor = b;
    else
      menor = c;
  }
  printf("Menor: %d\n", menor);
  print("\n------------------------------\n");
}


x86 assembly (clang, -O0):
<ex2>:
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    0xf26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf33(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cd <ex2+0x9d>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <ex2+0x9d>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1217 <ex2+0xe7>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f0 <ex2+0xc0>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f0 <ex2+0xc0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1212 <ex2+0xe2>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1207 <ex2+0xd7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    120d <ex2+0xdd>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1212 <ex2+0xe2>
jmp    1217 <ex2+0xe7>
mov    -0x10(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd1(%rip),%rdi
call   1040 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex2>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec2(%rip),%r14
mov    %r14,%rdi
call   1040 <print@plt>
lea    0xed4(%rip),%rdi
call   1040 <print@plt>
lea    0xf24(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf31(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf20(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xf1f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
mov    0xc(%rsp),%ecx
cmp    %ecx,%eax
mov    %ecx,%esi
cmovl  %eax,%esi
mov    0x14(%rsp),%edi
cmp    %eax,%edi
mov    %esi,%edx
cmovl  %ecx,%edx
cmp    %edi,%ecx
cmovge %esi,%edx
cmp    %ecx,%eax
mov    %edx,%esi
cmovl  %edi,%esi
cmp    %eax,%edi
cmovge %edx,%esi
lea    0xef4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <print@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A------------------------------\0A\00"
@.str.1 = [92 x i8] c"Verifique se o algoritmo abaixo esta correto. Se nao, explique o(s) erro(s) e corrija-o(s).\00"
@.str.2 = [27 x i8] c"Digite o primeiro numero: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [26 x i8] c"Digite o segundo numero: \00"
@.str.5 = [27 x i8] c"Digite o terceiro numero: \00"
@.str.6 = [11 x i8] c"Menor: %d\0A\00"
define void @ex2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%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 ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0))
%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.3, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %0
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i32, i32* %1
store i32 %21, i32* %4
br label %42
22: ; preds = %16, %0
%23 = load i32, i32* %3
%24 = load i32, i32* %1
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i32, i32* %3
store i32 %31, i32* %4
br label %41
32: ; preds = %26, %22
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = load i32, i32* %2
store i32 %37, i32* %4
br label %40
38: ; preds = %32
%39 = load i32, i32* %3
store i32 %39, i32* %4
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40, %30
br label %42
42: ; preds = %41, %20
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = 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 = [92 x i8] c"Verifique se o algoritmo abaixo esta correto. Se nao, explique o(s) erro(s) e corrija-o(s).\00"
@.str.2 = [27 x i8] c"Digite o primeiro numero: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [26 x i8] c"Digite o segundo numero: \00"
@.str.5 = [27 x i8] c"Digite o terceiro numero: \00"
@.str.6 = [11 x i8] c"Menor: %d\0A\00"
define void @ex2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @print(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
%18 = load i32, i32* %3
%19 = icmp slt i32 %16, %18
%20 = select i1 %17, i1 %19, i1 false
%21 = icmp slt i32 %18, %15
%22 = select i1 %21, i1 %17, i1 false
%23 = select i1 %19, i32 %16, i32 %18
%24 = select i1 %22, i32 %18, i32 %23
%25 = select i1 %20, i32 %15, i32 %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = call i32 @print(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}