#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 get_flag_value(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ uncompressed_parse_values(unsigned char *, int *);
void test_uncompressed_packet(void) {
  int i = 0;
  unsigned char packet[6] = {0xe0, 0x17, 0x6a, 0x88, 0x63, 0x84};
  char dropped_flag = 0;
  char expected_dropped_flag = 0;
  int eeg_values[4];
  int expected_eeg_values[4] = {535, 538, 568, 529};
  dropped_flag = get_flag_value(packet[0]);
  uncompressed_parse_values(&(packet[1]), eeg_values);
  printf("\n\n");
  printf("*************************\n");
  printf("Uncompressed Packet      \n");
  printf("*************************\n");
  printf("\n");
  printf("Expected:Obtained\n");
  printf("dropped flag:%i:%i\n", expected_dropped_flag, dropped_flag);
  if (expected_dropped_flag == dropped_flag) {
    printf("OK\n");
  } else {
    printf("bug!\n");
  }
  for (i = 0; i < 4; i++) {
    printf("value[%i]:%i:%i ", i, expected_eeg_values[i], eeg_values[i]);
    if (expected_eeg_values[i] == eeg_values[i]) {
      printf("OK\n");
    } else {
      printf("bug!\n");
    }
  }
}


x86 assembly (clang, -O0):
<test_uncompressed_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xeb5(%rip),%ax
mov    %ax,-0x6(%rbp)
movb   $0x0,-0xb(%rbp)
movb   $0x0,-0xc(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
movzbl -0xa(%rbp),%edi
call   1050 <get_flag_value@plt>
mov    %al,-0xb(%rbp)
lea    -0xa(%rbp),%rdi
add    $0x1,%rdi
lea    -0x20(%rbp),%rsi
call   1040 <uncompressed_parse_values@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xc(%rbp),%esi
movsbl -0xb(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xc(%rbp),%eax
movsbl -0xb(%rbp),%ecx
cmp    %ecx,%eax
jne    121b <test_uncompressed_packet+0xeb>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <test_uncompressed_packet+0xf9>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    12a5 <test_uncompressed_packet+0x175>
mov    -0x4(%rbp),%esi
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
movslq -0x4(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x4(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jne    1284 <test_uncompressed_packet+0x154>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1292 <test_uncompressed_packet+0x162>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1297 <test_uncompressed_packet+0x167>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1230 <test_uncompressed_packet+0x100>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_uncompressed_packet>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movw   $0x8463,0x1c(%rsp)
movl   $0x886a17e0,0x18(%rsp)
88
mov    $0xe0,%edi
call   1070 <get_flag_value@plt>
mov    %eax,%ebp
lea    0x19(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <uncompressed_parse_values@plt>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb2(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe9f(%rip),%rdi
call   1040 <puts@plt>
movsbl %bpl,%ebx
lea    0xe36(%rip),%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
test   %bl,%bl
lea    0xe92(%rip),%rbp
lea    0xe86(%rip),%rbx
mov    %rbx,%rdi
cmove  %rbp,%rdi
call   1040 <puts@plt>
mov    (%rsp),%ecx
lea    0xe19(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x217,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x217,(%rsp)
mov    %rbx,%rdi
cmove  %rbp,%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x21a,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x21a,0x4(%rsp)
mov    %rbx,%rdi
cmove  %rbp,%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%ecx
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x238,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x238,0x8(%rsp)
mov    %rbx,%rdi
cmove  %rbp,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%ecx
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x211,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x211,0xc(%rsp)
cmove  %rbp,%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.test_uncompressed_packet.packet = [6 x i8] c"\E0\17j\88c\84"
@__const.test_uncompressed_packet.expected_eeg_values = [4 x i32] [i32 535, i32 538, i32 568, i32 529]
@.str = [3 x i8] c"\0A\0A\00"
@.str.1 = [27 x i8] c"*************************\0A\00"
@.str.2 = [27 x i8] c"Uncompressed Packet \0A\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [19 x i8] c"Expected:Obtained\0A\00"
@.str.5 = [20 x i8] c"dropped flag:%i:%i\0A\00"
@.str.6 = [4 x i8] c"OK\0A\00"
@.str.7 = [6 x i8] c"bug!\0A\00"
@.str.8 = [17 x i8] c"value[%i]:%i:%i \00"
define void @test_uncompressed_packet() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca i8
%4 = alloca i8
%5 = alloca [4 x i32]
%6 = alloca [4 x i32]
store i32 0, i32* %1
%7 = bitcast [6 x i8]* %2 to i8*
store i8 0, i8* %3
store i8 0, i8* %4
%8 = bitcast [4 x i32]* %6 to i8*
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%10 = load i8, i8* %9
%11 = call signext i8 @get_flag_value(i8 zeroext %10)
store i8 %11, i8* %3
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 1
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 0
%14 = call i32 @uncompressed_parse_values(i8* %12, i32* %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %22, i32 %24)
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %27, %29
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %35
33: ; preds = %0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
store i32 0, i32* %1
br label %36
36: ; preds = %64, %35
%37 = load i32, i32* %1
%38 = icmp slt i32 %37, 4
br i1 %38, label %39, label %67
39: ; preds = %36
%40 = load i32, i32* %1
%41 = load i32, i32* %1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %40, i32 %44, i32 %48)
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %5, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = icmp eq i32 %53, %57
br i1 %58, label %59, label %61
59: ; preds = %39
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %63
61: ; preds = %39
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
br label %64
64: ; preds = %63
%65 = load i32, i32* %1
%66 = add nsw i32 %65, 1
store i32 %66, i32* %1
br label %36
67: ; preds = %36
ret void
}

LLVM IR (-O2):
@__const.test_uncompressed_packet.packet = [6 x i8] c"\E0\17j\88c\84"
@.str.5 = [20 x i8] c"dropped flag:%i:%i\0A\00"
@.str.8 = [17 x i8] c"value[%i]:%i:%i \00"
@str = [2 x i8] c"\0A\00"
@str.10 = [26 x i8] c"Uncompressed Packet \00"
@str.11 = [26 x i8] c"*************************\00"
@str.12 = [18 x i8] c"Expected:Obtained\00"
@str.14 = [5 x i8] c"bug!\00"
@str.16 = [3 x i8] c"OK\00"
define void @test_uncompressed_packet() {
%1 = alloca [6 x i8]
%2 = alloca [4 x i32]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = bitcast [4 x i32]* %2 to i8*
%5 = tail call signext i8 @get_flag_value(i8 zeroext -32)
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 1
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = call i32 @uncompressed_parse_values(i8* %6, i32* %7)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.10, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
%13 = call i32 @putchar(i32 10)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
%15 = sext i8 %5 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 %15)
%17 = icmp eq i8 %5, 0
%18 = select i1 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0)
%19 = call i32 @puts(i8* dereferenceable(1) %18)
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 0, i32 535, i32 %20)
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 535
%24 = select i1 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0)
%25 = call i32 @puts(i8* dereferenceable(1) %24)
%26 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 1, i32 538, i32 %27)
%29 = load i32, i32* %26
%30 = icmp eq i32 %29, 538
%31 = select i1 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0)
%32 = call i32 @puts(i8* dereferenceable(1) %31)
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 2, i32 568, i32 %34)
%36 = load i32, i32* %33
%37 = icmp eq i32 %36, 568
%38 = select i1 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0)
%39 = call i32 @puts(i8* dereferenceable(1) %38)
%40 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 3, i32 529, i32 %41)
%43 = load i32, i32* %40
%44 = icmp eq i32 %43, 529
%45 = select i1 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.14, i64 0, i64 0)
%46 = call i32 @puts(i8* dereferenceable(1) %45)
ret void
}