#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
int read_int_data(FILE *in) {
  int byte = 0, scrap = 0;
  scrap = fgetc(in);
  if (scrap != 0x40) {
    fprintf(stdout, "Cannot find an int type when expecting one!\n");
    return -1;
  }
  byte = fgetc(in) << 24;
  byte += fgetc(in) << 16;
  byte += fgetc(in) << 8;
  byte += fgetc(in);
  return byte;
}


x86 assembly (clang, -O0):
<read_int_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x40,-0x18(%rbp)
je     1171 <read_int_data+0x51>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b9 <read_int_data+0x99>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
shl    $0x18,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
shl    $0x10,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
shl    $0x8,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_int_data>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <fgetc@plt>
cmp    $0x40,%eax
jne    116e <read_int_data+0x4e>
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r14d
shl    $0x18,%r14d
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
add    %r14d,%ebp
mov    %r15,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
shl    $0x8,%ebx
add    %ebp,%ebx
mov    %r15,%rdi
call   1030 <fgetc@plt>
add    %ebx,%eax
jmp    1188 <read_int_data+0x68>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [45 x i8] c"Cannot find an int type when expecting one!\0A\00"
define i32 @read_int_data(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i32*, i32** %3
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 64
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %32
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = call i32 @fgetc(i32* %14)
%16 = shl i32 %15, 24
store i32 %16, i32* %4
%17 = load i32*, i32** %3
%18 = call i32 @fgetc(i32* %17)
%19 = shl i32 %18, 16
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
%22 = load i32*, i32** %3
%23 = call i32 @fgetc(i32* %22)
%24 = shl i32 %23, 8
%25 = load i32, i32* %4
%26 = add nsw i32 %25, %24
store i32 %26, i32* %4
%27 = load i32*, i32** %3
%28 = call i32 @fgetc(i32* %27)
%29 = load i32, i32* %4
%30 = add nsw i32 %29, %28
store i32 %30, i32* %4
%31 = load i32, i32* %4
store i32 %31, i32* %2
br label %32
32: ; preds = %13, %10
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [45 x i8] c"Cannot find an int type when expecting one!\0A\00"
define i32 @read_int_data(i32* nocapture %0) {
%2 = tail call i32 @fgetc(i32* %0)
%3 = icmp eq i32 %2, 64
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* @stdout
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %18
7: ; preds = %1
%8 = tail call i32 @fgetc(i32* %0)
%9 = shl i32 %8, 24
%10 = tail call i32 @fgetc(i32* %0)
%11 = shl i32 %10, 16
%12 = add nsw i32 %11, %9
%13 = tail call i32 @fgetc(i32* %0)
%14 = shl i32 %13, 8
%15 = add nsw i32 %12, %14
%16 = tail call i32 @fgetc(i32* %0)
%17 = add nsw i32 %15, %16
br label %18
18: ; preds = %7, %4
%19 = phi i32 [ -1, %4 ], [ %17, %7 ]
ret i32 %19
}