#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 *);
int /*<<< orphan*/ isdigit(char);
char *strdup(char const *);
char *strtok(char *, char *);
int iioutils_break_up_name(const char *full_name, char **generic_name) {
  char *current;
  char *w, *r;
  char *working;
  current = strdup(full_name);
  working = strtok(current, "_\0");
  w = working;
  r = working;
  while (*r != '\0') {
    if (!isdigit(*r)) {
      *w = *r;
      w++;
    }
    r++;
  }
  *w = '\0';
  *generic_name = strdup(working);
  free(current);
  return 0;
}


x86 assembly (clang, -O0):
<iioutils_break_up_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cf <iioutils_break_up_name+0x8f>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    11be <iioutils_break_up_name+0x7e>
mov    -0x28(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1181 <iioutils_break_up_name+0x41>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iioutils_break_up_name>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
call   1060 <strdup@plt>
mov    %rax,%r15
lea    0xea5(%rip),%rsi
mov    %rax,%rdi
call   1050 <strtok@plt>
mov    %rax,%r12
mov    (%rax),%al
mov    %r12,%r13
test   %al,%al
je     11a5 <iioutils_break_up_name+0x65>
mov    %r12,%rbx
add    $0x1,%rbx
mov    %r12,%r13
jmp    118b <iioutils_break_up_name+0x4b>
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11a5 <iioutils_break_up_name+0x65>
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %eax,%eax
jne    1180 <iioutils_break_up_name+0x40>
movzbl -0x1(%rbx),%eax
mov    %al,0x0(%r13)
add    $0x1,%r13
jmp    1180 <iioutils_break_up_name+0x40>
movb   $0x0,0x0(%r13)
mov    %r12,%rdi
call   1060 <strdup@plt>
mov    %rax,(%r14)
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"_\00\00"
define i32 @iioutils_break_up_name(i8* nocapture %0, i8** nocapture writeonly %1) {
%3 = tail call i8* @strdup(i8* %0)
%4 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %2, %16
%8 = phi i8 [ %19, %16 ], [ %5, %2 ]
%9 = phi i8* [ %17, %16 ], [ %4, %2 ]
%10 = phi i8* [ %18, %16 ], [ %4, %2 ]
%11 = tail call i32 @isdigit(i8 signext %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i8, i8* %10
store i8 %14, i8* %9
%15 = getelementptr inbounds i8, i8* %9, i64 1
br label %16
16: ; preds = %13, %7
%17 = phi i8* [ %9, %7 ], [ %15, %13 ]
%18 = getelementptr inbounds i8, i8* %10, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %16, %2
%22 = phi i8* [ %4, %2 ], [ %17, %16 ]
store i8 0, i8* %22
%23 = tail call i8* @strdup(i8* %4)
store i8* %23, i8** %1
%24 = tail call i32 @free(i8* %3)
ret i32 0
}