#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*/ *strchr(char *, char);
int strlen(char *);
char *eman_azken_zifra(char zenb[]) {
  int l = strlen(zenb) - 1;
  while (strchr("0123456789", zenb[l]) == NULL) {
    l--;
  }
  while ((l >= 0) && (strchr("0123456789", zenb[l]) != NULL)) {
    l--;
  }
  return (&zenb[l + 1]);
}


x86 assembly (clang, -O0):
<eman_azken_zifra>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xeb6(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    116b <eman_azken_zifra+0x4b>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    113b <eman_azken_zifra+0x1b>
jmp    1170 <eman_azken_zifra+0x50>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     11a1 <eman_azken_zifra+0x81>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe72(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11b1 <eman_azken_zifra+0x91>
jmp    11bf <eman_azken_zifra+0x9f>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1170 <eman_azken_zifra+0x50>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eman_azken_zifra>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
movslq %eax,%rbx
lea    0xec6(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsbl -0x1(%r15,%rbx,1),%esi
add    $0xffffffffffffffff,%rbx
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     1140 <eman_azken_zifra+0x20>
lea    0x1(%rbx),%eax
test   %eax,%eax
jle    11a4 <eman_azken_zifra+0x84>
mov    %ebx,%r12d
xor    %eax,%eax
test   %ebx,%ebx
cmovs  %ebx,%eax
mov    %eax,%ebx
add    $0xffffffff,%ebx
lea    0xe8c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r15,%r12,1),%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a1 <eman_azken_zifra+0x81>
add    $0xffffffffffffffff,%r12
lea    0x1(%r12),%eax
test   %eax,%eax
jg     1180 <eman_azken_zifra+0x60>
jmp    11a4 <eman_azken_zifra+0x84>
mov    %r12d,%ebx
movslq %ebx,%rax
add    %r15,%rax
add    $0x1,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0123456789\00"
define i8* @eman_azken_zifra(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = sub nsw i32 %5, 1
store i32 %6, i32* %3
br label %7
7: ; preds = %15, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = call i32* @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = load i32, i32* %3
%17 = add nsw i32 %16, -1
store i32 %17, i32* %3
br label %7
18: ; preds = %7
br label %19
19: ; preds = %32, %18
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32* @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %27)
%29 = icmp ne i32* %28, null
br label %30
30: ; preds = %22, %19
%31 = phi i1 [ false, %19 ], [ %29, %22 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %19
35: ; preds = %30
%36 = load i8*, i8** %2
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
ret i8* %40
}

LLVM IR (-O2):
@.str = [11 x i8] c"0123456789\00"
define i8* @eman_azken_zifra(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ %6, %4 ], [ %3, %1 ]
%6 = add i64 %5, -1
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i32* @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %4, label %11
11: ; preds = %4
%12 = trunc i64 %5 to i32
%13 = trunc i64 %6 to i32
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = and i64 %6, 4294967295
%17 = call i32 @llvm.smin.i32(i32 %13, i32 0)
%18 = add i32 %17, -1
br label %19
19: ; preds = %15, %26
%20 = phi i64 [ %16, %15 ], [ %27, %26 ]
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = load i8, i8* %21
%23 = tail call i32* @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %22)
%24 = icmp eq i32* %23, null
%25 = trunc i64 %20 to i32
br i1 %24, label %29, label %26
26: ; preds = %19
%27 = add nsw i64 %20, -1
%28 = icmp sgt i32 %25, 0
br i1 %28, label %19, label %31
29: ; preds = %19
%30 = trunc i64 %20 to i32
br label %31
31: ; preds = %29, %26, %11
%32 = phi i32 [ %13, %11 ], [ %30, %29 ], [ %18, %26 ]
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %0, i64 %34
ret i8* %35
}