#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ out_fn(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int, int,
                          int);
int pdp11_in(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void block(FILE *in, FILE *out) {
  int first, count, address;
  for (first = 0; ((first = pdp11_in(in)) & 0377) != 1;)
    ;
  count = pdp11_in(in);
  address = pdp11_in(in);
  if (count == 6 && (address & 1) == 0)
    fprintf(stderr, "Program start: %06o\n", address);
  out_fn(in, out, first, address, count);
}


x86 assembly (clang, -O0):
<block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <pdp11_in@plt>
mov    %eax,-0x14(%rbp)
and    $0xff,%eax
cmp    $0x1,%eax
je     1166 <block+0x36>
jmp    1147 <block+0x17>
mov    -0x8(%rbp),%rdi
call   1050 <pdp11_in@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <pdp11_in@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x6,-0x18(%rbp)
jne    11af <block+0x7f>
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11af <block+0x7f>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe56(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1040 <out_fn@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <pdp11_in@plt>
mov    %eax,%ebp
cmp    $0x1,%bpl
jne    1140 <block+0x10>
mov    %rbx,%rdi
call   1050 <pdp11_in@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1050 <pdp11_in@plt>
mov    %eax,%r12d
cmp    $0x6,%r15d
jne    118c <block+0x5c>
mov    %r12d,%eax
and    $0x1,%eax
jne    118c <block+0x5c>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
mov    %r12d,%edx
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <out_fn@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Program start: %06o\0A\00"
define void @block(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %8
8: ; preds = %13, %2
%9 = load i32*, i32** %3
%10 = call i32 @pdp11_in(i32* %9)
store i32 %10, i32* %5
%11 = and i32 %10, 255
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %8
br label %8
14: ; preds = %8
%15 = load i32*, i32** %3
%16 = call i32 @pdp11_in(i32* %15)
store i32 %16, i32* %6
%17 = load i32*, i32** %3
%18 = call i32 @pdp11_in(i32* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 6
br i1 %20, label %21, label %29
21: ; preds = %14
%22 = load i32, i32* %7
%23 = and i32 %22, 1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i32, i32* %7
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %21, %14
%30 = load i32*, i32** %3
%31 = load i32*, i32** %4
%32 = load i32, i32* %5
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = call i32 @out_fn(i32* %30, i32* %31, i32 %32, i32 %33, i32 %34)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Program start: %06o\0A\00"
define void @block(i32* %0, i32* %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @pdp11_in(i32* %0)
%5 = and i32 %4, 255
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %3
7: ; preds = %3
%8 = tail call i32 @pdp11_in(i32* %0)
%9 = tail call i32 @pdp11_in(i32* %0)
%10 = icmp eq i32 %8, 6
%11 = and i32 %9, 1
%12 = icmp eq i32 %11, 0
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %17
17: ; preds = %14, %7
%18 = tail call i32 @out_fn(i32* %0, i32* %1, i32 %4, i32 %9, i32 %8)
ret void
}