#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 */
char *dec2hex(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int validatePartitionType(char *, int /*<<< orphan*/ *);
int analyzePartitions(int p1[], int pnumber, FILE *oPtr) {
  fprintf(oPtr, "\nPARTITION %d:\n", pnumber);
  fprintf(oPtr, "============\n");
  int i = 0;
  int sectors_mbr_partition = 0;
  int isValid = 0;
  char *hexvalue = NULL;
  char *starthead, *systemid, *endhead;
  long total_sectors = 0;
  for (i = 0; i < 16; i++) {
  }
  hexvalue = dec2hex(p1[0] & 0xff);
  if (p1[0] == 128) {
    fprintf(oPtr, "\nPartition %d has an active partition:  0x%s\n", pnumber,
            hexvalue);
  } else {
    fprintf(oPtr, "\nPartition %d does not have an active partition:  0x%s\n",
            pnumber, hexvalue);
  }
  starthead = dec2hex(p1[1]);
  fprintf(oPtr, "Starting Head:\t0x%s (%d)\n", starthead, p1[1]);
  systemid = dec2hex(p1[4]);
  fprintf(oPtr, "System ID:\t0x%s\n", systemid);
  isValid = validatePartitionType(systemid, oPtr);
  if (isValid) {
    fprintf(oPtr, "Partition %d (VALID):  %s\n", pnumber, systemid);
  } else {
    fprintf(oPtr, "Partition %d (NOT VALID):  %s\n", pnumber, systemid);
  }
  endhead = dec2hex(p1[5]);
  fprintf(oPtr, "Ending head:\t0x%s (%d)\n", endhead, p1[5]);
  sectors_mbr_partition = (p1[9] << 8 | p1[8]);
  fprintf(oPtr, "Sectors between MBR and Partition %d:  %d\n", pnumber,
          sectors_mbr_partition);
  total_sectors = (p1[15] << 24 | p1[14] << 16 | p1[13] << 8 | p1[12]);
  fprintf(oPtr, "Total sectors in partition %d:  %ld\n", pnumber,
          total_sectors);
  return 0;
}


x86 assembly (clang, -O0):
<analyzePartitions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11b3 <analyzePartitions+0x83>
jmp    11a5 <analyzePartitions+0x75>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1196 <analyzePartitions+0x66>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
and    $0xff,%edi
call   1050 <dec2hex@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x80,(%rax)
jne    11f6 <analyzePartitions+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    120f <analyzePartitions+0xdf>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1050 <dec2hex@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
call   1050 <dec2hex@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <validatePartitionType@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     129a <analyzePartitions+0x16a>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x40(%rbp),%rcx
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12b3 <analyzePartitions+0x183>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x40(%rbp),%rcx
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edi
call   1050 <dec2hex@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%ecx
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x24(%rax),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
or     0x20(%rcx),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x3c(%rax),%eax
shl    $0x18,%eax
mov    -0x8(%rbp),%rcx
mov    0x38(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
mov    0x34(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
or     0x30(%rcx),%eax
cltq
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x50(%rbp),%rcx
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyzePartitions>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0xea9(%rip),%rsi
mov    %rdx,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xea5(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fwrite@plt>
movzbl 0x0(%rbp),%edi
call   1050 <dec2hex@plt>
cmpl   $0x80,0x0(%rbp)
lea    0xe8a(%rip),%rcx
lea    0xeb1(%rip),%rsi
cmove  %rcx,%rsi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x4(%rbp),%edi
call   1050 <dec2hex@plt>
mov    0x4(%rbp),%ecx
lea    0xec3(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x10(%rbp),%edi
call   1050 <dec2hex@plt>
mov    %rax,%rbx
lea    0xebe(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <validatePartitionType@plt>
test   %eax,%eax
lea    0xec9(%rip),%rax
lea    0xea7(%rip),%rsi
cmove  %rax,%rsi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x14(%rbp),%edi
call   1050 <dec2hex@plt>
mov    0x14(%rbp),%ecx
lea    0xebb(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x24(%rbp),%ecx
shl    $0x8,%ecx
or     0x20(%rbp),%ecx
lea    0xeb6(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x3c(%rbp),%eax
shl    $0x18,%eax
mov    0x34(%rbp),%ecx
mov    0x38(%rbp),%edx
shl    $0x10,%edx
or     %eax,%edx
shl    $0x8,%ecx
or     %edx,%ecx
or     0x30(%rbp),%ecx
movslq %ecx,%rcx
lea    0xeb1(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0APARTITION %d:\0A\00"
@.str.1 = [14 x i8] c"============\0A\00"
@.str.2 = [46 x i8] c"\0APartition %d has an active partition: 0x%s\0A\00"
@.str.3 = [56 x i8] c"\0APartition %d does not have an active partition: 0x%s\0A\00"
@.str.4 = [26 x i8] c"Starting Head:\090x%s (%d)\0A\00"
@.str.5 = [17 x i8] c"System ID:\090x%s\0A\00"
@.str.6 = [27 x i8] c"Partition %d (VALID): %s\0A\00"
@.str.7 = [31 x i8] c"Partition %d (NOT VALID): %s\0A\00"
@.str.8 = [24 x i8] c"Ending head:\090x%s (%d)\0A\00"
@.str.9 = [43 x i8] c"Sectors between MBR and Partition %d: %d\0A\00"
@.str.10 = [37 x i8] c"Total sectors in partition %d: %ld\0A\00"
define i32 @analyzePartitions(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 i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%15 = load i32*, i32** %6
%16 = load i32, i32* %5
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32*, i32** %6
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
store i64 0, i64* %14
store i32 0, i32* %7
br label %20
20: ; preds = %24, %3
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 16
br i1 %22, label %23, label %27
23: ; preds = %20
br label %24
24: ; preds = %23
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %20
27: ; preds = %20
%28 = load i32*, i32** %4
%29 = getelementptr inbounds i32, i32* %28, i64 0
%30 = load i32, i32* %29
%31 = and i32 %30, 255
%32 = call i8* @dec2hex(i32 %31)
store i8* %32, i8** %10
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 0
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 128
br i1 %36, label %37, label %42
37: ; preds = %27
%38 = load i32*, i32** %6
%39 = load i32, i32* %5
%40 = load i8*, i8** %10
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %39, i8* %40)
br label %47
42: ; preds = %27
%43 = load i32*, i32** %6
%44 = load i32, i32* %5
%45 = load i8*, i8** %10
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i32 %44, i8* %45)
br label %47
47: ; preds = %42, %37
%48 = load i32*, i32** %4
%49 = getelementptr inbounds i32, i32* %48, i64 1
%50 = load i32, i32* %49
%51 = call i8* @dec2hex(i32 %50)
store i8* %51, i8** %11
%52 = load i32*, i32** %6
%53 = load i8*, i8** %11
%54 = load i32*, i32** %4
%55 = getelementptr inbounds i32, i32* %54, i64 1
%56 = load i32, i32* %55
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %53, i32 %56)
%58 = load i32*, i32** %4
%59 = getelementptr inbounds i32, i32* %58, i64 4
%60 = load i32, i32* %59
%61 = call i8* @dec2hex(i32 %60)
store i8* %61, i8** %12
%62 = load i32*, i32** %6
%63 = load i8*, i8** %12
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %63)
%65 = load i8*, i8** %12
%66 = load i32*, i32** %6
%67 = call i32 @validatePartitionType(i8* %65, i32* %66)
store i32 %67, i32* %9
%68 = load i32, i32* %9
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %47
%71 = load i32*, i32** %6
%72 = load i32, i32* %5
%73 = load i8*, i8** %12
%74 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i32 %72, i8* %73)
br label %80
75: ; preds = %47
%76 = load i32*, i32** %6
%77 = load i32, i32* %5
%78 = load i8*, i8** %12
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %77, i8* %78)
br label %80
80: ; preds = %75, %70
%81 = load i32*, i32** %4
%82 = getelementptr inbounds i32, i32* %81, i64 5
%83 = load i32, i32* %82
%84 = call i8* @dec2hex(i32 %83)
store i8* %84, i8** %13
%85 = load i32*, i32** %6
%86 = load i8*, i8** %13
%87 = load i32*, i32** %4
%88 = getelementptr inbounds i32, i32* %87, i64 5
%89 = load i32, i32* %88
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %85, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %86, i32 %89)
%91 = load i32*, i32** %4
%92 = getelementptr inbounds i32, i32* %91, i64 9
%93 = load i32, i32* %92
%94 = shl i32 %93, 8
%95 = load i32*, i32** %4
%96 = getelementptr inbounds i32, i32* %95, i64 8
%97 = load i32, i32* %96
%98 = or i32 %94, %97
store i32 %98, i32* %8
%99 = load i32*, i32** %6
%100 = load i32, i32* %5
%101 = load i32, i32* %8
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %100, i32 %101)
%103 = load i32*, i32** %4
%104 = getelementptr inbounds i32, i32* %103, i64 15
%105 = load i32, i32* %104
%106 = shl i32 %105, 24
%107 = load i32*, i32** %4
%108 = getelementptr inbounds i32, i32* %107, i64 14
%109 = load i32, i32* %108
%110 = shl i32 %109, 16
%111 = or i32 %106, %110
%112 = load i32*, i32** %4
%113 = getelementptr inbounds i32, i32* %112, i64 13
%114 = load i32, i32* %113
%115 = shl i32 %114, 8
%116 = or i32 %111, %115
%117 = load i32*, i32** %4
%118 = getelementptr inbounds i32, i32* %117, i64 12
%119 = load i32, i32* %118
%120 = or i32 %116, %119
%121 = sext i32 %120 to i64
store i64 %121, i64* %14
%122 = load i32*, i32** %6
%123 = load i32, i32* %5
%124 = load i64, i64* %14
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %122, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i32 %123, i64 %124)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0APARTITION %d:\0A\00"
@.str.1 = [14 x i8] c"============\0A\00"
@.str.2 = [46 x i8] c"\0APartition %d has an active partition: 0x%s\0A\00"
@.str.3 = [56 x i8] c"\0APartition %d does not have an active partition: 0x%s\0A\00"
@.str.4 = [26 x i8] c"Starting Head:\090x%s (%d)\0A\00"
@.str.5 = [17 x i8] c"System ID:\090x%s\0A\00"
@.str.6 = [27 x i8] c"Partition %d (VALID): %s\0A\00"
@.str.7 = [31 x i8] c"Partition %d (NOT VALID): %s\0A\00"
@.str.8 = [24 x i8] c"Ending head:\090x%s (%d)\0A\00"
@.str.9 = [43 x i8] c"Sectors between MBR and Partition %d: %d\0A\00"
@.str.10 = [37 x i8] c"Total sectors in partition %d: %ld\0A\00"
define i32 @analyzePartitions(i32* nocapture %0, i32 %1, i32* %2) {
%4 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 13, i64 1, i32* %2)
%6 = load i32, i32* %0
%7 = and i32 %6, 255
%8 = tail call i8* @dec2hex(i32 %7)
%9 = load i32, i32* %0
%10 = icmp eq i32 %9, 128
%11 = select i1 %10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0)
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* %11, i32 %1, i8* %8)
%13 = getelementptr inbounds i32, i32* %0, i64 1
%14 = load i32, i32* %13
%15 = tail call i8* @dec2hex(i32 %14)
%16 = load i32, i32* %13
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %15, i32 %16)
%18 = getelementptr inbounds i32, i32* %0, i64 4
%19 = load i32, i32* %18
%20 = tail call i8* @dec2hex(i32 %19)
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %20)
%22 = tail call i32 @validatePartitionType(i8* %20, i32* %2)
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0)
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* %24, i32 %1, i8* %20)
%26 = getelementptr inbounds i32, i32* %0, i64 5
%27 = load i32, i32* %26
%28 = tail call i8* @dec2hex(i32 %27)
%29 = load i32, i32* %26
%30 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %28, i32 %29)
%31 = getelementptr inbounds i32, i32* %0, i64 9
%32 = load i32, i32* %31
%33 = shl i32 %32, 8
%34 = getelementptr inbounds i32, i32* %0, i64 8
%35 = load i32, i32* %34
%36 = or i32 %33, %35
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %1, i32 %36)
%38 = getelementptr inbounds i32, i32* %0, i64 15
%39 = load i32, i32* %38
%40 = shl i32 %39, 24
%41 = getelementptr inbounds i32, i32* %0, i64 14
%42 = load i32, i32* %41
%43 = shl i32 %42, 16
%44 = or i32 %43, %40
%45 = getelementptr inbounds i32, i32* %0, i64 13
%46 = load i32, i32* %45
%47 = shl i32 %46, 8
%48 = or i32 %44, %47
%49 = getelementptr inbounds i32, i32* %0, i64 12
%50 = load i32, i32* %49
%51 = or i32 %48, %50
%52 = sext i32 %51 to i64
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), i32 %1, i64 %52)
ret i32 0
}