#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 */
char *r64dec1(char *, unsigned int *, int *);
char *r64dec(char *p, unsigned char **bpp) {
  unsigned int v;
  int eof = 0;
  unsigned char *bp = *bpp;
  while (!eof) {
    if (!(p = r64dec1(p, &v, &eof)))
      return 0;
    *bp++ = v >> 16;
    *bp++ = v >> 8;
    *bp++ = v;
  }
  *bpp = bp - eof;
  return p;
}


x86 assembly (clang, -O0):
<r64dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x20(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1148 <r64dec+0x38>
jmp    11c1 <r64dec+0xb1>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <r64dec1@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1174 <r64dec+0x64>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <r64dec+0xd0>
mov    -0x1c(%rbp),%eax
shr    $0x10,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    1132 <r64dec+0x22>
mov    -0x28(%rbp),%rcx
movslq -0x20(%rbp),%rdx
xor    %eax,%eax
sub    %rdx,%rax
add    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r64dec>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rax
movl   $0x0,0x4(%rsp)
mov    (%rsi),%rbx
mov    %rsp,%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <r64dec1@plt>
test   %rax,%rax
je     117d <r64dec+0x6d>
movzbl 0x2(%rsp),%ecx
mov    %cl,(%rbx)
movzbl 0x1(%rsp),%ecx
mov    %cl,0x1(%rbx)
movzbl (%rsp),%ecx
mov    %cl,0x2(%rbx)
add    $0x3,%rbx
movslq 0x4(%rsp),%rcx
test   %rcx,%rcx
je     1140 <r64dec+0x30>
sub    %rcx,%rbx
mov    %rbx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @r64dec(i8* %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = load i8*, i8** %1
br label %8
8: ; preds = %2, %13
%9 = phi i8* [ %7, %2 ], [ %24, %13 ]
%10 = phi i8* [ %0, %2 ], [ %11, %13 ]
%11 = call i8* @r64dec1(i8* %10, i32* %3, i32* %4)
%12 = icmp eq i8* %11, null
br i1 %12, label %31, label %13
13: ; preds = %8
%14 = load i32, i32* %3
%15 = lshr i32 %14, 16
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %16, i8* %9
%18 = load i32, i32* %3
%19 = lshr i32 %18, 8
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %9, i64 2
store i8 %20, i8* %17
%22 = load i32, i32* %3
%23 = trunc i32 %22 to i8
%24 = getelementptr inbounds i8, i8* %9, i64 3
store i8 %23, i8* %21
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %8, label %27
27: ; preds = %13
%28 = sext i32 %25 to i64
%29 = sub nsw i64 0, %28
%30 = getelementptr inbounds i8, i8* %24, i64 %29
store i8* %30, i8** %1
br label %31
31: ; preds = %8, %27
ret i8* %11
}