#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 */
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ isdigit(char);
void WavpackNativeToLittleEndian(void *data, char *format) {
  unsigned char *cp = (unsigned char *)data;
  int32_t temp;
  while (*format) {
    switch (*format) {
    case 'L':
      temp = *(int32_t *)cp;
      *cp++ = (unsigned char)temp;
      *cp++ = (unsigned char)(temp >> 8);
      *cp++ = (unsigned char)(temp >> 16);
      *cp++ = (unsigned char)(temp >> 24);
      break;
    case 'S':
      temp = *(short *)cp;
      *cp++ = (unsigned char)temp;
      *cp++ = (unsigned char)(temp >> 8);
      break;
    default:
      if (isdigit(*format))
        cp += *format - '0';
      break;
    }
    format++;
  }
}


x86 assembly (clang, -O0):
<WavpackNativeToLittleEndian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     124e <WavpackNativeToLittleEndian+0x13e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
sub    $0x4c,%eax
je     115e <WavpackNativeToLittleEndian+0x4e>
jmp    114d <WavpackNativeToLittleEndian+0x3d>
mov    -0x20(%rbp),%eax
sub    $0x53,%eax
je     11cd <WavpackNativeToLittleEndian+0xbd>
jmp    120b <WavpackNativeToLittleEndian+0xfb>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
sar    $0x10,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
sar    $0x18,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    123d <WavpackNativeToLittleEndian+0x12d>
mov    -0x18(%rbp),%rax
movswl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    123d <WavpackNativeToLittleEndian+0x12d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1238 <WavpackNativeToLittleEndian+0x128>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x30,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    123d <WavpackNativeToLittleEndian+0x12d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1128 <WavpackNativeToLittleEndian+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WavpackNativeToLittleEndian>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%al
test   %al,%al
je     1177 <WavpackNativeToLittleEndian+0x67>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rbx
jmp    113f <WavpackNativeToLittleEndian+0x2f>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1177 <WavpackNativeToLittleEndian+0x67>
movsbl %al,%edi
cmp    $0x53,%edi
je     1130 <WavpackNativeToLittleEndian+0x20>
cmp    $0x4c,%edi
jne    1160 <WavpackNativeToLittleEndian+0x50>
add    $0x4,%r14
jmp    1134 <WavpackNativeToLittleEndian+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <isdigit@plt>
test   %eax,%eax
je     1134 <WavpackNativeToLittleEndian+0x24>
movsbq -0x1(%rbx),%rax
add    %rax,%r14
add    $0xffffffffffffffd0,%r14
jmp    1134 <WavpackNativeToLittleEndian+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @WavpackNativeToLittleEndian(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %67, %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %70
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %53 [
i32 76, label %16
i32 83, label %39
]
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = bitcast i8* %17 to i32*
%19 = load i32, i32* %18
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
store i8 %21, i8* %22
%24 = load i32, i32* %6
%25 = ashr i32 %24, 8
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
store i8 %26, i8* %27
%29 = load i32, i32* %6
%30 = ashr i32 %29, 16
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
store i8 %31, i8* %32
%34 = load i32, i32* %6
%35 = ashr i32 %34, 24
%36 = trunc i32 %35 to i8
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
store i8 %36, i8* %37
br label %67
39: ; preds = %12
%40 = load i8*, i8** %5
%41 = bitcast i8* %40 to i16*
%42 = load i16, i16* %41
%43 = sext i16 %42 to i32
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = trunc i32 %44 to i8
%46 = load i8*, i8** %5
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %5
store i8 %45, i8* %46
%48 = load i32, i32* %6
%49 = ashr i32 %48, 8
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %5
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %5
store i8 %50, i8* %51
br label %67
53: ; preds = %12
%54 = load i8*, i8** %4
%55 = load i8, i8* %54
%56 = call i32 @isdigit(i8 signext %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %66
58: ; preds = %53
%59 = load i8*, i8** %4
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = sub nsw i32 %61, 48
%63 = load i8*, i8** %5
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8* %65, i8** %5
br label %66
66: ; preds = %58, %53
br label %67
67: ; preds = %66, %39, %16
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %4
br label %8
70: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @WavpackNativeToLittleEndian(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %45, label %5
5: ; preds = %2, %40
%6 = phi i8 [ %43, %40 ], [ %3, %2 ]
%7 = phi i8* [ %41, %40 ], [ %0, %2 ]
%8 = phi i8* [ %42, %40 ], [ %1, %2 ]
%9 = sext i8 %6 to i32
switch i32 %9, label %32 [
i32 76, label %10
i32 83, label %24
]
10: ; preds = %5
%11 = bitcast i8* %7 to i32*
%12 = load i32, i32* %11
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %13, i8* %7
%15 = lshr i32 %12, 8
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds i8, i8* %7, i64 2
store i8 %16, i8* %14
%18 = lshr i32 %12, 16
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds i8, i8* %7, i64 3
store i8 %19, i8* %17
%21 = lshr i32 %12, 24
%22 = trunc i32 %21 to i8
%23 = getelementptr inbounds i8, i8* %7, i64 4
store i8 %22, i8* %20
br label %40
24: ; preds = %5
%25 = bitcast i8* %7 to i16*
%26 = load i16, i16* %25
%27 = trunc i16 %26 to i8
%28 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %27, i8* %7
%29 = lshr i16 %26, 8
%30 = trunc i16 %29 to i8
%31 = getelementptr inbounds i8, i8* %7, i64 2
store i8 %30, i8* %28
br label %40
32: ; preds = %5
%33 = tail call i32 @isdigit(i8 signext %6)
%34 = icmp eq i32 %33, 0
br i1 %34, label %40, label %35
35: ; preds = %32
%36 = load i8, i8* %8
%37 = sext i8 %36 to i64
%38 = add nsw i64 %37, -48
%39 = getelementptr inbounds i8, i8* %7, i64 %38
br label %40
40: ; preds = %32, %35, %24, %10
%41 = phi i8* [ %39, %35 ], [ %7, %32 ], [ %31, %24 ], [ %23, %10 ]
%42 = getelementptr inbounds i8, i8* %8, i64 1
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 0
br i1 %44, label %45, label %5
45: ; preds = %40, %2
ret void
}