#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*/ free(char const *);
char *m_stem(char const *);
scalar_t__ strcmp(char const *, char *);
char *m_full_stem(const char *input) {
  char *stemmed;
  stemmed = m_stem(input);
  if (strcmp(input, stemmed)) {
    input = stemmed;
    stemmed = m_stem(input);
    while (strcmp(input, stemmed)) {
      free(input);
      input = stemmed;
      stemmed = m_stem(input);
    }
    free(input);
  }
  return stemmed;
}


x86 assembly (clang, -O0):
<m_full_stem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <m_stem@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11b8 <m_full_stem+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <m_stem@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11af <m_full_stem+0x7f>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <m_stem@plt>
mov    %rax,-0x10(%rbp)
jmp    1175 <m_full_stem+0x45>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_full_stem>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <m_stem@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a9 <m_full_stem+0x79>
mov    %r14,%rdi
call   1050 <m_stem@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     119b <m_full_stem+0x6b>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <m_stem@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
mov    %rbx,%r14
test   %rax,%rax
jne    1170 <m_full_stem+0x40>
jmp    119e <m_full_stem+0x6e>
mov    %r14,%rbx
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @m_full_stem(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @m_stem(i8* %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %2
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %6, i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %1
%11 = load i8*, i8** %3
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i8* @m_stem(i8* %12)
store i8* %13, i8** %3
br label %14
14: ; preds = %19, %10
%15 = load i8*, i8** %2
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
%22 = load i8*, i8** %3
store i8* %22, i8** %2
%23 = load i8*, i8** %2
%24 = call i8* @m_stem(i8* %23)
store i8* %24, i8** %3
br label %14
25: ; preds = %14
%26 = load i8*, i8** %2
%27 = call i32 @free(i8* %26)
br label %28
28: ; preds = %25, %1
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
define i8* @m_full_stem(i8* %0) {
%2 = tail call i8* @m_stem(i8* %0)
%3 = tail call i64 @strcmp(i8* %0, i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %1
%6 = tail call i8* @m_stem(i8* %2)
%7 = tail call i64 @strcmp(i8* %2, i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %5, %9
%10 = phi i8* [ %13, %9 ], [ %6, %5 ]
%11 = phi i8* [ %10, %9 ], [ %2, %5 ]
%12 = tail call i32 @free(i8* %11)
%13 = tail call i8* @m_stem(i8* %10)
%14 = tail call i64 @strcmp(i8* %10, i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %5
%17 = phi i8* [ %2, %5 ], [ %10, %9 ]
%18 = phi i8* [ %6, %5 ], [ %13, %9 ]
%19 = tail call i32 @free(i8* %17)
br label %20
20: ; preds = %16, %1
%21 = phi i8* [ %18, %16 ], [ %2, %1 ]
ret i8* %21
}