#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 int64_t;
typedef scalar_t__ int32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ bot_fileutils_fread32(int /*<<< orphan*/ *, scalar_t__ *);
int bot_fileutils_fread64(FILE *f, int64_t *v64) {
  int32_t v1, v2;
  if (bot_fileutils_fread32(f, &v1))
    return -1;
  if (bot_fileutils_fread32(f, &v2))
    return -1;
  *v64 = (((int64_t)v1) << 32) | (((int64_t)v2) & 0xffffffff);
  return 0;
}


x86 assembly (clang, -O0):
<bot_fileutils_fread64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <bot_fileutils_fread32@plt>
cmp    $0x0,%rax
je     1143 <bot_fileutils_fread64+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    1189 <bot_fileutils_fread64+0x79>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <bot_fileutils_fread32@plt>
cmp    $0x0,%rax
je     1166 <bot_fileutils_fread64+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    1189 <bot_fileutils_fread64+0x79>
mov    -0x20(%rbp),%rax
mov    $0x20,%ecx
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
and    $0xffffffff,%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_fileutils_fread64>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <bot_fileutils_fread32@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    113f <bot_fileutils_fread64+0x2f>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <bot_fileutils_fread32@plt>
neg    %rax
sbb    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @bot_fileutils_fread64(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = load i32*, i32** %4
%9 = call i64 @bot_fileutils_fread32(i32* %8, i64* %6)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %26
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = call i64 @bot_fileutils_fread32(i32* %13, i64* %7)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %3
br label %26
17: ; preds = %12
%18 = load i64, i64* %6
%19 = trunc i64 %18 to i32
%20 = shl i32 %19, 32
%21 = load i64, i64* %7
%22 = trunc i64 %21 to i32
%23 = and i32 %22, -1
%24 = or i32 %20, %23
%25 = load i32*, i32** %5
store i32 %24, i32* %25
store i32 0, i32* %3
br label %26
26: ; preds = %17, %16, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @bot_fileutils_fread64(i32* %0, i32* nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = call i64 @bot_fileutils_fread32(i32* %0, i64* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = call i64 @bot_fileutils_fread32(i32* %0, i64* %4)
%11 = icmp ne i64 %10, 0
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %9, %2
%14 = phi i32 [ -1, %2 ], [ %12, %9 ]
ret i32 %14
}