#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__ readbufferfix(unsigned char *, int);
int tng_compress_uncompress_pos(char *, double *);
int tng_compress_uncompress_vel(char *, double *);
int tng_compress_uncompress(char *data, double *posvel) {
  int magic_int;
  magic_int = (int)readbufferfix((unsigned char *)data, 4);
  if (magic_int == 0x50474E54)
    return tng_compress_uncompress_pos(data, posvel);
  else if (magic_int == 0x56474E54)
    return tng_compress_uncompress_vel(data, posvel);
  else
    return 1;
}


x86 assembly (clang, -O0):
<tng_compress_uncompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1030 <readbufferfix@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x50474e54,-0x1c(%rbp)
jne    1173 <tng_compress_uncompress+0x43>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <tng_compress_uncompress_pos@plt>
mov    %eax,-0x4(%rbp)
jmp    119c <tng_compress_uncompress+0x6c>
cmpl   $0x56474e54,-0x1c(%rbp)
jne    1195 <tng_compress_uncompress+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <tng_compress_uncompress_vel@plt>
mov    %eax,-0x4(%rbp)
jmp    119c <tng_compress_uncompress+0x6c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tng_compress_uncompress>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x4,%esi
call   1030 <readbufferfix@plt>
cmp    $0x56474e54,%eax
je     1164 <tng_compress_uncompress+0x34>
cmp    $0x50474e54,%eax
jne    1176 <tng_compress_uncompress+0x46>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <tng_compress_uncompress_pos@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <tng_compress_uncompress_vel@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @tng_compress_uncompress(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i32
store i8* %0, i8** %4
store double* %1, double** %5
%7 = load i8*, i8** %4
%8 = call i64 @readbufferfix(i8* %7, i32 4)
%9 = trunc i64 %8 to i32
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 1346850388
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load double*, double** %5
%15 = call i32 @tng_compress_uncompress_pos(i8* %13, double* %14)
store i32 %15, i32* %3
br label %24
16: ; preds = %2
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 1447513684
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i8*, i8** %4
%21 = load double*, double** %5
%22 = call i32 @tng_compress_uncompress_vel(i8* %20, double* %21)
store i32 %22, i32* %3
br label %24
23: ; preds = %16
store i32 1, i32* %3
br label %24
24: ; preds = %23, %19, %12
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @tng_compress_uncompress(i8* %0, double* %1) {
%3 = tail call i64 @readbufferfix(i8* %0, i32 4)
%4 = trunc i64 %3 to i32
switch i32 %4, label %9 [
i32 1346850388, label %5
i32 1447513684, label %7
]
5: ; preds = %2
%6 = tail call i32 @tng_compress_uncompress_pos(i8* %0, double* %1)
br label %9
7: ; preds = %2
%8 = tail call i32 @tng_compress_uncompress_vel(i8* %0, double* %1)
br label %9
9: ; preds = %2, %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ], [ 1, %2 ]
ret i32 %10
}