#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 */
char *dupstr(char const *);
int eval(char *, int);
char lowercase(char const);
int strlen(char const *);
int eval_dec(const char *s) {
  char *p;
  p = dupstr(s);
  if (lowercase(s[strlen(s) - 1]) == 'd') {
    p[strlen(p) - 1] = '\0';
  }
  return eval(p, 10);
}


x86 assembly (clang, -O0):
<eval_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <dupstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <lowercase@plt>
movsbl %al,%eax
cmp    $0x64,%eax
jne    11ac <eval_dec+0x6c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <eval@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_dec>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1060 <dupstr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%edi
call   1040 <lowercase@plt>
cmp    $0x64,%al
jne    1177 <eval_dec+0x37>
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r14,%rdi
mov    $0xa,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <eval@plt>

LLVM IR (-O0):
define i32 @eval_dec(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @dupstr(i8* %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = sub nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %6, i64 %10
%12 = load i8, i8* %11
%13 = call signext i8 @lowercase(i8 signext %12)
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %23
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %16, %1
%24 = load i8*, i8** %3
%25 = call i32 @eval(i8* %24, i32 10)
ret i32 %25
}

LLVM IR (-O2):
define i32 @eval_dec(i8* %0) {
%2 = tail call i8* @dupstr(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = tail call signext i8 @lowercase(i8 signext %7)
%9 = icmp eq i8 %8, 100
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = tail call i32 @strlen(i8* %2)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %2, i64 %13
store i8 0, i8* %14
br label %15
15: ; preds = %10, %1
%16 = tail call i32 @eval(i8* %2, i32 10)
ret i32 %16
}