#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 *);
int main() {
  int numero_de_pes = 0, numero_de_cabecas = 0, quantidade_de_patos = 0,
      quantidade_de_coelhos = 0, resto_de_animais = 0;
  printf("\nEntre com o numero de cabecas:\n");
  scanf("%d", &numero_de_cabecas);
  printf("\nEntre com o numero de pes:\n");
  scanf("%d", &numero_de_pes);
  if (numero_de_pes > 2 && numero_de_cabecas > 0) {
    if (numero_de_pes >= numero_de_cabecas * 2 &&
        numero_de_pes <= numero_de_cabecas * 4) {
      quantidade_de_coelhos = (numero_de_pes - (2 * numero_de_cabecas)) / 2;
      quantidade_de_patos = numero_de_cabecas - quantidade_de_coelhos;
      printf("A quantidade de patos é %d \n", quantidade_de_patos);
      printf("A quantidade de coelhos é %d \n", quantidade_de_coelhos);
    } else {
      printf("\nNumero de pes e cabecas invalido. Tem algum bicho invalido "
             "(aleijado).\n");
    }
  } else {
    printf("\nNumero de pes e cabecas invalido\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2,-0x8(%rbp)
jle    121d <main+0xfd>
cmpl   $0x0,-0xc(%rbp)
jle    121d <main+0xfd>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jl     120a <main+0xea>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jg     120a <main+0xea>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <main+0xf8>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <main+0x10b>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jl     11ce <main+0x9e>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    11ce <main+0x9e>
lea    (%rsi,%rsi,1),%edx
mov    %eax,%ecx
sub    %edx,%ecx
jl     11d7 <main+0xa7>
lea    0x0(,%rsi,4),%edx
cmp    %edx,%eax
jg     11d7 <main+0xa7>
mov    %ecx,%ebx
shr    $0x1f,%ebx
add    %ecx,%ebx
sar    %ebx
sub    %ebx,%esi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e3 <main+0xb3>
lea    0xea8(%rip),%rdi
jmp    11de <main+0xae>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0AEntre com o numero de cabecas:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AEntre com o numero de pes:\0A\00"
@.str.3 = [30 x i8] c"A quantidade de patos \C3\A9 %d \0A\00"
@.str.4 = [32 x i8] c"A quantidade de coelhos \C3\A9 %d \0A\00"
@.str.5 = [73 x i8] c"\0ANumero de pes e cabecas invalido. Tem algum bicho invalido (aleijado).\0A\00"
@.str.6 = [35 x i8] c"\0ANumero de pes e cabecas invalido\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 2
br i1 %12, label %13, label %42
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %42
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 2
%20 = icmp sge i32 %17, %19
br i1 %20, label %21, label %39
21: ; preds = %16
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = mul nsw i32 %23, 4
%25 = icmp sle i32 %22, %24
br i1 %25, label %26, label %39
26: ; preds = %21
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = mul nsw i32 2, %28
%30 = sub nsw i32 %27, %29
%31 = sdiv i32 %30, 2
store i32 %31, i32* %5
%32 = load i32, i32* %3
%33 = load i32, i32* %5
%34 = sub nsw i32 %32, %33
store i32 %34, i32* %4
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %5
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %41
39: ; preds = %21, %16
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.5, i64 0, i64 0))
br label %41
41: ; preds = %39, %26
br label %44
42: ; preds = %13, %0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %44
44: ; preds = %42, %41
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [30 x i8] c"A quantidade de patos \C3\A9 %d \0A\00"
@.str.4 = [32 x i8] c"A quantidade de coelhos \C3\A9 %d \0A\00"
@str = [32 x i8] c"\0AEntre com o numero de cabecas:\00"
@str.7 = [28 x i8] c"\0AEntre com o numero de pes:\00"
@str.8 = [34 x i8] c"\0ANumero de pes e cabecas invalido\00"
@str.9 = [72 x i8] c"\0ANumero de pes e cabecas invalido. Tem algum bicho invalido (aleijado).\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.7, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 2
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %28
14: ; preds = %0
%15 = shl nuw nsw i32 %11, 1
%16 = icmp slt i32 %9, %15
%17 = shl nsw i32 %11, 2
%18 = icmp sgt i32 %9, %17
%19 = select i1 %16, i1 true, i1 %18
br i1 %19, label %26, label %20
20: ; preds = %14
%21 = sub nsw i32 %9, %15
%22 = sdiv i32 %21, 2
%23 = sub nsw i32 %11, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %22)
br label %30
26: ; preds = %14
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.9, i64 0, i64 0))
br label %30
28: ; preds = %0
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.8, i64 0, i64 0))
br label %30
30: ; preds = %20, %26, %28
ret i32 0
}