#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*/ fprintf(int /*<<< orphan*/, char *, int);
int rb(int);
int /*<<< orphan*/ stderr;
int getlength(void) {
  int x1, x2;
  x1 = rb(1);
  if (x1 == -1)
    return -1;
  x2 = rb(1);
  if (x2 == -1)
    return -1;
  x1 = (x1 << 8) | x2;
  fprintf(stderr, "(%d)", x1);
  return x1;
}


x86 assembly (clang, -O0):
<getlength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1040 <rb@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    114b <getlength+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <getlength+0x78>
mov    $0x1,%edi
call   1040 <rb@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    116e <getlength+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <getlength+0x78>
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe73(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getlength>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%edi
call   1040 <rb@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     116b <getlength+0x4b>
mov    %eax,%ebx
mov    $0x1,%edi
call   1040 <rb@plt>
cmp    $0xffffffff,%eax
je     116b <getlength+0x4b>
mov    %eax,%ebp
shl    $0x8,%ebx
or     %ebx,%ebp
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    %ebp,%edx
call   1030 <fprintf@plt>
mov    %ebp,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"(%d)\00"
define i32 @getlength() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @rb(i32 1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %1
br label %22
8: ; preds = %0
%9 = call i32 @rb(i32 1)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 -1, i32* %1
br label %22
13: ; preds = %8
%14 = load i32, i32* %2
%15 = shl i32 %14, 8
%16 = load i32, i32* %3
%17 = or i32 %15, %16
store i32 %17, i32* %2
%18 = load i32, i32* @stderr
%19 = load i32, i32* %2
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %2
store i32 %21, i32* %1
br label %22
22: ; preds = %13, %12, %7
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"(%d)\00"
define i32 @getlength() {
%1 = tail call i32 @rb(i32 1)
%2 = icmp eq i32 %1, -1
br i1 %2, label %11, label %3
3: ; preds = %0
%4 = tail call i32 @rb(i32 1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = shl i32 %1, 8
%8 = or i32 %4, %7
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %11
11: ; preds = %3, %0, %6
%12 = phi i32 [ %8, %6 ], [ -1, %0 ], [ -1, %3 ]
ret i32 %12
}