#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 /*<<< orphan*/ temp64;
typedef int /*<<< orphan*/ temp32;
typedef int /*<<< orphan*/ temp16;
typedef int int64_t;
typedef int int32_t;
typedef int int16_t;

/* Variables and functions */
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ memcpy(int *, unsigned char *, int);
void WavpackNativeToLittleEndian(void *data, char *format) {
  unsigned char *cp = (unsigned char *)data;
  int64_t temp64;
  int32_t temp32;
  int16_t temp16;
  while (*format) {
    switch (*format) {
    case 'D':
      memcpy(&temp64, cp, sizeof(temp64));
      *cp++ = (unsigned char)temp64;
      *cp++ = (unsigned char)(temp64 >> 8);
      *cp++ = (unsigned char)(temp64 >> 16);
      *cp++ = (unsigned char)(temp64 >> 24);
      *cp++ = (unsigned char)(temp64 >> 32);
      *cp++ = (unsigned char)(temp64 >> 40);
      *cp++ = (unsigned char)(temp64 >> 48);
      *cp++ = (unsigned char)(temp64 >> 56);
      break;
    case 'L':
      memcpy(&temp32, cp, sizeof(temp32));
      *cp++ = (unsigned char)temp32;
      *cp++ = (unsigned char)(temp32 >> 8);
      *cp++ = (unsigned char)(temp32 >> 16);
      *cp++ = (unsigned char)(temp32 >> 24);
      break;
    case 'S':
      memcpy(&temp16, cp, sizeof(temp16));
      *cp++ = (unsigned char)temp16;
      *cp++ = (unsigned char)(temp16 >> 8);
      break;
    default:
      if (isdigit(*format))
        cp += *format - '0';
      break;
    }
    format++;
  }
}


