#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 analyzePartitions(int *, int, int /*<<< orphan*/ *);
char *dec2hex(char);
int /*<<< orphan*/ end_of_sector_marker(char *, int /*<<< orphan*/ *);
void parsePartitionEntries(char *masterbootrec, FILE *outputptr) {
  int partitionentry1[16] = {};
  int partitionentry2[16] = {};
  int partitionentry3[16] = {};
  int partitionentry4[16] = {};
  int ptnum1 = 1;
  int ptnum2 = 2;
  int ptnum3 = 3;
  int ptnum4 = 4;
  int rtn = 0;
  char *hexvalue_p1;
  int i = 0;
  int counter = -1;
  for (i = 446; i < 446 + 16; i++) {
    counter++;
    hexvalue_p1 = dec2hex(masterbootrec[i] & 0xff);
    partitionentry1[counter] = masterbootrec[i] & 0xff;
    partitionentry2[counter] = masterbootrec[i + 16] & 0xff;
    partitionentry3[counter] = masterbootrec[i + 32] & 0xff;
    partitionentry4[counter] = masterbootrec[i + 48] & 0xff;
  }
  rtn = analyzePartitions(partitionentry1, ptnum1, outputptr);
  rtn = analyzePartitions(partitionentry2, ptnum2, outputptr);
  rtn = analyzePartitions(partitionentry3, ptnum3, outputptr);
  rtn = analyzePartitions(partitionentry4, ptnum4, outputptr);
  end_of_sector_marker(masterbootrec, outputptr);
  return;
}


