#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 write_data(int /*<<< orphan*/ *, int, unsigned char *, int);
int write_partition_start_sector_number(FILE *fp, int iStartSector) {
  unsigned char aucBuf[4];
  unsigned long l = (unsigned long)iStartSector;
  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    %esi,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    113e <write_partition_start_sector_number+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    119c <write_partition_start_sector_number+0x8c>
mov    -0x20(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x18(%rbp)
mov    -0x20(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %al,-0x17(%rbp)
mov    -0x20(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %al,-0x16(%rbp)
movabs $0xff000000,%rax
and    -0x20(%rbp),%rax
shr    $0x18,%rax
mov    %al,-0x15(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rdx
mov    $0x1c,%esi
mov    $0x4,%ecx
call   1030 <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>:
test   %esi,%esi
je     1132 <write_partition_start_sector_number+0x22>
push   %rax
mov    %esi,0x4(%rsp)
lea    0x4(%rsp),%rdx
mov    $0x1c,%esi
mov    $0x4,%ecx
call   1030 <write_data@plt>
add    $0x8,%rsp
ret
xor    %eax,%eax
ret

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

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