#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*/ decode_DP_packet(char *, char *);
int /*<<< orphan*/ decode_Frame_packet(char *, char *);
int /*<<< orphan*/ decode_ro_packet(char *, char *);
int /*<<< orphan*/ init_tracepoints();
int /*<<< orphan*/ start_trace_recording();
int /*<<< orphan*/ stop_trace_recording();
int /*<<< orphan*/ write_ok(char *);
int decode_Q_packet(char *buffer, char *response) {
  int i = 0;
  if (buffer[i] != 'T') {
    return (0);
  } else {
    i = 1;
  }
  switch (buffer[i]) {
  case 'i': {
    init_tracepoints();
    write_ok(response);
    return (1);
  };
  case 'S': {
    if (buffer[i + 2] == 'a') {
      start_trace_recording();
      write_ok(response);
      return (1);
    } else if (buffer[i + 2] == 'o') {
      stop_trace_recording();
      write_ok(response);
      return (1);
    } else {
      return (0);
    }
  }; break;
  case 'D': {
    decode_DP_packet(&(buffer[i + 3]), response);
    write_ok(response);
    return (1);
  } break;
  case 'F': {
    decode_Frame_packet(&(buffer[i + 6]), response);
    return (1);
  } break;
  case 'r': {
    decode_ro_packet(&(buffer[i + 3]), response);
    return (1);
  }
  default: {
    return (0);
  }
  }
  return (0);
}


