#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int inode_to_block(int inode) {
  int blockgroup;
  int inode_in_block;
  int blocknum;
  if (inode == -1) {
    fprintf(stderr, "Internal error: bad inode %d\n", inode);
    exit(2);
  }
  blockgroup = inode / 64;
  inode_in_block = inode % 64;
  blocknum = (blockgroup * 256) + 1 + inode_in_block / (512 / 64);
  return blocknum;
}


x86 assembly (clang, -O0):
<inode_to_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1157 <inode_to_block+0x37>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xeb8(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>
mov    -0x4(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x8,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inode_to_block>:
cmp    $0xffffffff,%edi
je     1151 <inode_to_block+0x31>
lea    0x3f(%rdi),%eax
test   %edi,%edi
cmovns %edi,%eax
mov    %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%edi
sar    $0x6,%eax
shl    $0x8,%eax
mov    %edi,%ecx
sar    $0x7,%cl
shr    $0x5,%cl
add    %dil,%cl
sar    $0x3,%cl
movsbl %cl,%ecx
add    %ecx,%eax
add    $0x1,%eax
ret
push   %rax
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
mov    $0xffffffff,%edx
call   1030 <fprintf@plt>
mov    $0x2,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Internal error: bad inode %d\0A\00"
define i32 @inode_to_block(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i32, i32* %2
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @exit(i32 2)
unreachable
13: ; preds = %1
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 64
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = srem i32 %16, 64
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 256
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %4
%22 = sdiv i32 %21, 8
%23 = add nsw i32 %20, %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Internal error: bad inode %d\0A\00"
define i32 @inode_to_block(i32 %0) {
%2 = icmp eq i32 %0, -1
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 -1)
%6 = tail call i32 @exit(i32 2)
unreachable
7: ; preds = %1
%8 = sdiv i32 %0, 64
%9 = srem i32 %0, 64
%10 = shl nsw i32 %8, 8
%11 = or i32 %10, 1
%12 = trunc i32 %9 to i8
%13 = sdiv i8 %12, 8
%14 = sext i8 %13 to i32
%15 = add nsw i32 %11, %14
ret i32 %15
}