#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*/ uint8_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int bufToInt32(int /*<<< orphan*/ *);
int readTag(int, char *, int /*<<< orphan*/ *, int);
int getSector(int entId, int *xyz) {
  uint8_t buffer[1024];
  int len = readTag(entId, "sector", buffer, sizeof(buffer));
  if (len < 4 * 3)
    return 0;
  uint8_t *pnt = buffer;
  xyz[0] = bufToInt32(pnt);
  xyz[1] = bufToInt32(pnt + 4);
  xyz[2] = bufToInt32(pnt + 8);
  return 1;
}


x86 assembly (clang, -O0):
<getSector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x1010(%rbp),%rdx
lea    0xebd(%rip),%rsi
mov    $0x1000,%ecx
call   1030 <readTag@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0xc,-0x1014(%rbp)
jge    116c <getSector+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <getSector+0xa7>
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1020(%rbp)
mov    -0x1020(%rbp),%rdi
call   1040 <bufToInt32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1020(%rbp),%rdi
add    $0x10,%rdi
call   1040 <bufToInt32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1020(%rbp),%rdi
add    $0x20,%rdi
call   1040 <bufToInt32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSector>:
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%rbx
lea    0xece(%rip),%rsi
mov    %rsp,%rdx
mov    $0x1000,%ecx
call   1030 <readTag@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xc,%ecx
jl     1171 <getSector+0x51>
mov    %rsp,%rdi
call   1040 <bufToInt32@plt>
mov    %eax,(%rbx)
lea    0x10(%rsp),%rdi
call   1040 <bufToInt32@plt>
mov    %eax,0x4(%rbx)
lea    0x20(%rsp),%rdi
call   1040 <bufToInt32@plt>
mov    %eax,0x8(%rbx)
mov    $0x1,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"sector\00"
define i32 @getSector(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [1024 x i32]
%7 = alloca i32
%8 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
%9 = load i32, i32* %4
%10 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 0
%11 = call i32 @readTag(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %10, i32 4096)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 12
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %31
15: ; preds = %2
%16 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 0
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = call i32 @bufToInt32(i32* %17)
%19 = load i32*, i32** %5
%20 = getelementptr inbounds i32, i32* %19, i64 0
store i32 %18, i32* %20
%21 = load i32*, i32** %8
%22 = getelementptr inbounds i32, i32* %21, i64 4
%23 = call i32 @bufToInt32(i32* %22)
%24 = load i32*, i32** %5
%25 = getelementptr inbounds i32, i32* %24, i64 1
store i32 %23, i32* %25
%26 = load i32*, i32** %8
%27 = getelementptr inbounds i32, i32* %26, i64 8
%28 = call i32 @bufToInt32(i32* %27)
%29 = load i32*, i32** %5
%30 = getelementptr inbounds i32, i32* %29, i64 2
store i32 %28, i32* %30
store i32 1, i32* %3
br label %31
31: ; preds = %15, %14
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [7 x i8] c"sector\00"
define i32 @getSector(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca [1024 x i32]
%4 = bitcast [1024 x i32]* %3 to i8*
%5 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
%6 = call i32 @readTag(i32 %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %5, i32 4096)
%7 = icmp slt i32 %6, 12
br i1 %7, label %16, label %8
8: ; preds = %2
%9 = call i32 @bufToInt32(i32* %5)
store i32 %9, i32* %1
%10 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 4
%11 = call i32 @bufToInt32(i32* %10)
%12 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %11, i32* %12
%13 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 8
%14 = call i32 @bufToInt32(i32* %13)
%15 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %14, i32* %15
br label %16
16: ; preds = %2, %8
%17 = phi i32 [ 1, %8 ], [ 0, %2 ]
ret i32 %17
}