#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*/ fd_readwrite(int, int /*<<< orphan*/, int, int, int, char *);
void get_os_sectors(int fd, char *buffer) {
  int track = 0;
  fd_readwrite(fd, 0, track, 0, 5120, buffer);
  fd_readwrite(fd, 0, track, 5, 512, buffer + 5120);
  track++;
  fd_readwrite(fd, 0, track, 0, 5120, buffer + 5632);
  fd_readwrite(fd, 0, track, 5, 512, buffer + 10752);
  track++;
  for (; track <= 11; track++) {
    fd_readwrite(fd, 0, track, 5, 512, buffer + 10240 + (512 * track));
  }
}


x86 assembly (clang, -O0):
<get_os_sectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%r9
xor    %ecx,%ecx
mov    $0x1400,%r8d
mov    %ecx,%esi
call   1030 <fd_readwrite@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%r9
add    $0x1400,%r9
xor    %esi,%esi
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%r9
add    $0x1600,%r9
xor    %ecx,%ecx
mov    $0x1400,%r8d
mov    %ecx,%esi
call   1030 <fd_readwrite@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%r9
add    $0x2a00,%r9
xor    %esi,%esi
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xb,-0x14(%rbp)
jg     11fd <get_os_sectors+0xed>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%r9
add    $0x2800,%r9
mov    -0x14(%rbp),%eax
shl    $0x9,%eax
cltq
add    %rax,%r9
xor    %esi,%esi
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b7 <get_os_sectors+0xa7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_os_sectors>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x1400,%r8d
mov    %rbx,%r9
call   1030 <fd_readwrite@plt>
lea    0x1400(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x1600(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x1400,%r8d
call   1030 <fd_readwrite@plt>
lea    0x2a00(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x2c00(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x2e00(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3000(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x4,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3200(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x5,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3400(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x6,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3600(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x7,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3800(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x8,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3a00(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0x9,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
lea    0x3c00(%rbx),%r9
mov    %ebp,%edi
xor    %esi,%esi
mov    $0xa,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
call   1030 <fd_readwrite@plt>
add    $0x3e00,%rbx
mov    %ebp,%edi
xor    %esi,%esi
mov    $0xb,%edx
mov    $0x5,%ecx
mov    $0x200,%r8d
mov    %rbx,%r9
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fd_readwrite@plt>

LLVM IR (-O0):
define void @get_os_sectors(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = load i32, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @fd_readwrite(i32 %6, i32 0, i32 %7, i32 0, i32 5120, i8* %8)
%10 = load i32, i32* %3
%11 = load i32, i32* %5
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 5120
%14 = call i32 @fd_readwrite(i32 %10, i32 0, i32 %11, i32 5, i32 512, i8* %13)
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 5632
%21 = call i32 @fd_readwrite(i32 %17, i32 0, i32 %18, i32 0, i32 5120, i8* %20)
%22 = load i32, i32* %3
%23 = load i32, i32* %5
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 10752
%26 = call i32 @fd_readwrite(i32 %22, i32 0, i32 %23, i32 5, i32 512, i8* %25)
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %29
29: ; preds = %42, %2
%30 = load i32, i32* %5
%31 = icmp sle i32 %30, 11
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = load i32, i32* %3
%34 = load i32, i32* %5
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 10240
%37 = load i32, i32* %5
%38 = mul nsw i32 512, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
%41 = call i32 @fd_readwrite(i32 %33, i32 0, i32 %34, i32 5, i32 512, i8* %40)
br label %42
42: ; preds = %32
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %29
45: ; preds = %29
ret void
}

LLVM IR (-O2):
define void @get_os_sectors(i32 %0, i8* %1) {
%3 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 0, i32 0, i32 5120, i8* %1)
%4 = getelementptr inbounds i8, i8* %1, i64 5120
%5 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 0, i32 5, i32 512, i8* %4)
%6 = getelementptr inbounds i8, i8* %1, i64 5632
%7 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 1, i32 0, i32 5120, i8* %6)
%8 = getelementptr inbounds i8, i8* %1, i64 10752
%9 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 1, i32 5, i32 512, i8* %8)
%10 = getelementptr inbounds i8, i8* %1, i64 11264
%11 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 2, i32 5, i32 512, i8* %10)
%12 = getelementptr inbounds i8, i8* %1, i64 11776
%13 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 3, i32 5, i32 512, i8* %12)
%14 = getelementptr inbounds i8, i8* %1, i64 12288
%15 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 4, i32 5, i32 512, i8* %14)
%16 = getelementptr inbounds i8, i8* %1, i64 12800
%17 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 5, i32 5, i32 512, i8* %16)
%18 = getelementptr inbounds i8, i8* %1, i64 13312
%19 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 6, i32 5, i32 512, i8* %18)
%20 = getelementptr inbounds i8, i8* %1, i64 13824
%21 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 7, i32 5, i32 512, i8* %20)
%22 = getelementptr inbounds i8, i8* %1, i64 14336
%23 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 8, i32 5, i32 512, i8* %22)
%24 = getelementptr inbounds i8, i8* %1, i64 14848
%25 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 9, i32 5, i32 512, i8* %24)
%26 = getelementptr inbounds i8, i8* %1, i64 15360
%27 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 10, i32 5, i32 512, i8* %26)
%28 = getelementptr inbounds i8, i8* %1, i64 15872
%29 = tail call i32 @fd_readwrite(i32 %0, i32 0, i32 11, i32 5, i32 512, i8* %28)
ret void
}