#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 CHAR_BIT;
int /*<<< orphan*/ assert(int);
int decode_char(unsigned char const);
int get_octet(int);
int get_offset(int);
unsigned char shift_left(int, int);
int decode_sequence(const unsigned char *coded, unsigned char *plain) {
  int block;
  assert(CHAR_BIT == 8);
  assert(coded && plain);
  plain[0] = 0;
  for (block = 0; block < 8; block++) {
    int offset = get_offset(block);
    int octet = get_octet(block);
    int c = decode_char(coded[block]);
    if (c < 0)
      return octet;
    plain[octet] |= shift_left(c, offset);
    if (offset < 0) {
      assert(octet < 4);
      plain[octet + 1] = shift_left(c, 8 + offset);
    }
  }
  return 5;
}


x86 assembly (clang, -O0):
<decode_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e79(%rip),%rax
cmpl   $0x8,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x29(%rbp)
je     1192 <decode_sequence+0x42>
cmpq   $0x0,-0x18(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1263 <decode_sequence+0x113>
mov    -0x1c(%rbp),%edi
call   1070 <get_offset@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <get_octet@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <decode_char@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    11f6 <decode_sequence+0xa6>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    126a <decode_sequence+0x11a>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1060 <shift_left@plt>
movzbl %al,%esi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
or     %esi,%edx
mov    %dl,(%rax,%rcx,1)
cmpl   $0x0,-0x20(%rbp)
jge    1250 <decode_sequence+0x100>
cmpl   $0x4,-0x24(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
add    $0x8,%esi
call   1060 <shift_left@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1255 <decode_sequence+0x105>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ad <decode_sequence+0x5d>
movl   $0x5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_sequence>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e78(%rip),%rax
xor    %edi,%edi
cmpl   $0x8,(%rax)
sete   %dil
call   1040 <assert@plt>
mov    %rbx,(%rsp)
test   %rbx,%rbx
setne  %al
test   %r15,%r15
setne  %cl
and    %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
movb   $0x0,(%r15)
xor    %ebx,%ebx
jmp    11aa <decode_sequence+0x5a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x8,%rbx
je     120b <decode_sequence+0xbb>
mov    %ebx,%edi
call   1070 <get_offset@plt>
mov    %eax,%r13d
mov    %ebx,%edi
call   1050 <get_octet@plt>
mov    %eax,%r12d
mov    (%rsp),%rax
movzbl (%rax,%rbx,1),%edi
call   1030 <decode_char@plt>
test   %eax,%eax
js     1211 <decode_sequence+0xc1>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r13d,%esi
call   1060 <shift_left@plt>
movslq %r12d,%r14
or     %al,(%r15,%r14,1)
test   %r13d,%r13d
jns    11a0 <decode_sequence+0x50>
xor    %edi,%edi
cmp    $0x4,%r12d
setl   %dil
call   1040 <assert@plt>
add    $0x8,%r13d
mov    %ebp,%edi
mov    %r13d,%esi
call   1060 <shift_left@plt>
mov    %al,0x1(%r14,%r15,1)
jmp    11a0 <decode_sequence+0x50>
mov    $0x5,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define i32 @decode_sequence(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i32, i32* @CHAR_BIT
%11 = icmp eq i32 %10, 8
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br label %19
19: ; preds = %16, %2
%20 = phi i1 [ false, %2 ], [ %18, %16 ]
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 0, i8* %24
store i32 0, i32* %6
br label %25
25: ; preds = %73, %19
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 8
br i1 %27, label %28, label %76
28: ; preds = %25
%29 = load i32, i32* %6
%30 = call i32 @get_offset(i32 %29)
store i32 %30, i32* %7
%31 = load i32, i32* %6
%32 = call i32 @get_octet(i32 %31)
store i32 %32, i32* %8
%33 = load i8*, i8** %4
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @decode_char(i8 zeroext %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %28
%42 = load i32, i32* %8
store i32 %42, i32* %3
br label %77
43: ; preds = %28
%44 = load i32, i32* %9
%45 = load i32, i32* %7
%46 = call zeroext i8 @shift_left(i32 %44, i32 %45)
%47 = zext i8 %46 to i32
%48 = load i8*, i8** %5
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = or i32 %53, %47
%55 = trunc i32 %54 to i8
store i8 %55, i8* %51
%56 = load i32, i32* %7
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %72
58: ; preds = %43
%59 = load i32, i32* %8
%60 = icmp slt i32 %59, 4
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load i32, i32* %9
%64 = load i32, i32* %7
%65 = add nsw i32 8, %64
%66 = call zeroext i8 @shift_left(i32 %63, i32 %65)
%67 = load i8*, i8** %5
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %67, i64 %70
store i8 %66, i8* %71
br label %72
72: ; preds = %58, %43
br label %73
73: ; preds = %72
%74 = load i32, i32* %6
%75 = add nsw i32 %74, 1
store i32 %75, i32* %6
br label %25
76: ; preds = %25
store i32 5, i32* %3
br label %77
77: ; preds = %76, %41
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define i32 @decode_sequence(i8* %0, i8* %1) {
%3 = load i32, i32* @CHAR_BIT
%4 = icmp eq i32 %3, 8
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne i8* %0, null
%8 = icmp ne i8* %1, null
%9 = and i1 %7, %8
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
store i8 0, i8* %1
br label %12
12: ; preds = %2, %37
%13 = phi i64 [ 0, %2 ], [ %38, %37 ]
%14 = trunc i64 %13 to i32
%15 = tail call i32 @get_offset(i32 %14)
%16 = tail call i32 @get_octet(i32 %14)
%17 = getelementptr inbounds i8, i8* %0, i64 %13
%18 = load i8, i8* %17
%19 = tail call i32 @decode_char(i8 zeroext %18)
%20 = icmp slt i32 %19, 0
br i1 %20, label %40, label %21
21: ; preds = %12
%22 = tail call zeroext i8 @shift_left(i32 %19, i32 %15)
%23 = sext i32 %16 to i64
%24 = getelementptr inbounds i8, i8* %1, i64 %23
%25 = load i8, i8* %24
%26 = or i8 %25, %22
store i8 %26, i8* %24
%27 = icmp slt i32 %15, 0
br i1 %27, label %28, label %37
28: ; preds = %21
%29 = icmp slt i32 %16, 4
%30 = zext i1 %29 to i32
%31 = tail call i32 @assert(i32 %30)
%32 = add nsw i32 %15, 8
%33 = tail call zeroext i8 @shift_left(i32 %19, i32 %32)
%34 = add nsw i32 %16, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %1, i64 %35
store i8 %33, i8* %36
br label %37
37: ; preds = %21, %28
%38 = add nuw nsw i64 %13, 1
%39 = icmp eq i64 %38, 8
br i1 %39, label %40, label %12
40: ; preds = %12, %37
%41 = phi i32 [ 5, %37 ], [ %16, %12 ]
ret i32 %41
}