x86 assembly (clang, -O0):
<parsePartitionEntries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movl   $0x1,-0x114(%rbp)
movl   $0x2,-0x118(%rbp)
movl   $0x3,-0x11c(%rbp)
movl   $0x4,-0x120(%rbp)
movl   $0x0,-0x124(%rbp)
movl   $0x0,-0x134(%rbp)
movl   $0xffffffff,-0x138(%rbp)
ff ff ff
movl   $0x1be,-0x134(%rbp)
cmpl   $0x1ce,-0x134(%rbp)
jge    12da <parsePartitionEntries+0x19a>
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xff,%eax
movsbl %al,%edi
call   1060 <dec2hex@plt>
mov    %rax,-0x130(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
and    $0xff,%ecx
movslq -0x138(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
mov    -0x134(%rbp),%ecx
add    $0x10,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
and    $0xff,%ecx
movslq -0x138(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
mov    -0x134(%rbp),%ecx
add    $0x20,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
and    $0xff,%ecx
movslq -0x138(%rbp),%rax
mov    %ecx,-0xd0(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
mov    -0x134(%rbp),%ecx
add    $0x30,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
and    $0xff,%ecx
movslq -0x138(%rbp),%rax
mov    %ecx,-0x110(%rbp,%rax,4)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    11ec <parsePartitionEntries+0xac>
lea    -0x50(%rbp),%rdi
mov    -0x114(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <analyzePartitions@plt>
mov    %eax,-0x124(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x118(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <analyzePartitions@plt>
mov    %eax,-0x124(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x11c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <analyzePartitions@plt>
mov    %eax,-0x124(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x120(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <analyzePartitions@plt>
mov    %eax,-0x124(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <end_of_sector_marker@plt>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsePartitionEntries>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0x1be(%rdi),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1050 <dec2hex@plt>
movzbl (%r12,%rbx,1),%eax
mov    %eax,0xc0(%rsp,%rbx,4)
movzbl 0x10(%r12,%rbx,1),%eax
mov    %eax,0x80(%rsp,%rbx,4)
movzbl 0x20(%r12,%rbx,1),%eax
mov    %eax,0x40(%rsp,%rbx,4)
movzbl 0x30(%r12,%rbx,1),%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x10,%rbx
jne    11c0 <parsePartitionEntries+0x90>
lea    0xc0(%rsp),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1040 <analyzePartitions@plt>
lea    0x80(%rsp),%rdi
mov    $0x2,%esi
mov    %r15,%rdx
call   1040 <analyzePartitions@plt>
lea    0x40(%rsp),%rdi
mov    $0x3,%esi
mov    %r15,%rdx
call   1040 <analyzePartitions@plt>
mov    %rsp,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
call   1040 <analyzePartitions@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <end_of_sector_marker@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @parsePartitionEntries(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [16 x i32]
%6 = alloca [16 x i32]
%7 = alloca [16 x i32]
%8 = alloca [16 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%17 = bitcast [16 x i32]* %5 to i8*
%18 = bitcast [16 x i32]* %6 to i8*
%19 = bitcast [16 x i32]* %7 to i8*
%20 = bitcast [16 x i32]* %8 to i8*
store i32 1, i32* %9
store i32 2, i32* %10
store i32 3, i32* %11
store i32 4, i32* %12
store i32 0, i32* %13
store i32 0, i32* %15
store i32 -1, i32* %16
store i32 446, i32* %15
br label %21
21: ; preds = %79, %2
%22 = load i32, i32* %15
%23 = icmp slt i32 %22, 462
br i1 %23, label %24, label %82
24: ; preds = %21
%25 = load i32, i32* %16
%26 = add nsw i32 %25, 1
store i32 %26, i32* %16
%27 = load i8*, i8** %3
%28 = load i32, i32* %15
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = and i32 %32, 255
%34 = trunc i32 %33 to i8
%35 = call i8* @dec2hex(i8 signext %34)
store i8* %35, i8** %14
%36 = load i8*, i8** %3
%37 = load i32, i32* %15
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = and i32 %41, 255
%43 = load i32, i32* %16
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %44
store i32 %42, i32* %45
%46 = load i8*, i8** %3
%47 = load i32, i32* %15
%48 = add nsw i32 %47, 16
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %46, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = and i32 %52, 255
%54 = load i32, i32* %16
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 %55
store i32 %53, i32* %56
%57 = load i8*, i8** %3
%58 = load i32, i32* %15
%59 = add nsw i32 %58, 32
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %57, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = and i32 %63, 255
%65 = load i32, i32* %16
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 %66
store i32 %64, i32* %67
%68 = load i8*, i8** %3
%69 = load i32, i32* %15
%70 = add nsw i32 %69, 48
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %68, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = and i32 %74, 255
%76 = load i32, i32* %16
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 %77
store i32 %75, i32* %78
br label %79
79: ; preds = %24
%80 = load i32, i32* %15
%81 = add nsw i32 %80, 1
store i32 %81, i32* %15
br label %21
82: ; preds = %21
%83 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%84 = load i32, i32* %9
%85 = load i32*, i32** %4
%86 = call i32 @analyzePartitions(i32* %83, i32 %84, i32* %85)
store i32 %86, i32* %13
%87 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%88 = load i32, i32* %10
%89 = load i32*, i32** %4
%90 = call i32 @analyzePartitions(i32* %87, i32 %88, i32* %89)
store i32 %90, i32* %13
%91 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%92 = load i32, i32* %11
%93 = load i32*, i32** %4
%94 = call i32 @analyzePartitions(i32* %91, i32 %92, i32* %93)
store i32 %94, i32* %13
%95 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%96 = load i32, i32* %12
%97 = load i32*, i32** %4
%98 = call i32 @analyzePartitions(i32* %95, i32 %96, i32* %97)
store i32 %98, i32* %13
%99 = load i8*, i8** %3
%100 = load i32*, i32** %4
%101 = call i32 @end_of_sector_marker(i8* %99, i32* %100)
ret void
}

LLVM IR (-O2):
define void @parsePartitionEntries(i8* %0, i32* %1) {
%3 = alloca [16 x i32]
%4 = alloca [16 x i32]
%5 = alloca [16 x i32]
%6 = alloca [16 x i32]
%7 = bitcast [16 x i32]* %3 to i8*
%8 = bitcast [16 x i32]* %4 to i8*
%9 = bitcast [16 x i32]* %5 to i8*
%10 = bitcast [16 x i32]* %6 to i8*
br label %11
11: ; preds = %2, %11
%12 = phi i64 [ 446, %2 ], [ %36, %11 ]
%13 = phi i64 [ -1, %2 ], [ %14, %11 ]
%14 = add nsw i64 %13, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %12
%16 = load i8, i8* %15
%17 = tail call i8* @dec2hex(i8 signext %16)
%18 = load i8, i8* %15
%19 = zext i8 %18 to i32
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %14
store i32 %19, i32* %20
%21 = add nuw nsw i64 %12, 16
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %14
store i32 %24, i32* %25
%26 = add nuw nsw i64 %12, 32
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %14
store i32 %29, i32* %30
%31 = add nuw nsw i64 %12, 48
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 %14
store i32 %34, i32* %35
%36 = add nuw nsw i64 %12, 1
%37 = icmp eq i64 %36, 462
br i1 %37, label %38, label %11
38: ; preds = %11
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%40 = call i32 @analyzePartitions(i32* %39, i32 1, i32* %1)
%41 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%42 = call i32 @analyzePartitions(i32* %41, i32 2, i32* %1)
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%44 = call i32 @analyzePartitions(i32* %43, i32 3, i32* %1)
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%46 = call i32 @analyzePartitions(i32* %45, i32 4, i32* %1)
%47 = call i32 @end_of_sector_marker(i8* %0, i32* %1)
ret void
}