#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*/ close_stemmer();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ full_morpha_stem(char *, char **);
int /*<<< orphan*/ init_stemmer();
int /*<<< orphan*/ morpha_stem(char *, char **);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int main(void) {
  init_stemmer();
  char *stemmed;
  char *test;
  test = strdup("there are numbers");
  morpha_stem(test, &stemmed);
  free(test);
  if (strcmp(stemmed, "there be number")) {
    fprintf(stderr, "test normalizer -- wrong result: %s\n", stemmed);
    free(stemmed);
    return 1;
  }
  free(stemmed);
  test = strdup("Let x be the greatest common denominator of y we are going to "
                "prove the following");
  morpha_stem(test, &stemmed);
  free(test);
  if (strcmp(stemmed, "let x be the greatest common denominator of y we be go "
                      "to prove the follow")) {
    fprintf(stderr, "test normalizer -- wrong result: %s\n", stemmed);
    free(stemmed);
    return 1;
  }
  free(stemmed);
  test = strdup("tilings");
  full_morpha_stem(test, &stemmed);
  free(test);
  if (strcmp(stemmed, "tile")) {
    fprintf(stderr, "test normalizer -- wrong result: %s\n", stemmed);
    free(stemmed);
    return 1;
  }
  free(stemmed);
  close_stemmer();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <init_stemmer@plt>
lea    0xe63(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <morpha_stem@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1204 <main+0x84>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe38(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1309 <main+0x189>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe33(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <morpha_stem@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     127b <main+0xfb>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdc1(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1309 <main+0x189>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe59(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <full_morpha_stem@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     12f2 <main+0x172>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd4a(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1309 <main+0x189>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <close_stemmer@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <init_stemmer@plt>
lea    0xe6d(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1060 <morpha_stem@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
lea    0xe56(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1252 <main+0xd2>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
lea    0xe6c(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1060 <morpha_stem@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
lea    0xe95(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1252 <main+0xd2>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
lea    0xec5(%rip),%rdi
call   10a0 <strdup@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1050 <full_morpha_stem@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
lea    0xea4(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1283 <main+0x103>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rdx
lea    0xdbb(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <close_stemmer@plt>
jmp    127b <main+0xfb>

LLVM IR (-O0):
@.str = [18 x i8] c"there are numbers\00"
@.str.1 = [16 x i8] c"there be number\00"
@stderr = global i32 0
@.str.2 = [37 x i8] c"test normalizer -- wrong result: %s\0A\00"
@.str.3 = [82 x i8] c"Let x be the greatest common denominator of y we are going to prove the following\00"
@.str.4 = [75 x i8] c"let x be the greatest common denominator of y we be go to prove the follow\00"
@.str.5 = [8 x i8] c"tilings\00"
@.str.6 = [5 x i8] c"tile\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 (...) @init_stemmer()
%5 = call i8* @strdup(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @morpha_stem(i8* %6, i8** %2)
%8 = load i8*, i8** %3
%9 = call i32 @free(i8* %8)
%10 = load i8*, i8** %2
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %2
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %2
%18 = call i32 @free(i8* %17)
store i32 1, i32* %1
br label %57
19: ; preds = %0
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
%22 = call i8* @strdup(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.3, i64 0, i64 0))
store i8* %22, i8** %3
%23 = load i8*, i8** %3
%24 = call i32 @morpha_stem(i8* %23, i8** %2)
%25 = load i8*, i8** %3
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %2
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %2
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %2
%35 = call i32 @free(i8* %34)
store i32 1, i32* %1
br label %57
36: ; preds = %19
%37 = load i8*, i8** %2
%38 = call i32 @free(i8* %37)
%39 = call i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i8* %39, i8** %3
%40 = load i8*, i8** %3
%41 = call i32 @full_morpha_stem(i8* %40, i8** %2)
%42 = load i8*, i8** %3
%43 = call i32 @free(i8* %42)
%44 = load i8*, i8** %2
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %36
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %2
%50 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %49)
%51 = load i8*, i8** %2
%52 = call i32 @free(i8* %51)
store i32 1, i32* %1
br label %57
53: ; preds = %36
%54 = load i8*, i8** %2
%55 = call i32 @free(i8* %54)
%56 = call i32 (...) @close_stemmer()
store i32 0, i32* %1
br label %57
57: ; preds = %53, %47, %30, %13
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [18 x i8] c"there are numbers\00"
@.str.1 = [16 x i8] c"there be number\00"
@stderr = global i32 0
@.str.2 = [37 x i8] c"test normalizer -- wrong result: %s\0A\00"
@.str.3 = [82 x i8] c"Let x be the greatest common denominator of y we are going to prove the following\00"
@.str.4 = [75 x i8] c"let x be the greatest common denominator of y we be go to prove the follow\00"
@.str.5 = [8 x i8] c"tilings\00"
@.str.6 = [5 x i8] c"tile\00"
define i32 @main() {
%1 = alloca i8*
%2 = tail call i32 (...) @init_stemmer()
%3 = bitcast i8** %1 to i8*
%4 = tail call dereferenceable_or_null(18) i8* @strdup(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @morpha_stem(i8* %4, i8** %1)
%6 = call i32 @free(i8* %4)
%7 = load i8*, i8** %1
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %1
%15 = call i32 @free(i8* %14)
br label %50
16: ; preds = %0
%17 = load i8*, i8** %1
%18 = call i32 @free(i8* %17)
%19 = call dereferenceable_or_null(82) i8* @strdup(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @morpha_stem(i8* %19, i8** %1)
%21 = call i32 @free(i8* %19)
%22 = load i8*, i8** %1
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %16
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %1
%30 = call i32 @free(i8* %29)
br label %50
31: ; preds = %16
%32 = load i8*, i8** %1
%33 = call i32 @free(i8* %32)
%34 = call dereferenceable_or_null(8) i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @full_morpha_stem(i8* %34, i8** %1)
%36 = call i32 @free(i8* %34)
%37 = load i8*, i8** %1
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %46, label %40
40: ; preds = %31
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %1
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %1
%45 = call i32 @free(i8* %44)
br label %50
46: ; preds = %31
%47 = load i8*, i8** %1
%48 = call i32 @free(i8* %47)
%49 = call i32 (...) @close_stemmer()
br label %50
50: ; preds = %46, %40, %25, %10
%51 = phi i32 [ 1, %10 ], [ 1, %25 ], [ 1, %40 ], [ 0, %46 ]
ret i32 %51
}