#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*/ cprint(char *);
int /*<<< orphan*/ cprintf(char *, char *);
int /*<<< orphan*/ get_input(char *, int, char *);
char *read_animal(char *target, int len) {
  cprint("\n <b><fg:cyan>*** You win! ***<r>\n");
  if (!get_input(target, len, "What <u>animal</u> is it?"))
    return NULL;
  cprintf("\n Animal learned: <fg:cyan><b>%s<r>\n", target);
  return target;
}


x86 assembly (clang, -O0):
<read_animal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <cprint@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xeca(%rip),%rdx
call   1050 <get_input@plt>
cmp    $0x0,%eax
jne    1174 <read_animal+0x44>
movq   $0x0,-0x8(%rbp)
jmp    118c <read_animal+0x5c>
mov    -0x10(%rbp),%rsi
lea    0xebe(%rip),%rdi
call   1040 <cprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_animal>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xec1(%rip),%rdi
call   1030 <cprint@plt>
lea    0xed8(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <get_input@plt>
test   %eax,%eax
je     116a <read_animal+0x3a>
lea    0xedd(%rip),%rdi
mov    %rbx,%rsi
call   1040 <cprintf@plt>
jmp    116c <read_animal+0x3c>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0A <b><fg:cyan>*** You win! ***<r>\0A\00"
@.str.1 = [26 x i8] c"What <u>animal</u> is it?\00"
@.str.2 = [37 x i8] c"\0A Animal learned: <fg:cyan><b>%s<r>\0A\00"
define i8* @read_animal(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = call i32 @cprint(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %4
%8 = load i32, i32* %5
%9 = call i32 @get_input(i8* %7, i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i8* null, i8** %3
br label %16
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @cprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %4
store i8* %15, i8** %3
br label %16
16: ; preds = %12, %11
%17 = load i8*, i8** %3
ret i8* %17
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0A <b><fg:cyan>*** You win! ***<r>\0A\00"
@.str.1 = [26 x i8] c"What <u>animal</u> is it?\00"
@.str.2 = [37 x i8] c"\0A Animal learned: <fg:cyan><b>%s<r>\0A\00"
define i8* @read_animal(i8* %0, i32 %1) {
%3 = tail call i32 @cprint(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @get_input(i8* %0, i32 %1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @cprintf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %8
8: ; preds = %2, %6
%9 = phi i8* [ %0, %6 ], [ null, %2 ]
ret i8* %9
}