#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 /*<<< orphan*/ SEEK_CUR;
scalar_t__ fseeko(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
char *getRecord(FILE *handle, int n, int x0) {
  int ii, m, n1, n2, x = 0, offset = 0;
  n1 = 0;
  n2 = n;
  for (ii = 0; ii < n; ii++) {
    m = (n2 + n1) / 2;
    if (fseeko(handle, offset, SEEK_CUR) != 0)
      printf("error in fseeko\n");
    if (x0 >= x)
      n1 = m;
    if (x0 < x)
      n2 = m;
    if ((n2 - n1) == 1)
      break;
  }
  return (NULL);
}


x86 assembly (clang, -O0):
<getRecord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e7 <getRecord+0xc7>
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
call   1040 <fseeko@plt>
cmp    $0x0,%rax
je     119c <getRecord+0x7c>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     11ae <getRecord+0x8e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11c0 <getRecord+0xa0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    $0x1,%eax
jne    11d4 <getRecord+0xb4>
jmp    11e7 <getRecord+0xc7>
jmp    11d9 <getRecord+0xb9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <getRecord+0x34>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRecord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
test   %esi,%esi
jle    11a8 <getRecord+0x88>
mov    %esi,%ebp
mov    %rdi,%r12
xor    %ebx,%ebx
mov    $0x1,%r15d
mov    %esi,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%rbx,%r13,1),%eax
mov    %eax,%r14d
shr    $0x1f,%r14d
add    %eax,%r14d
sar    %r14d
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <fseeko@plt>
test   %rax,%rax
je     1185 <getRecord+0x65>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
cmovns %r14d,%ebx
cmovs  %r14d,%r13d
mov    %r13d,%eax
sub    %ebx,%eax
cmp    $0x1,%eax
je     11a8 <getRecord+0x88>
lea    0x1(%r15),%eax
cmp    %ebp,%r15d
mov    %eax,%r15d
jl     1150 <getRecord+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@.str = [17 x i8] c"error in fseeko\0A\00"
define i8* @getRecord(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %9
%13 = load i32, i32* %5
store i32 %13, i32* %10
store i32 0, i32* %7
br label %14
14: ; preds = %49, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %52
18: ; preds = %14
%19 = load i32, i32* %10
%20 = load i32, i32* %9
%21 = add nsw i32 %19, %20
%22 = sdiv i32 %21, 2
store i32 %22, i32* %8
%23 = load i32*, i32** %4
%24 = load i32, i32* %12
%25 = load i32, i32* @SEEK_CUR
%26 = call i64 @fseeko(i32* %23, i32 %24, i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %18
%29 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28, %18
%31 = load i32, i32* %6
%32 = load i32, i32* %11
%33 = icmp sge i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %8
store i32 %35, i32* %9
br label %36
36: ; preds = %34, %30
%37 = load i32, i32* %6
%38 = load i32, i32* %11
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = load i32, i32* %8
store i32 %41, i32* %10
br label %42
42: ; preds = %40, %36
%43 = load i32, i32* %10
%44 = load i32, i32* %9
%45 = sub nsw i32 %43, %44
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %48
47: ; preds = %42
br label %52
48: ; preds = %42
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %14
52: ; preds = %47, %14
ret i8* null
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@str = [16 x i8] c"error in fseeko\00"
define noalias i8* @getRecord(i32* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %27
5: ; preds = %3
%6 = icmp sgt i32 %2, -1
%7 = icmp slt i32 %2, 0
br label %8
8: ; preds = %19, %5
%9 = phi i32 [ 0, %5 ], [ %24, %19 ]
%10 = phi i32 [ 0, %5 ], [ %20, %19 ]
%11 = phi i32 [ %1, %5 ], [ %21, %19 ]
%12 = add nsw i32 %10, %11
%13 = sdiv i32 %12, 2
%14 = load i32, i32* @SEEK_CUR
%15 = tail call i64 @fseeko(i32* %0, i32 0, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %8
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %17, %8
%20 = select i1 %6, i32 %13, i32 %10
%21 = select i1 %7, i32 %13, i32 %11
%22 = sub nsw i32 %21, %20
%23 = icmp ne i32 %22, 1
%24 = add nuw nsw i32 %9, 1
%25 = icmp slt i32 %24, %1
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %8, label %27
27: ; preds = %19, %3
ret i8* null
}