#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 byteswap(int);
int readdata(int, int *, int);
int prereadcount(int *count) {
  int x;
  int y;
  x = readdata(sizeof(int), &y, false);
  if (x != (1))
    return (x);
  x = readdata(sizeof(int), &y, true);
  if (x != (1))
    return (x);
  *count = byteswap(y);
  return ((1));
}


x86 assembly (clang, -O0):
<prereadcount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x4,%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1030 <readdata@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1154 <prereadcount+0x34>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <prereadcount+0x76>
mov    $0x4,%edi
lea    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <readdata@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     117f <prereadcount+0x5f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <prereadcount+0x76>
mov    -0x18(%rbp),%edi
call   1040 <byteswap@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prereadcount>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
mov    $0x4,%edi
xor    %edx,%edx
call   1030 <readdata@plt>
cmp    $0x1,%eax
jne    1167 <prereadcount+0x47>
lea    0xc(%rsp),%rsi
mov    $0x4,%edi
mov    $0x1,%edx
call   1030 <readdata@plt>
cmp    $0x1,%eax
jne    1167 <prereadcount+0x47>
mov    0xc(%rsp),%edi
call   1040 <byteswap@plt>
mov    %eax,(%rbx)
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @prereadcount(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = call i32 @readdata(i32 4, i32* %5, i32 0)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i32, i32* %4
store i32 %10, i32* %2
br label %21
11: ; preds = %1
%12 = call i32 @readdata(i32 4, i32* %5, i32 1)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i32, i32* %4
store i32 %16, i32* %2
br label %21
17: ; preds = %11
%18 = load i32, i32* %5
%19 = call i32 @byteswap(i32 %18)
%20 = load i32*, i32** %3
store i32 %19, i32* %20
store i32 1, i32* %2
br label %21
21: ; preds = %17, %15, %9
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
define i32 @prereadcount(i32* nocapture writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @readdata(i32 4, i32* %2, i32 0)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = call i32 @readdata(i32 4, i32* %2, i32 1)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i32 @byteswap(i32 %10)
store i32 %11, i32* %0
br label %12
12: ; preds = %6, %1, %9
%13 = phi i32 [ 1, %9 ], [ %4, %1 ], [ %7, %6 ]
ret i32 %13
}