#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 */
unsigned long partition_start_sector(int /*<<< orphan*/ *);
int write_data(int /*<<< orphan*/ *, int, unsigned char *, int);
int write_partition_start_sector_number(FILE *fp) {
  unsigned char aucBuf[4];
  unsigned long l = partition_start_sector(fp);
  if (!l)
    return 0;
  aucBuf[0] = (unsigned char)(l & 0xff);
  aucBuf[1] = (unsigned char)((l & 0xff00) >> 8);
  aucBuf[2] = (unsigned char)((l & 0xff0000) >> 16);
  aucBuf[3] = (unsigned char)((l & 0xff000000) >> 24);
  return write_data(fp, 0x1c, aucBuf, 4);
}


x86 assembly (clang, -O0):
<write_partition_start_sector_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <partition_start_sector@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1150 <write_partition_start_sector_number+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11ae <write_partition_start_sector_number+0x8e>
mov    -0x20(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x14(%rbp)
mov    -0x20(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %al,-0x13(%rbp)
mov    -0x20(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %al,-0x12(%rbp)
movabs $0xff000000,%rax
and    -0x20(%rbp),%rax
shr    $0x18,%rax
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rdx
mov    $0x1c,%esi
mov    $0x4,%ecx
call   1040 <write_data@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_partition_start_sector_number>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <partition_start_sector@plt>
test   %rax,%rax
je     114f <write_partition_start_sector_number+0x2f>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x1c,%esi
mov    $0x4,%ecx
call   1040 <write_data@plt>
jmp    1151 <write_partition_start_sector_number+0x31>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @write_partition_start_sector_number(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [4 x i8]
%5 = alloca i64
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i64 @partition_start_sector(i32* %6)
store i64 %7, i64* %5
%8 = load i64, i64* %5
%9 = icmp ne i64 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %34
11: ; preds = %1
%12 = load i64, i64* %5
%13 = and i64 %12, 255
%14 = trunc i64 %13 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
store i8 %14, i8* %15
%16 = load i64, i64* %5
%17 = and i64 %16, 65280
%18 = lshr i64 %17, 8
%19 = trunc i64 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
store i8 %19, i8* %20
%21 = load i64, i64* %5
%22 = and i64 %21, 16711680
%23 = lshr i64 %22, 16
%24 = trunc i64 %23 to i8
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
store i8 %24, i8* %25
%26 = load i64, i64* %5
%27 = and i64 %26, 4278190080
%28 = lshr i64 %27, 24
%29 = trunc i64 %28 to i8
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
store i8 %29, i8* %30
%31 = load i32*, i32** %3
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%33 = call i32 @write_data(i32* %31, i32 28, i8* %32, i32 4)
store i32 %33, i32* %2
br label %34
34: ; preds = %11, %10
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @write_partition_start_sector_number(i32* %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @partition_start_sector(i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %1
%7 = trunc i64 %4 to i8
store i8 %7, i8* %3
%8 = lshr i64 %4, 8
%9 = trunc i64 %8 to i8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
store i8 %9, i8* %10
%11 = lshr i64 %4, 16
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
store i8 %12, i8* %13
%14 = lshr i64 %4, 24
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
store i8 %15, i8* %16
%17 = call i32 @write_data(i32* %0, i32 28, i8* %3, i32 4)
br label %18
18: ; preds = %1, %6
%19 = phi i32 [ %17, %6 ], [ 0, %1 ]
ret i32 %19
}