#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void s_stem(char *s) {
  int s_len = strlen(s);
  if (s_len >= 4) {
    if (strcmp(s + s_len - 3, "ies") == 0) {
      if (strcmp(s + s_len - 4, "eies") != 0) {
        strcpy(s + s_len - 3, "y");
      }
    }
  }
  if (s_len >= 3) {
    if (strcmp(s + s_len - 2, "es") == 0) {
      if (strcmp(s + s_len - 3, "aes") != 0) {
        strcpy(s + s_len - 2, "e");
      }
    }
  }
  if (s_len >= 2) {
    if (strcmp(s + s_len - 1, "s") == 0) {
      if ((strcmp(s + s_len - 2, "us") != 0) &&
          (strcmp(s + s_len - 2, "ss") != 0)) {
        strcpy(s + s_len - 1, "");
      }
    }
  }
}


x86 assembly (clang, -O0):
<s_stem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jl     11c1 <s_stem+0x91>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe99(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <s_stem+0x8c>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe73(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11b7 <s_stem+0x87>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe53(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11bc <s_stem+0x8c>
jmp    11c1 <s_stem+0x91>
cmpl   $0x3,-0xc(%rbp)
jl     123a <s_stem+0x10a>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xe27(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1235 <s_stem+0x105>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe01(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1230 <s_stem+0x100>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xde0(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1235 <s_stem+0x105>
jmp    123a <s_stem+0x10a>
cmpl   $0x2,-0xc(%rbp)
jl     12d8 <s_stem+0x1a8>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
lea    0xdaf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12d3 <s_stem+0x1a3>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xd8e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12ce <s_stem+0x19e>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xd6c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     12ce <s_stem+0x19e>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
lea    0xd43(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12d3 <s_stem+0x1a3>
jmp    12d8 <s_stem+0x1a8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s_stem>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x4,%eax
jl     118b <s_stem+0x5b>
mov    %eax,%r15d
lea    (%rbx,%r15,1),%r14
add    $0xfffffffffffffffd,%r14
lea    0xead(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1196 <s_stem+0x66>
lea    (%rbx,%r15,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe90(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1196 <s_stem+0x66>
lea    0xe84(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
jmp    1196 <s_stem+0x66>
mov    $0x3,%r15d
cmp    $0x3,%eax
jne    11dc <s_stem+0xac>
lea    (%rbx,%r15,1),%r14
add    $0xfffffffffffffffe,%r14
lea    0xe63(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11e7 <s_stem+0xb7>
lea    (%rbx,%r15,1),%rdi
add    $0xfffffffffffffffd,%rdi
lea    0xe46(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e7 <s_stem+0xb7>
lea    0xe39(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
jmp    11e7 <s_stem+0xb7>
mov    $0x2,%r15d
cmp    $0x2,%eax
jl     1203 <s_stem+0xd3>
lea    (%rbx,%r15,1),%r14
add    $0xffffffffffffffff,%r14
lea    0xe13(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1209 <s_stem+0xd9>
pop    %rbx
pop    %r14
pop    %r15
ret
add    %r15,%rbx
add    $0xfffffffffffffffe,%rbx
lea    0xdf6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1203 <s_stem+0xd3>
lea    0xde5(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1203 <s_stem+0xd3>
lea    0xdcd(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"ies\00"
@.str.1 = [5 x i8] c"eies\00"
@.str.2 = [2 x i8] c"y\00"
@.str.3 = [3 x i8] c"es\00"
@.str.4 = [4 x i8] c"aes\00"
@.str.5 = [2 x i8] c"e\00"
@.str.6 = [2 x i8] c"s\00"
@.str.7 = [3 x i8] c"us\00"
@.str.8 = [3 x i8] c"ss\00"
@.str.9 = [1 x i8] zeroinitializer
define void @s_stem(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 4
br i1 %7, label %8, label %33
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -3
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %8
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 -4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %16
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 -3
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %24, %16
br label %32
32: ; preds = %31, %8
br label %33
33: ; preds = %32, %1
%34 = load i32, i32* %3
%35 = icmp sge i32 %34, 3
br i1 %35, label %36, label %61
36: ; preds = %33
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 -2
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %60
44: ; preds = %36
%45 = load i8*, i8** %2
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = getelementptr inbounds i8, i8* %48, i64 -3
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %59
52: ; preds = %44
%53 = load i8*, i8** %2
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = getelementptr inbounds i8, i8* %56, i64 -2
%58 = call i32 @strcpy(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %52, %44
br label %60
60: ; preds = %59, %36
br label %61
61: ; preds = %60, %33
%62 = load i32, i32* %3
%63 = icmp sge i32 %62, 2
br i1 %63, label %64, label %97
64: ; preds = %61
%65 = load i8*, i8** %2
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %65, i64 %67
%69 = getelementptr inbounds i8, i8* %68, i64 -1
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %96
72: ; preds = %64
%73 = load i8*, i8** %2
%74 = load i32, i32* %3
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = getelementptr inbounds i8, i8* %76, i64 -2
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %95
80: ; preds = %72
%81 = load i8*, i8** %2
%82 = load i32, i32* %3
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = getelementptr inbounds i8, i8* %84, i64 -2
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %95
88: ; preds = %80
%89 = load i8*, i8** %2
%90 = load i32, i32* %3
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %89, i64 %91
%93 = getelementptr inbounds i8, i8* %92, i64 -1
%94 = call i32 @strcpy(i8* %93, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
br label %95
95: ; preds = %88, %80, %72
br label %96
96: ; preds = %95, %64
br label %97
97: ; preds = %96, %61
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"ies\00"
@.str.1 = [5 x i8] c"eies\00"
@.str.2 = [2 x i8] c"y\00"
@.str.3 = [3 x i8] c"es\00"
@.str.4 = [4 x i8] c"aes\00"
@.str.5 = [2 x i8] c"e\00"
@.str.6 = [2 x i8] c"s\00"
@.str.7 = [3 x i8] c"us\00"
@.str.8 = [3 x i8] c"ss\00"
@.str.9 = [1 x i8] zeroinitializer
define void @s_stem(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 3
br i1 %3, label %4, label %16
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -3
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %6, i64 -4
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %1
%17 = icmp eq i32 %2, 3
br i1 %17, label %18, label %30
18: ; preds = %16, %10, %14, %4
%19 = phi i64 [ %5, %10 ], [ %5, %14 ], [ %5, %4 ], [ 3, %16 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 -2
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = getelementptr inbounds i8, i8* %20, i64 -3
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = tail call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %32
30: ; preds = %16
%31 = icmp sgt i32 %2, 1
br i1 %31, label %32, label %47
32: ; preds = %30, %24, %28, %18
%33 = phi i64 [ %19, %24 ], [ %19, %28 ], [ %19, %18 ], [ 2, %30 ]
%34 = getelementptr inbounds i8, i8* %0, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 -1
%36 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %32
%39 = getelementptr inbounds i8, i8* %34, i64 -2
%40 = tail call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %38
%43 = tail call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0))
br label %47
47: ; preds = %32, %45, %42, %38, %30
ret void
}