#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*/ qread(unsigned char *, char *, int);
int readint(unsigned char *infile) {
  int a, i;
  unsigned char b[4];
  for (i = 0; i < 4; i++)
    qread(infile, (char *)&b[i], 1);
  a = b[0];
  for (i = 1; i < 4; i++)
    a = (a << 8) + b[i];
  return (a);
}


x86 assembly (clang, -O0):
<readint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1154 <readint+0x44>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
lea    -0x14(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <qread@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <readint+0x13>
movzbl -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    118e <readint+0x7e>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
movslq -0x10(%rbp),%rcx
movzbl -0x14(%rbp,%rcx,1),%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <readint+0x52>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readint>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
mov    $0x1,%edx
call   1030 <qread@plt>
lea    0xd(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <qread@plt>
lea    0xe(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <qread@plt>
lea    0xf(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <qread@plt>
mov    0xc(%rsp),%eax
bswap  %eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @readint(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4 x i8]
store i8* %0, i8** %2
store i32 0, i32* %4
br label %6
6: ; preds = %15, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %12
%14 = call i32 @qread(i8* %10, i8* %13, i32 1)
br label %15
15: ; preds = %9
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %6
18: ; preds = %6
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
store i32 %21, i32* %3
store i32 1, i32* %4
br label %22
22: ; preds = %34, %18
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 4
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i32, i32* %3
%27 = shl i32 %26, 8
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = add nsw i32 %27, %32
store i32 %33, i32* %3
br label %34
34: ; preds = %25
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %22
37: ; preds = %22
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @readint(i8* %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32 @qread(i8* %0, i8* %3, i32 1)
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%6 = call i32 @qread(i8* %0, i8* %5, i32 1)
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%8 = call i32 @qread(i8* %0, i8* %7, i32 1)
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%10 = call i32 @qread(i8* %0, i8* %9, i32 1)
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = load i8, i8* %5
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %12, 16
%16 = shl nuw nsw i32 %14, 8
%17 = or i32 %15, %16
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = or i32 %17, %19
%21 = shl nuw i32 %20, 8
%22 = load i8, i8* %9
%23 = zext i8 %22 to i32
%24 = or i32 %21, %23
ret i32 %24
}