#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__ isdigit(int);
void stress_iostat_dev_trim(char *devname) {
  char *ptr;
  for (ptr = devname; *ptr; ptr++)
    ;
  for (--ptr; (ptr > devname) && isdigit((int)*ptr); ptr--)
    *ptr = '\0';
}


x86 assembly (clang, -O0):
<stress_iostat_dev_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1147 <stress_iostat_dev_trim+0x37>
jmp    1136 <stress_iostat_dev_trim+0x26>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <stress_iostat_dev_trim+0x14>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x11(%rbp)
jbe    117c <stress_iostat_dev_trim+0x6c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    118c <stress_iostat_dev_trim+0x7c>
jmp    11a4 <stress_iostat_dev_trim+0x94>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1153 <stress_iostat_dev_trim+0x43>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_iostat_dev_trim>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    -0x2(%rdi),%rbx
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x2(%rbx)
lea    0x1(%rbx),%rbx
jne    1120 <stress_iostat_dev_trim+0x10>
jmp    1137 <stress_iostat_dev_trim+0x27>
nopl   0x0(%rax)
movb   $0x0,(%rbx)
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jbe    1149 <stress_iostat_dev_trim+0x39>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1130 <stress_iostat_dev_trim+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @stress_iostat_dev_trim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %10, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %5
br label %10
10: ; preds = %9
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %3
br label %5
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 -1
store i8* %15, i8** %3
br label %16
16: ; preds = %30, %13
%17 = load i8*, i8** %3
%18 = load i8*, i8** %2
%19 = icmp ugt i8* %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i64 @isdigit(i32 %23)
%25 = icmp ne i64 %24, 0
br label %26
26: ; preds = %20, %16
%27 = phi i1 [ false, %16 ], [ %25, %20 ]
br i1 %27, label %28, label %33
28: ; preds = %26
%29 = load i8*, i8** %3
store i8 0, i8* %29
br label %30
30: ; preds = %28
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %3
br label %16
33: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @stress_iostat_dev_trim(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %5, label %7, label %2
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 -1
%9 = icmp ugt i8* %8, %0
br i1 %9, label %10, label %19
10: ; preds = %7, %16
%11 = phi i8* [ %17, %16 ], [ %8, %7 ]
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = tail call i64 @isdigit(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
store i8 0, i8* %11
%17 = getelementptr inbounds i8, i8* %11, i64 -1
%18 = icmp ugt i8* %17, %0
br i1 %18, label %10, label %19
19: ; preds = %10, %16, %7
ret void
}