x86 assembly (clang, -O0):
<decode_Q_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x54,%eax
je     11a8 <decode_Q_packet+0x38>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x2e,%eax
ja     12ea <decode_Q_packet+0x17a>
mov    -0x28(%rbp),%rax
lea    0xe28(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <init_tracepoints@plt>
mov    -0x18(%rbp),%rdi
call   1050 <write_ok@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jne    1233 <decode_Q_packet+0xc3>
mov    $0x0,%al
call   1060 <start_trace_recording@plt>
mov    -0x18(%rbp),%rdi
call   1050 <write_ok@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6f,%eax
jne    1269 <decode_Q_packet+0xf9>
mov    $0x0,%al
call   1090 <stop_trace_recording@plt>
mov    -0x18(%rbp),%rdi
call   1050 <write_ok@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1080 <decode_DP_packet@plt>
mov    -0x18(%rbp),%rdi
call   1050 <write_ok@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x6,%eax
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <decode_Frame_packet@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
cltq
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1070 <decode_ro_packet@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <decode_Q_packet+0x181>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_Q_packet>:
push   %rbx
xor    %eax,%eax
cmpb   $0x54,(%rdi)
jne    11f4 <decode_Q_packet+0x84>
movsbl 0x1(%rdi),%ecx
add    $0xffffffbc,%ecx
cmp    $0x2e,%ecx
ja     11f4 <decode_Q_packet+0x84>
mov    %rsi,%rbx
lea    0xe72(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
add    $0x4,%rdi
mov    %rbx,%rsi
call   1080 <decode_DP_packet@plt>
jmp    11e7 <decode_Q_packet+0x77>
add    $0x7,%rdi
mov    %rbx,%rsi
call   1040 <decode_Frame_packet@plt>
jmp    11ef <decode_Q_packet+0x7f>
mov    0x3(%rdi),%cl
cmp    $0x6f,%cl
je     11e0 <decode_Q_packet+0x70>
cmp    $0x61,%cl
jne    11f4 <decode_Q_packet+0x84>
xor    %eax,%eax
call   1060 <start_trace_recording@plt>
jmp    11e7 <decode_Q_packet+0x77>
xor    %eax,%eax
call   1030 <init_tracepoints@plt>
jmp    11e7 <decode_Q_packet+0x77>
add    $0x4,%rdi
mov    %rbx,%rsi
call   1070 <decode_ro_packet@plt>
jmp    11ef <decode_Q_packet+0x7f>
xor    %eax,%eax
call   1090 <stop_trace_recording@plt>
mov    %rbx,%rdi
call   1050 <write_ok@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @decode_Q_packet(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 84
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %81
15: ; preds = %2
store i32 1, i32* %6
br label %16
16: ; preds = %15
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %80 [
i32 105, label %23
i32 83, label %27
i32 68, label %54
i32 70, label %64
i32 114, label %72
]
23: ; preds = %16
%24 = call i32 (...) @init_tracepoints()
%25 = load i8*, i8** %5
%26 = call i32 @write_ok(i8* %25)
store i32 1, i32* %3
br label %81
27: ; preds = %16
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 97
br i1 %35, label %36, label %40
36: ; preds = %27
%37 = call i32 (...) @start_trace_recording()
%38 = load i8*, i8** %5
%39 = call i32 @write_ok(i8* %38)
store i32 1, i32* %3
br label %81
40: ; preds = %27
%41 = load i8*, i8** %4
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 111
br i1 %48, label %49, label %53
49: ; preds = %40
%50 = call i32 (...) @stop_trace_recording()
%51 = load i8*, i8** %5
%52 = call i32 @write_ok(i8* %51)
store i32 1, i32* %3
br label %81
53: ; preds = %40
store i32 0, i32* %3
br label %81
54: ; preds = %16
%55 = load i8*, i8** %4
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
%60 = load i8*, i8** %5
%61 = call i32 @decode_DP_packet(i8* %59, i8* %60)
%62 = load i8*, i8** %5
%63 = call i32 @write_ok(i8* %62)
store i32 1, i32* %3
br label %81
64: ; preds = %16
%65 = load i8*, i8** %4
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %65, i64 %68
%70 = load i8*, i8** %5
%71 = call i32 @decode_Frame_packet(i8* %69, i8* %70)
store i32 1, i32* %3
br label %81
72: ; preds = %16
%73 = load i8*, i8** %4
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8*, i8** %5
%79 = call i32 @decode_ro_packet(i8* %77, i8* %78)
store i32 1, i32* %3
br label %81
80: ; preds = %16
store i32 0, i32* %3
br label %81
81: ; preds = %80, %72, %64, %54, %53, %49, %36, %23, %14
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
define i32 @decode_Q_packet(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 84
br i1 %4, label %5, label %31
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %31 [
i32 105, label %9
i32 83, label %12
i32 68, label %21
i32 70, label %25
i32 114, label %28
]
9: ; preds = %5
%10 = tail call i32 (...) @init_tracepoints()
%11 = tail call i32 @write_ok(i8* %1)
br label %31
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %0, i64 3
%14 = load i8, i8* %13
switch i8 %14, label %31 [
i8 97, label %15
i8 111, label %18
]
15: ; preds = %12
%16 = tail call i32 (...) @start_trace_recording()
%17 = tail call i32 @write_ok(i8* %1)
br label %31
18: ; preds = %12
%19 = tail call i32 (...) @stop_trace_recording()
%20 = tail call i32 @write_ok(i8* %1)
br label %31
21: ; preds = %5
%22 = getelementptr inbounds i8, i8* %0, i64 4
%23 = tail call i32 @decode_DP_packet(i8* %22, i8* %1)
%24 = tail call i32 @write_ok(i8* %1)
br label %31
25: ; preds = %5
%26 = getelementptr inbounds i8, i8* %0, i64 7
%27 = tail call i32 @decode_Frame_packet(i8* %26, i8* %1)
br label %31
28: ; preds = %5
%29 = getelementptr inbounds i8, i8* %0, i64 4
%30 = tail call i32 @decode_ro_packet(i8* %29, i8* %1)
br label %31
31: ; preds = %5, %12, %2, %28, %25, %21, %18, %15, %9
%32 = phi i32 [ 1, %28 ], [ 1, %25 ], [ 1, %21 ], [ 1, %15 ], [ 1, %18 ], [ 1, %9 ], [ 0, %2 ], [ 0, %12 ], [ 0, %5 ]
ret i32 %32
}