#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__ isByteExponent(char);
scalar_t__ isByteNumber(char, int);
void muj_reparse_number(char *target, char *str) {
  for (int i = 0;; i++) {
    char byte = str[i];
    if (isByteNumber(byte, i == 0)) {
      if (isByteExponent(byte)) {
        *target = 'e';
        target++;
        *target = (byte == 'e' ? '-' : '+');
      } else {
        *target = byte;
      }
      target++;
    } else
      return;
  }
}


x86 assembly (clang, -O0):
<muj_reparse_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
cmpl   $0x0,-0x14(%rbp)
sete   %cl
and    $0x1,%cl
movzbl %cl,%esi
movsbl %al,%edi
call   1030 <isByteNumber@plt>
cmp    $0x0,%rax
je     11c8 <muj_reparse_number+0xa8>
movsbl -0x15(%rbp),%edi
call   1040 <isByteExponent@plt>
cmp    $0x0,%rax
je     11ae <muj_reparse_number+0x8e>
mov    -0x8(%rbp),%rax
movb   $0x65,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movsbl -0x15(%rbp),%edx
mov    $0x2b,%eax
mov    $0x2d,%ecx
cmp    $0x65,%edx
cmove  %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11b7 <muj_reparse_number+0x97>
mov    -0x15(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11ce <muj_reparse_number+0xae>
add    $0x20,%rsp
pop    %rbp
ret
jmp    11d3 <muj_reparse_number+0xb3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <muj_reparse_number+0x17>

x86 assembly (clang, -O2):
<muj_reparse_number>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rsi),%bpl
movsbl %bpl,%edi
mov    $0x1,%esi
call   1030 <isByteNumber@plt>
test   %rax,%rax
je     1194 <muj_reparse_number+0x74>
add    $0x1,%r14
jmp    116f <muj_reparse_number+0x4f>
cs nopw 0x0(%rax,%rax,1)
mov    %bpl,(%rbx)
add    $0x1,%rbx
movzbl (%r14),%ebp
movsbl %bpl,%edi
xor    %esi,%esi
call   1030 <isByteNumber@plt>
add    $0x1,%r14
test   %rax,%rax
je     1194 <muj_reparse_number+0x74>
movsbl %bpl,%edi
call   1040 <isByteExponent@plt>
test   %rax,%rax
je     1150 <muj_reparse_number+0x30>
movb   $0x65,(%rbx)
cmp    $0x65,%bpl
sete   %al
add    %al,%al
add    $0x2b,%al
mov    %al,0x1(%rbx)
add    $0x1,%rbx
jmp    1153 <muj_reparse_number+0x33>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @muj_reparse_number(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %7
7: ; preds = %42, %2
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
store i8 %12, i8* %6
%13 = load i8, i8* %6
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i64 @isByteNumber(i8 signext %13, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %40
19: ; preds = %7
%20 = load i8, i8* %6
%21 = call i64 @isByteExponent(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load i8*, i8** %3
store i8 101, i8* %24
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 101
%30 = zext i1 %29 to i64
%31 = select i1 %29, i32 45, i32 43
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %3
store i8 %32, i8* %33
br label %37
34: ; preds = %19
%35 = load i8, i8* %6
%36 = load i8*, i8** %3
store i8 %35, i8* %36
br label %37
37: ; preds = %34, %23
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
br label %41
40: ; preds = %7
ret void
41: ; preds = %37
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %7
}

LLVM IR (-O2):
define void @muj_reparse_number(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = tail call i64 @isByteNumber(i8 signext %3, i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %2, %17
%7 = phi i64 [ %20, %17 ], [ 0, %2 ]
%8 = phi i8 [ %22, %17 ], [ %3, %2 ]
%9 = phi i8* [ %19, %17 ], [ %0, %2 ]
%10 = tail call i64 @isByteExponent(i8 signext %8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %6
store i8 101, i8* %9
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = icmp eq i8 %8, 101
%15 = select i1 %14, i8 45, i8 43
store i8 %15, i8* %13
br label %17
16: ; preds = %6
store i8 %8, i8* %9
br label %17
17: ; preds = %16, %12
%18 = phi i8* [ %13, %12 ], [ %9, %16 ]
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = add nuw i64 %7, 1
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
%23 = tail call i64 @isByteNumber(i8 signext %22, i32 0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %6
25: ; preds = %17, %2
ret void
}