#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*/ parse_message(unsigned char *, unsigned int);
void input_step(unsigned char c) {
  static unsigned int idx = 0;
  static unsigned int size;
  static unsigned char buffer[127 + 1];
  buffer[idx] = c;
  if (idx == 0)
    size = c & 0x7f;
  if (idx == size) {
    parse_message(buffer, size);
    idx = 0;
  } else
    idx++;
}


x86 assembly (clang, -O0):
<input_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%dl
mov    0x2f19(%rip),%eax
mov    %eax,%ecx
lea    0x2f20(%rip),%rax
mov    %dl,(%rax,%rcx,1)
cmpl   $0x0,0x2f06(%rip)
jne    114d <input_step+0x3d>
movzbl -0x1(%rbp),%eax
and    $0x7f,%eax
mov    %eax,0x2ef7(%rip)
mov    0x2eed(%rip),%eax
cmp    0x2eeb(%rip),%eax
jne    1180 <input_step+0x70>
mov    0x2edf(%rip),%esi
lea    0x2ee4(%rip),%rdi
call   1030 <parse_message@plt>
movl   $0x0,0x2ec5(%rip)
jmp    118f <input_step+0x7f>
mov    0x2eba(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb1(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_step>:
push   %rax
mov    0x2f29(%rip),%esi
lea    0x2f32(%rip),%rax
mov    %dil,(%rsi,%rax,1)
test   %rsi,%rsi
je     1141 <input_step+0x31>
mov    0x2f17(%rip),%eax
cmp    %eax,%esi
jne    1153 <input_step+0x43>
lea    0x2f18(%rip),%rdi
call   1030 <parse_message@plt>
xor    %eax,%eax
jmp    1156 <input_step+0x46>
and    $0x7f,%dil
movzbl %dil,%eax
mov    %eax,0x2ef5(%rip)
cmp    %eax,%esi
je     1131 <input_step+0x21>
lea    0x1(%rsi),%eax
mov    %eax,0x2ee4(%rip)
pop    %rax
ret

LLVM IR (-O0):
@input_step.idx = internal global i32 0
@input_step.size = internal global i32 0
@input_step.buffer = internal global [128 x i8] zeroinitializer
define void @input_step(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = load i32, i32* @input_step.idx
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [128 x i8], [128 x i8]* @input_step.buffer, i64 0, i64 %5
store i8 %3, i8* %6
%7 = load i32, i32* @input_step.idx
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8, i8* %2
%11 = zext i8 %10 to i32
%12 = and i32 %11, 127
store i32 %12, i32* @input_step.size
br label %13
13: ; preds = %9, %1
%14 = load i32, i32* @input_step.idx
%15 = load i32, i32* @input_step.size
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @input_step.size
%19 = call i32 @parse_message(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @input_step.buffer, i64 0, i64 0), i32 %18)
store i32 0, i32* @input_step.idx
br label %23
20: ; preds = %13
%21 = load i32, i32* @input_step.idx
%22 = add i32 %21, 1
store i32 %22, i32* @input_step.idx
br label %23
23: ; preds = %20, %17
ret void
}

LLVM IR (-O2):
@input_step.idx = internal unnamed_addr global i32 0
@input_step.size = internal unnamed_addr global i32 0
@input_step.buffer = internal global [128 x i8] zeroinitializer
define void @input_step(i8 zeroext %0) {
%2 = load i32, i32* @input_step.idx
%3 = zext i32 %2 to i64
%4 = getelementptr inbounds [128 x i8], [128 x i8]* @input_step.buffer, i64 0, i64 %3
store i8 %0, i8* %4
%5 = icmp eq i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = load i32, i32* @input_step.size
br label %11
8: ; preds = %1
%9 = and i8 %0, 127
%10 = zext i8 %9 to i32
store i32 %10, i32* @input_step.size
br label %11
11: ; preds = %6, %8
%12 = phi i32 [ %7, %6 ], [ %10, %8 ]
%13 = icmp eq i32 %2, %12
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @parse_message(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @input_step.buffer, i64 0, i64 0), i32 %2)
br label %18
16: ; preds = %11
%17 = add i32 %2, 1
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %17, %16 ], [ 0, %14 ]
store i32 %19, i32* @input_step.idx
ret void
}