#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 */
struct io_file {
  int dummy;
};

/* Variables and functions */
int io_in(struct io_file *, int, unsigned char *, int);
int io_in_i4(struct io_file *f, int pos, int *i) {
  unsigned char x[4];
  const int r = io_in(f, pos, x, sizeof x);
  if (i)
    *i = (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3];
  return r;
}


x86 assembly (clang, -O0):
<io_in_i4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x1c(%rbp),%rdx
mov    $0x4,%ecx
call   1030 <io_in@plt>
mov    %eax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116b <io_in_i4+0x5b>
movzbl -0x1c(%rbp),%ecx
shl    $0x18,%ecx
movzbl -0x1b(%rbp),%eax
shl    $0x10,%eax
or     %eax,%ecx
movzbl -0x1a(%rbp),%eax
shl    $0x8,%eax
or     %eax,%ecx
movzbl -0x19(%rbp),%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<io_in_i4>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
lea    0xc(%rsp),%rdx
mov    $0x4,%ecx
call   1030 <io_in@plt>
test   %rbx,%rbx
je     1134 <io_in_i4+0x24>
mov    0xc(%rsp),%ecx
bswap  %ecx
mov    %ecx,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.io_file = type { i32 }
define i32 @io_in_i4(%struct.io_file* %0, i32 %1, i32* writeonly %2) {
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = call i32 @io_in(%struct.io_file* %0, i32 %1, i8* %5, i32 4)
%7 = icmp eq i32* %2, null
br i1 %7, label %26, label %8
8: ; preds = %3
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = shl nuw i32 %10, 24
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 16
%16 = or i32 %15, %11
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw nsw i32 %19, 8
%21 = or i32 %16, %20
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = or i32 %21, %24
store i32 %25, i32* %2
br label %26
26: ; preds = %8, %3
ret i32 %6
}