#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 uint8_t;
typedef char uint32_t;

/* Variables and functions */
char EOF;
char getc(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int readop(uint32_t *op) {
  char c;
  uint8_t i;
  for (i = 0; i < 4; i++) {
    c = getc(stdin);
    if (c == EOF) {
      return 0;
    }
    *op |= (c & 0xFF);
    if (i != 3) {
      *op <<= 8;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<readop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    119e <readop+0x8e>
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
call   1030 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    0x2e97(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1160 <readop+0x50>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <readop+0x95>
movsbl -0x11(%rbp),%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
cmpl   $0x3,-0x18(%rbp)
je     118b <readop+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
shl    $0x8,%ecx
mov    %cl,(%rax)
jmp    1190 <readop+0x80>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1123 <readop+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readop>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2ec6(%rip),%r15
mov    (%r15),%edi
call   1030 <getc@plt>
mov    0x2eaf(%rip),%r12
xor    %ebx,%ebx
cmp    (%r12),%al
je     1177 <readop+0x67>
movb   $0x0,(%r14)
mov    (%r15),%edi
call   1030 <getc@plt>
cmp    (%r12),%al
je     1177 <readop+0x67>
movb   $0x0,(%r14)
mov    (%r15),%edi
call   1030 <getc@plt>
cmp    (%r12),%al
je     1177 <readop+0x67>
movb   $0x0,(%r14)
mov    (%r15),%edi
call   1030 <getc@plt>
cmp    (%r12),%al
je     1177 <readop+0x67>
or     %al,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i8 0
define i32 @readop(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
br label %6
6: ; preds = %36, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %39
9: ; preds = %6
%10 = load i32, i32* @stdin
%11 = call signext i8 @getc(i32 %10)
store i8 %11, i8* %4
%12 = load i8, i8* %4
%13 = sext i8 %12 to i32
%14 = load i8, i8* @EOF
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %13, %15
br i1 %16, label %17, label %18
17: ; preds = %9
store i32 0, i32* %2
br label %40
18: ; preds = %9
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = and i32 %20, 255
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = or i32 %24, %21
%26 = trunc i32 %25 to i8
store i8 %26, i8* %22
%27 = load i32, i32* %5
%28 = icmp ne i32 %27, 3
br i1 %28, label %29, label %35
29: ; preds = %18
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = shl i32 %32, 8
%34 = trunc i32 %33 to i8
store i8 %34, i8* %30
br label %35
35: ; preds = %29, %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %6
39: ; preds = %6
store i32 1, i32* %2
br label %40
40: ; preds = %39, %17
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i8 0
define i32 @readop(i8* nocapture %0) {
%2 = load i32, i32* @stdin
%3 = tail call signext i8 @getc(i32 %2)
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %24, label %6
6: ; preds = %1
store i8 0, i8* %0
%7 = load i32, i32* @stdin
%8 = tail call signext i8 @getc(i32 %7)
%9 = load i8, i8* @EOF
%10 = icmp eq i8 %8, %9
br i1 %10, label %24, label %11
11: ; preds = %6
store i8 0, i8* %0
%12 = load i32, i32* @stdin
%13 = tail call signext i8 @getc(i32 %12)
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %13, %14
br i1 %15, label %24, label %16
16: ; preds = %11
store i8 0, i8* %0
%17 = load i32, i32* @stdin
%18 = tail call signext i8 @getc(i32 %17)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = load i8, i8* %0
%23 = or i8 %22, %18
store i8 %23, i8* %0
br label %24
24: ; preds = %21, %16, %11, %6, %1
%25 = phi i32 [ 0, %1 ], [ 0, %6 ], [ 0, %11 ], [ 0, %16 ], [ 1, %21 ]
ret i32 %25
}