#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 */
int /*<<< orphan*/ printf(char *, ...);
void parsedata(void *buffer) {
  int i = 0;
  unsigned char *data = buffer;
  if (data[0] != 0xb7 || (data[2] << 8 | data[3]) != 3248)
    goto failed;
  printf("\033[40;34mbn\033[0m: %d, ", data[1]);
  printf("\033[40;34mfn\033[0m: %d, ", data[4] << 8 | data[5]);
  printf("\033[40;34mwait\033[0m: %d\n", data[6]);
failed:
  printf("data error:\n");
  for (i = 0; i < 100; i++) {
    printf("[%d]:%#x,", i, data[i]);
    if (i == 8) {
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<parsedata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xb7,%eax
jne    115d <parsedata+0x4d>
mov    -0x18(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
mov    -0x18(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
cmp    $0xcb0,%eax
je     1162 <parsedata+0x52>
jmp    11b1 <parsedata+0xa1>
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movzbl 0x4(%rax),%esi
shl    $0x8,%esi
mov    -0x18(%rbp),%rax
movzbl 0x5(%rax),%eax
or     %eax,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movzbl 0x6(%rax),%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    1218 <parsedata+0x108>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x8,-0xc(%rbp)
jne    1205 <parsedata+0xf5>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <parsedata+0xfa>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c6 <parsedata+0xb6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsedata>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
cmpb   $0xb7,(%rdi)
jne    118c <parsedata+0x5c>
movzwl 0x2(%r15),%eax
shl    $0x10,%eax
bswap  %eax
cmp    $0xcb0,%eax
jne    118c <parsedata+0x5c>
movzbl 0x1(%r15),%esi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzwl 0x4(%r15),%esi
shl    $0x10,%esi
bswap  %esi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x6(%r15),%esi
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%r14
xor    %ebx,%ebx
jmp    11ba <parsedata+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0x64,%rbx
je     11dd <parsedata+0xad>
movzbl (%r15,%rbx,1),%edx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x8,%rbx
jne    11b0 <parsedata+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <parsedata+0x80>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\1B[40;34mbn\1B[0m: %d, \00"
@.str.1 = [21 x i8] c"\1B[40;34mfn\1B[0m: %d, \00"
@.str.2 = [22 x i8] c"\1B[40;34mwait\1B[0m: %d\0A\00"
@.str.3 = [13 x i8] c"data error:\0A\00"
@.str.4 = [10 x i8] c"[%d]:%#x,\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @parsedata(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = load i8*, i8** %2
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = icmp ne i32 %9, 183
br i1 %10, label %23, label %11
11: ; preds = %1
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = shl i32 %15, 8
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 3
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = or i32 %16, %20
%22 = icmp ne i32 %21, 3248
br i1 %22, label %23, label %24
23: ; preds = %11, %1
br label %46
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 4
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl i32 %33, 8
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 5
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = or i32 %34, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 6
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %24, %23
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %48
48: ; preds = %65, %46
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 100
br i1 %50, label %51, label %68
51: ; preds = %48
%52 = load i32, i32* %3
%53 = load i8*, i8** %4
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %58)
%60 = load i32, i32* %3
%61 = icmp eq i32 %60, 8
br i1 %61, label %62, label %64
62: ; preds = %51
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %62, %51
br label %65
65: ; preds = %64
%66 = load i32, i32* %3
%67 = add nsw i32 %66, 1
store i32 %67, i32* %3
br label %48
68: ; preds = %48
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"\1B[40;34mbn\1B[0m: %d, \00"
@.str.1 = [21 x i8] c"\1B[40;34mfn\1B[0m: %d, \00"
@.str.2 = [22 x i8] c"\1B[40;34mwait\1B[0m: %d\0A\00"
@.str.4 = [10 x i8] c"[%d]:%#x,\00"
@str = [12 x i8] c"data error:\00"
define void @parsedata(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, -73
br i1 %3, label %4, label %32
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = shl nuw nsw i32 %7, 8
%9 = getelementptr inbounds i8, i8* %0, i64 3
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = or i32 %8, %11
%13 = icmp eq i32 %12, 3248
br i1 %13, label %14, label %32
14: ; preds = %4
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i8, i8* %0, i64 4
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = shl nuw nsw i32 %21, 8
%23 = getelementptr inbounds i8, i8* %0, i64 5
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = or i32 %22, %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i8, i8* %0, i64 6
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %1, %4, %14
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %32, %44
%35 = phi i64 [ 0, %32 ], [ %45, %44 ]
%36 = getelementptr inbounds i8, i8* %0, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = trunc i64 %35 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %39, i32 %38)
%41 = icmp eq i64 %35, 8
br i1 %41, label %42, label %44
42: ; preds = %34
%43 = tail call i32 @putchar(i32 10)
br label %44
44: ; preds = %34, %42
%45 = add nuw nsw i64 %35, 1
%46 = icmp eq i64 %45, 100
br i1 %46, label %47, label %34
47: ; preds = %44
ret void
}