x86 assembly (clang, -O0):
<WavpackNativeToLittleEndian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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     136c <WavpackNativeToLittleEndian+0x24c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x28(%rbp)
sub    $0x44,%eax
je     117f <WavpackNativeToLittleEndian+0x5f>
jmp    115d <WavpackNativeToLittleEndian+0x3d>
mov    -0x28(%rbp),%eax
sub    $0x4c,%eax
je     126b <WavpackNativeToLittleEndian+0x14b>
jmp    116e <WavpackNativeToLittleEndian+0x4e>
mov    -0x28(%rbp),%eax
sub    $0x53,%eax
je     12e3 <WavpackNativeToLittleEndian+0x1c3>
jmp    1329 <WavpackNativeToLittleEndian+0x209>
mov    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
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)
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%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
mov    $0x28,%ecx
sar    %cl,%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
mov    $0x30,%ecx
sar    %cl,%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
mov    $0x38,%ecx
sar    %cl,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    135b <WavpackNativeToLittleEndian+0x23b>
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%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    -0x20(%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    -0x20(%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    135b <WavpackNativeToLittleEndian+0x23b>
mov    -0x18(%rbp),%rsi
lea    -0x24(%rbp),%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x24(%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    135b <WavpackNativeToLittleEndian+0x23b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     1356 <WavpackNativeToLittleEndian+0x236>
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    135b <WavpackNativeToLittleEndian+0x23b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <WavpackNativeToLittleEndian+0x18>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WavpackNativeToLittleEndian>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    (%rsi),%al
test   %al,%al
je     124e <WavpackNativeToLittleEndian+0x12e>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rbx
lea    0xc(%rsp),%r15
lea    0x4(%rsp),%r12
lea    0x8(%rsp),%r13
jmp    11a6 <WavpackNativeToLittleEndian+0x86>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
movzbl 0x4(%rsp),%eax
mov    %al,(%r14)
movzbl 0x5(%rsp),%eax
mov    %al,0x1(%r14)
movzbl 0x6(%rsp),%eax
mov    %al,0x2(%r14)
movzbl 0x7(%rsp),%eax
mov    %al,0x3(%r14)
add    $0x4,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     124e <WavpackNativeToLittleEndian+0x12e>
movsbl %al,%edi
cmp    $0x53,%edi
je     1200 <WavpackNativeToLittleEndian+0xe0>
cmp    $0x4c,%edi
je     1160 <WavpackNativeToLittleEndian+0x40>
cmp    $0x44,%edi
jne    1230 <WavpackNativeToLittleEndian+0x110>
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
movzbl 0x8(%rsp),%eax
mov    %al,(%r14)
movzbl 0x9(%rsp),%eax
mov    %al,0x1(%r14)
movzbl 0xa(%rsp),%eax
mov    %al,0x2(%r14)
movzbl 0xb(%rsp),%eax
mov    %al,0x3(%r14)
add    $0x8,%r14
jmp    1197 <WavpackNativeToLittleEndian+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
movzbl 0xc(%rsp),%eax
mov    %al,(%r14)
movzbl 0xd(%rsp),%eax
mov    %al,0x1(%r14)
add    $0x2,%r14
jmp    1197 <WavpackNativeToLittleEndian+0x77>
nopw   0x0(%rax,%rax,1)
call   1030 <isdigit@plt>
test   %eax,%eax
je     1197 <WavpackNativeToLittleEndian+0x77>
movsbq -0x1(%rbx),%rax
add    %rax,%r14
add    $0xffffffffffffffd0,%r14
jmp    1197 <WavpackNativeToLittleEndian+0x77>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @WavpackNativeToLittleEndian(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
br label %10
10: ; preds = %108, %2
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %111
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %94 [
i32 68, label %18
i32 76, label %60
i32 83, label %82
]
18: ; preds = %14
%19 = load i8*, i8** %5
%20 = call i32 @memcpy(i32* %6, i8* %19, i32 4)
%21 = load i32, i32* %6
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
store i8 %22, i8* %23
%25 = load i32, i32* %6
%26 = ashr i32 %25, 8
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
store i8 %27, i8* %28
%30 = load i32, i32* %6
%31 = ashr i32 %30, 16
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %5
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %5
store i8 %32, i8* %33
%35 = load i32, i32* %6
%36 = ashr i32 %35, 24
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %5
store i8 %37, i8* %38
%40 = load i32, i32* %6
%41 = ashr i32 %40, 32
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %5
store i8 %42, i8* %43
%45 = load i32, i32* %6
%46 = ashr i32 %45, 40
%47 = trunc i32 %46 to i8
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %5
store i8 %47, i8* %48
%50 = load i32, i32* %6
%51 = ashr i32 %50, 48
%52 = trunc i32 %51 to i8
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %5
store i8 %52, i8* %53
%55 = load i32, i32* %6
%56 = ashr i32 %55, 56
%57 = trunc i32 %56 to i8
%58 = load i8*, i8** %5
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %5
store i8 %57, i8* %58
br label %108
60: ; preds = %14
%61 = load i8*, i8** %5
%62 = call i32 @memcpy(i32* %7, i8* %61, i32 4)
%63 = load i32, i32* %7
%64 = trunc i32 %63 to i8
%65 = load i8*, i8** %5
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %5
store i8 %64, i8* %65
%67 = load i32, i32* %7
%68 = ashr i32 %67, 8
%69 = trunc i32 %68 to i8
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %5
store i8 %69, i8* %70
%72 = load i32, i32* %7
%73 = ashr i32 %72, 16
%74 = trunc i32 %73 to i8
%75 = load i8*, i8** %5
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %5
store i8 %74, i8* %75
%77 = load i32, i32* %7
%78 = ashr i32 %77, 24
%79 = trunc i32 %78 to i8
%80 = load i8*, i8** %5
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %5
store i8 %79, i8* %80
br label %108
82: ; preds = %14
%83 = load i8*, i8** %5
%84 = call i32 @memcpy(i32* %8, i8* %83, i32 4)
%85 = load i32, i32* %8
%86 = trunc i32 %85 to i8
%87 = load i8*, i8** %5
%88 = getelementptr inbounds i8, i8* %87, i32 1
store i8* %88, i8** %5
store i8 %86, i8* %87
%89 = load i32, i32* %8
%90 = ashr i32 %89, 8
%91 = trunc i32 %90 to i8
%92 = load i8*, i8** %5
%93 = getelementptr inbounds i8, i8* %92, i32 1
store i8* %93, i8** %5
store i8 %91, i8* %92
br label %108
94: ; preds = %14
%95 = load i8*, i8** %4
%96 = load i8, i8* %95
%97 = call i32 @isdigit(i8 signext %96)
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %107
99: ; preds = %94
%100 = load i8*, i8** %4
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = sub nsw i32 %102, 48
%104 = load i8*, i8** %5
%105 = sext i32 %103 to i64
%106 = getelementptr inbounds i8, i8* %104, i64 %105
store i8* %106, i8** %5
br label %107
107: ; preds = %99, %94
br label %108
108: ; preds = %107, %82, %60, %18
%109 = load i8*, i8** %4
%110 = getelementptr inbounds i8, i8* %109, i32 1
store i8* %110, i8** %4
br label %10
111: ; preds = %10
ret void
}

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