#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 */
struct sb_stemmer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sb_stemmer_delete(struct sb_stemmer *);
scalar_t__ sb_stemmer_length(struct sb_stemmer *);
char **sb_stemmer_list();
struct sb_stemmer *sb_stemmer_new(char *);
char *sb_stemmer_stem(struct sb_stemmer *, char const *, int);
scalar_t__ strlen(char const *);
int main() {
  const char *stemmed;
  const char *unstemmed;
  struct sb_stemmer *s;
  const char **list = sb_stemmer_list();
  if (*list == 0)
    error("TEST FAIL: empty list of stemmers");
  s = sb_stemmer_new("e");
  if (s != 0)
    error("TEST FAIL: non zero return for unrecognised language");
  s = sb_stemmer_new("english");
  if (s == 0)
    error("TEST FAIL: zero return for recognised language");
  sb_stemmer_delete(s);
  s = sb_stemmer_new("en");
  if (s == 0)
    error("TEST FAIL: zero return for recognised language");
  unstemmed = "recognised";
  stemmed = sb_stemmer_stem(s, unstemmed, 10);
  printf("%s -> %s\n", unstemmed, stemmed);
  if (sb_stemmer_length(s) != strlen(stemmed))
    error("TEST FAIL: length not correct");
  unstemmed = "recognized";
  printf("%s -> %s\n", unstemmed, stemmed);
  sb_stemmer_delete(s);
  printf("Success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <sb_stemmer_list@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11b4 <main+0x34>
lea    0xe51(%rip),%rdi
call   1070 <error@plt>
lea    0xed1(%rip),%rdi
call   1080 <sb_stemmer_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11db <main+0x5b>
lea    0xe4c(%rip),%rdi
call   1070 <error@plt>
lea    0xe75(%rip),%rdi
call   1080 <sb_stemmer_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1202 <main+0x82>
lea    0xe62(%rip),%rdi
call   1070 <error@plt>
mov    -0x20(%rbp),%rdi
call   1090 <sb_stemmer_delete@plt>
lea    0xe7c(%rip),%rdi
call   1080 <sb_stemmer_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1232 <main+0xb2>
lea    0xe32(%rip),%rdi
call   1070 <error@plt>
lea    0xe58(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1030 <sb_stemmer_stem@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <sb_stemmer_length@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     129b <main+0x11b>
lea    0xe10(%rip),%rdi
call   1070 <error@plt>
lea    0xe22(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1090 <sb_stemmer_delete@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <sb_stemmer_list@plt>
cmpq   $0x0,(%rax)
jne    11b1 <main+0x21>
lea    0xe54(%rip),%rdi
call   1080 <error@plt>
lea    0xed4(%rip),%rdi
call   1090 <sb_stemmer_new@plt>
test   %rax,%rax
je     11ce <main+0x3e>
lea    0xe59(%rip),%rdi
call   1080 <error@plt>
lea    0xe82(%rip),%rdi
call   1090 <sb_stemmer_new@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11ee <main+0x5e>
lea    0xe76(%rip),%rdi
call   1080 <error@plt>
mov    %rbx,%rdi
call   10a0 <sb_stemmer_delete@plt>
lea    0xe91(%rip),%rdi
call   1090 <sb_stemmer_new@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1216 <main+0x86>
lea    0xe4e(%rip),%rdi
call   1080 <error@plt>
lea    0xe74(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1030 <sb_stemmer_stem@plt>
mov    %rax,%r12
lea    0xe65(%rip),%rdi
mov    %r15,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   10b0 <sb_stemmer_length@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    %rax,%rbx
je     1268 <main+0xd8>
lea    0xe43(%rip),%rdi
call   1080 <error@plt>
lea    0xe2d(%rip),%rdi
lea    0xe4e(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   10a0 <sb_stemmer_delete@plt>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sb_stemmer = type { i32 }
@.str = [34 x i8] c"TEST FAIL: empty list of stemmers\00"
@.str.1 = [2 x i8] c"e\00"
@.str.2 = [53 x i8] c"TEST FAIL: non zero return for unrecognised language\00"
@.str.3 = [8 x i8] c"english\00"
@.str.4 = [47 x i8] c"TEST FAIL: zero return for recognised language\00"
@.str.5 = [3 x i8] c"en\00"
@.str.6 = [11 x i8] c"recognised\00"
@.str.7 = [10 x i8] c"%s -> %s\0A\00"
@.str.8 = [30 x i8] c"TEST FAIL: length not correct\00"
@.str.9 = [11 x i8] c"recognized\00"
@.str.10 = [9 x i8] c"Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.sb_stemmer*
%5 = alloca i8**
store i32 0, i32* %1
%6 = call i8** (...) @sb_stemmer_list()
store i8** %6, i8*** %5
%7 = load i8**, i8*** %5
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = call %struct.sb_stemmer* @sb_stemmer_new(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store %struct.sb_stemmer* %13, %struct.sb_stemmer** %4
%14 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%15 = icmp ne %struct.sb_stemmer* %14, null
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @error(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = call %struct.sb_stemmer* @sb_stemmer_new(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store %struct.sb_stemmer* %19, %struct.sb_stemmer** %4
%20 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%21 = icmp eq %struct.sb_stemmer* %20, null
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%26 = call i32 @sb_stemmer_delete(%struct.sb_stemmer* %25)
%27 = call %struct.sb_stemmer* @sb_stemmer_new(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store %struct.sb_stemmer* %27, %struct.sb_stemmer** %4
%28 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%29 = icmp eq %struct.sb_stemmer* %28, null
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8** %3
%33 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%34 = load i8*, i8** %3
%35 = call i8* @sb_stemmer_stem(%struct.sb_stemmer* %33, i8* %34, i32 10)
store i8* %35, i8** %2
%36 = load i8*, i8** %3
%37 = load i8*, i8** %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %36, i8* %37)
%39 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%40 = call i64 @sb_stemmer_length(%struct.sb_stemmer* %39)
%41 = load i8*, i8** %2
%42 = call i64 @strlen(i8* %41)
%43 = icmp ne i64 %40, %42
br i1 %43, label %44, label %46
44: ; preds = %32
%45 = call i32 @error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %44, %32
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %3
%47 = load i8*, i8** %3
%48 = load i8*, i8** %2
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %47, i8* %48)
%50 = load %struct.sb_stemmer*, %struct.sb_stemmer** %4
%51 = call i32 @sb_stemmer_delete(%struct.sb_stemmer* %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.sb_stemmer = type { i32 }
@.str = [34 x i8] c"TEST FAIL: empty list of stemmers\00"
@.str.1 = [2 x i8] c"e\00"
@.str.2 = [53 x i8] c"TEST FAIL: non zero return for unrecognised language\00"
@.str.3 = [8 x i8] c"english\00"
@.str.4 = [47 x i8] c"TEST FAIL: zero return for recognised language\00"
@.str.5 = [3 x i8] c"en\00"
@.str.6 = [11 x i8] c"recognised\00"
@.str.7 = [10 x i8] c"%s -> %s\0A\00"
@.str.8 = [30 x i8] c"TEST FAIL: length not correct\00"
@.str.9 = [11 x i8] c"recognized\00"
@str = [8 x i8] c"Success\00"
define i32 @main() {
%1 = tail call i8** (...) @sb_stemmer_list()
%2 = load i8*, i8** %1
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @error(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = tail call %struct.sb_stemmer* @sb_stemmer_new(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq %struct.sb_stemmer* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @error(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = tail call %struct.sb_stemmer* @sb_stemmer_new(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq %struct.sb_stemmer* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = tail call i32 @sb_stemmer_delete(%struct.sb_stemmer* %12)
%18 = tail call %struct.sb_stemmer* @sb_stemmer_new(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq %struct.sb_stemmer* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @error(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = tail call i8* @sb_stemmer_stem(%struct.sb_stemmer* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 10)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %23)
%25 = tail call i64 @sb_stemmer_length(%struct.sb_stemmer* %18)
%26 = tail call i64 @strlen(i8* dereferenceable(1) %23)
%27 = icmp eq i64 %25, %26
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = tail call i32 @error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%32 = tail call i32 @sb_stemmer_delete(%struct.sb_stemmer* %18)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret i32 0
}