#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 */
unsigned char get_char2();
int /*<<< orphan*/ put_char2(int);
unsigned char read_51block(void) {
  unsigned char hdr = 0, i = 1;
  hdr = get_char2();
  switch (hdr) {
  case 0x21:
    i = 2;
    break;
  case 0x15:
    i = 4;
    break;
  case 0x11:
    i = 6;
    break;
  case 0x14:
  case 0x30:
    i = 8;
    break;
  }
  while (--i)
    get_char2();
  put_char2(0xce);
  return hdr;
}


x86 assembly (clang, -O0):
<read_51block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
movb   $0x1,-0x2(%rbp)
xor    %eax,%eax
call   1030 <get_char2@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0xffffffef,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x1f,%eax
ja     1183 <read_51block+0x63>
mov    -0x10(%rbp),%rax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x2,-0x2(%rbp)
jmp    1183 <read_51block+0x63>
movb   $0x4,-0x2(%rbp)
jmp    1183 <read_51block+0x63>
movb   $0x6,-0x2(%rbp)
jmp    1183 <read_51block+0x63>
movb   $0x8,-0x2(%rbp)
jmp    1188 <read_51block+0x68>
mov    -0x2(%rbp),%al
add    $0xff,%al
mov    %al,-0x2(%rbp)
cmp    $0x0,%al
je     11a4 <read_51block+0x84>
mov    $0x0,%al
call   1030 <get_char2@plt>
jmp    1188 <read_51block+0x68>
mov    $0xce,%edi
call   1040 <put_char2@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_51block>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <get_char2@plt>
mov    %eax,%ebp
add    $0xef,%al
cmp    $0x1f,%al
ja     116c <read_51block+0x4c>
mov    $0x1,%bl
movzbl %al,%eax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x7,%bl
jmp    1160 <read_51block+0x40>
mov    $0x5,%bl
jmp    1160 <read_51block+0x40>
mov    $0x3,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <get_char2@plt>
add    $0xff,%bl
jne    1160 <read_51block+0x40>
mov    $0xce,%edi
call   1040 <put_char2@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @read_51block() {
%1 = alloca i8
%2 = alloca i8
store i8 0, i8* %1
store i8 1, i8* %2
%3 = call zeroext i8 (...) @get_char2()
store i8 %3, i8* %1
%4 = load i8, i8* %1
%5 = zext i8 %4 to i32
switch i32 %5, label %10 [
i32 33, label %6
i32 21, label %7
i32 17, label %8
i32 20, label %9
i32 48, label %9
]
6: ; preds = %0
store i8 2, i8* %2
br label %10
7: ; preds = %0
store i8 4, i8* %2
br label %10
8: ; preds = %0
store i8 6, i8* %2
br label %10
9: ; preds = %0, %0
store i8 8, i8* %2
br label %10
10: ; preds = %0, %9, %8, %7, %6
br label %11
11: ; preds = %15, %10
%12 = load i8, i8* %2
%13 = add i8 %12, -1
store i8 %13, i8* %2
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call zeroext i8 (...) @get_char2()
br label %11
17: ; preds = %11
%18 = call i32 @put_char2(i32 206)
%19 = load i8, i8* %1
ret i8 %19
}

LLVM IR (-O2):
define zeroext i8 @read_51block() {
%1 = tail call zeroext i8 (...) @get_char2()
switch i8 %1, label %12 [
i8 33, label %5
i8 21, label %2
i8 17, label %3
i8 20, label %4
i8 48, label %4
]
2: ; preds = %0
br label %5
3: ; preds = %0
br label %5
4: ; preds = %0, %0
br label %5
5: ; preds = %0, %4, %3, %2
%6 = phi i8 [ 1, %0 ], [ 7, %4 ], [ 5, %3 ], [ 3, %2 ]
br label %7
7: ; preds = %5, %7
%8 = phi i8 [ %10, %7 ], [ %6, %5 ]
%9 = tail call zeroext i8 (...) @get_char2()
%10 = add i8 %8, -1
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %7
12: ; preds = %7, %0
%13 = tail call i32 @put_char2(i32 206)
ret i8 %1
}