#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 */
typedef scalar_t__ wchar_t;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ free(scalar_t__ *);
scalar_t__ *generate_sentence();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ wprintf(char *, ...);
void gen_with_output(void) {
  wchar_t c = L'y';
  while (c != EOF) {
    wchar_t *sent = generate_sentence();
    if (sent == NULL) {
      perror("generate_sentence()");
      wprintf(L"[!] Sentence generation failed!\n");
      exit(EXIT_FAILURE);
    }
    wprintf(L"Sentence: \"%ls\"\n", sent);
    free(sent);
    wprintf(L"Another? (ENTER for yes, Ctrl-D to stop) ");
    c = fgetc(stdin);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<gen_with_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x79,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%rax
je     1202 <gen_with_output+0xa2>
mov    $0x0,%al
call   1070 <generate_sentence@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c2 <gen_with_output+0x62>
lea    0xe5f(%rip),%rdi
call   1060 <perror@plt>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %rax,-0x8(%rbp)
jmp    1170 <gen_with_output+0x10>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<gen_with_output>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e70(%rip),%r12
cmpq   $0x79,(%r12)
je     11cd <gen_with_output+0x6d>
lea    0xf1a(%rip),%r14
lea    0xf57(%rip),%r15
mov    0x2e5c(%rip),%r13
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <generate_sentence@plt>
test   %rax,%rax
je     11db <gen_with_output+0x7b>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <wprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <wprintf@plt>
mov    0x0(%r13),%edi
call   1040 <fgetc@plt>
cmp    (%r12),%rax
jne    1190 <gen_with_output+0x30>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0xe1e(%rip),%rdi
call   1060 <perror@plt>
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1050 <wprintf@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@EOF = global i64 0
@.str = [20 x i8] c"generate_sentence()\00"
@.str.1 = [33 x i32] [i32 91, i32 33, i32 93, i32 32, i32 83, i32 101, i32 110, i32 116, i32 101, i32 110, i32 99, i32 101, i32 32, i32 103, i32 101, i32 110, i32 101, i32 114, i32 97, i32 116, i32 105, i32 111, i32 110, i32 32, i32 102, i32 97, i32 105, i32 108, i32 101, i32 100, i32 33, i32 10, i32 0]
@EXIT_FAILURE = global i32 0
@.str.2 = [17 x i32] [i32 83, i32 101, i32 110, i32 116, i32 101, i32 110, i32 99, i32 101, i32 58, i32 32, i32 34, i32 37, i32 108, i32 115, i32 34, i32 10, i32 0]
@.str.3 = [42 x i32] [i32 65, i32 110, i32 111, i32 116, i32 104, i32 101, i32 114, i32 63, i32 32, i32 40, i32 69, i32 78, i32 84, i32 69, i32 82, i32 32, i32 102, i32 111, i32 114, i32 32, i32 121, i32 101, i32 115, i32 44, i32 32, i32 67, i32 116, i32 114, i32 108, i32 45, i32 68, i32 32, i32 116, i32 111, i32 32, i32 115, i32 116, i32 111, i32 112, i32 41, i32 32, i32 0]
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define void @gen_with_output() {
%1 = alloca i64
%2 = alloca i64*
store i64 121, i64* %1
br label %3
3: ; preds = %16, %0
%4 = load i64, i64* %1
%5 = load i64, i64* @EOF
%6 = icmp ne i64 %4, %5
br i1 %6, label %7, label %24
7: ; preds = %3
%8 = call i64* (...) @generate_sentence()
store i64* %8, i64** %2
%9 = load i64*, i64** %2
%10 = icmp eq i64* %9, null
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @wprintf(i8* bitcast ([33 x i32]* @.str.1 to i8*))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %7
%17 = load i64*, i64** %2
%18 = call i32 (i8*, ...) @wprintf(i8* bitcast ([17 x i32]* @.str.2 to i8*), i64* %17)
%19 = load i64*, i64** %2
%20 = call i32 @free(i64* %19)
%21 = call i32 (i8*, ...) @wprintf(i8* bitcast ([42 x i32]* @.str.3 to i8*))
%22 = load i32, i32* @stdin
%23 = call i64 @fgetc(i32 %22)
store i64 %23, i64* %1
br label %3
24: ; preds = %3
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [20 x i8] c"generate_sentence()\00"
@.str.1 = [33 x i32] [i32 91, i32 33, i32 93, i32 32, i32 83, i32 101, i32 110, i32 116, i32 101, i32 110, i32 99, i32 101, i32 32, i32 103, i32 101, i32 110, i32 101, i32 114, i32 97, i32 116, i32 105, i32 111, i32 110, i32 32, i32 102, i32 97, i32 105, i32 108, i32 101, i32 100, i32 33, i32 10, i32 0]
@EXIT_FAILURE = global i32 0
@.str.2 = [17 x i32] [i32 83, i32 101, i32 110, i32 116, i32 101, i32 110, i32 99, i32 101, i32 58, i32 32, i32 34, i32 37, i32 108, i32 115, i32 34, i32 10, i32 0]
@.str.3 = [42 x i32] [i32 65, i32 110, i32 111, i32 116, i32 104, i32 101, i32 114, i32 63, i32 32, i32 40, i32 69, i32 78, i32 84, i32 69, i32 82, i32 32, i32 102, i32 111, i32 114, i32 32, i32 121, i32 101, i32 115, i32 44, i32 32, i32 67, i32 116, i32 114, i32 108, i32 45, i32 68, i32 32, i32 116, i32 111, i32 32, i32 115, i32 116, i32 111, i32 112, i32 41, i32 32, i32 0]
@stdin = global i32 0
@EXIT_SUCCESS = global i32 0
define void @gen_with_output() {
%1 = load i64, i64* @EOF
%2 = icmp eq i64 %1, 121
br i1 %2, label %19, label %3
3: ; preds = %0, %11
%4 = tail call i64* (...) @generate_sentence()
%5 = icmp eq i64* %4, null
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([33 x i32]* @.str.1 to i8*))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([17 x i32]* @.str.2 to i8*), i64* %4)
%13 = tail call i32 @free(i64* %4)
%14 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([42 x i32]* @.str.3 to i8*))
%15 = load i32, i32* @stdin
%16 = tail call i64 @fgetc(i32 %15)
%17 = load i64, i64* @EOF
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %3
19: ; preds = %11, %0
%20 = load i32, i32* @EXIT_SUCCESS
%21 = tail call i32 @exit(i32 %20)
unreachable
}