#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 chickens(unsigned int, unsigned int);
int /*<<< orphan*/ die(char *);
int goats(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main() {
  unsigned input1, input2;
  printf("Input the number of heads: ");
  if (!scanf("%u", &input1))
    die("Input failure.\n");
  printf("Input the number of legs: ");
  if (!scanf("%u", &input2))
    die("Input failure.\n");
  printf("That's %u chickens and %u goats.\n", chickens(input1, input2),
         goats(input1, input2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%eax
jne    1192 <main+0x42>
lea    0xe92(%rip),%rdi
call   1060 <die@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%eax
jne    11c5 <main+0x75>
lea    0xe5f(%rip),%rdi
call   1060 <die@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <chickens@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <goats@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
test   %eax,%eax
jne    1184 <main+0x34>
lea    0xea0(%rip),%rdi
call   1060 <die@plt>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
test   %eax,%eax
jne    11b3 <main+0x63>
lea    0xe71(%rip),%rdi
call   1060 <die@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1030 <chickens@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1070 <goats@plt>
lea    0xe74(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Input the number of heads: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [16 x i8] c"Input failure.\0A\00"
@.str.3 = [27 x i8] c"Input the number of legs: \00"
@.str.4 = [34 x i8] c"That's %u chickens and %u goats.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = icmp ne i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @chickens(i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 @goats(i32 %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Input the number of heads: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [16 x i8] c"Input failure.\0A\00"
@.str.3 = [27 x i8] c"Input the number of legs: \00"
@.str.4 = [34 x i8] c"That's %u chickens and %u goats.\0A\00"
define i32 @main() {
%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 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @chickens(i32 %17, i32 %18)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 @goats(i32 %20, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 %22)
ret i32 0
}