#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*/ addBytes(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ changeByte(char *, int, char);
int /*<<< orphan*/ checkFileSize(char *, char *, int);
int /*<<< orphan*/ cleanup();
int /*<<< orphan*/ createZeroFile(char *, int);
int /*<<< orphan*/ syncAndCheckMd4(char *, char *, char *, int, int);
int /*<<< orphan*/ truncate(char *, int);
void testZeroSizedSource(int isSparse) {
  cleanup();
  createZeroFile("testSource.bin", 1024 * 1024 * 5);
  syncAndCheckMd4("zero sized source", "testSource.bin", "testDest.bin",
                  isSparse, 1);
  checkFileSize("zero sized source", "testDest.bin", 1024 * 1024 * 5);
  changeByte("testSource.bin", 5, 'c');
  syncAndCheckMd4("changed byte (zero sized source) ", "testSource.bin",
                  "testDest.bin", isSparse, 1);
  checkFileSize("changed byte (zero sized source) (size)", "testDest.bin",
                1024 * 1024 * 5);
  addBytes("testSource.bin", 1 * 1024 * 1024, 0);
  syncAndCheckMd4("added 1 md (zero sized source) ", "testSource.bin",
                  "testDest.bin", isSparse, 1);
  checkFileSize("added 1 md (zero sized source) (size)", "testDest.bin",
                1024 * 1024 * 6);
  truncate("testSource.bin", 2 * 1024 * 1024);
  syncAndCheckMd4("truncated (zero sized source) ", "testSource.bin",
                  "testDest.bin", isSparse, 1);
  checkFileSize("truncated (zero sized source) (size)", "testDest.bin",
                1024 * 1024 * 2);
}


x86 assembly (clang, -O0):
<testZeroSizedSource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1080 <cleanup@plt>
lea    0xe77(%rip),%rdi
mov    $0x500000,%esi
call   1060 <createZeroFile@plt>
mov    -0x4(%rbp),%ecx
lea    0xe72(%rip),%rdi
lea    0xe5c(%rip),%rsi
lea    0xe76(%rip),%rdx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe52(%rip),%rdi
lea    0xe5d(%rip),%rsi
mov    $0x500000,%edx
call   1030 <checkFileSize@plt>
lea    0xe2b(%rip),%rdi
mov    $0x5,%esi
mov    $0x63,%edx
call   1040 <changeByte@plt>
mov    -0x4(%rbp),%ecx
lea    0xe40(%rip),%rdi
lea    0xe0b(%rip),%rsi
lea    0xe25(%rip),%rdx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe42(%rip),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x500000,%edx
call   1030 <checkFileSize@plt>
lea    0xdda(%rip),%rdi
mov    $0x100000,%esi
xor    %edx,%edx
call   1090 <addBytes@plt>
mov    -0x4(%rbp),%ecx
lea    0xe3c(%rip),%rdi
lea    0xdbd(%rip),%rsi
lea    0xdd7(%rip),%rdx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe3c(%rip),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x600000,%edx
call   1030 <checkFileSize@plt>
lea    0xd8c(%rip),%rdi
mov    $0x200000,%esi
call   1050 <truncate@plt>
mov    -0x4(%rbp),%ecx
lea    0xe36(%rip),%rdi
lea    0xd71(%rip),%rsi
lea    0xd8b(%rip),%rdx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe35(%rip),%rdi
lea    0xd72(%rip),%rsi
mov    $0x200000,%edx
call   1030 <checkFileSize@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testZeroSizedSource>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1080 <cleanup@plt>
lea    0xe78(%rip),%r14
mov    %r14,%rdi
mov    $0x500000,%esi
call   1060 <createZeroFile@plt>
lea    0xe73(%rip),%r12
lea    0xe7e(%rip),%r15
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x500000,%edx
call   1030 <checkFileSize@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0x63,%edx
call   1040 <changeByte@plt>
lea    0xe4c(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe54(%rip),%rdi
mov    %r15,%rsi
mov    $0x500000,%edx
call   1030 <checkFileSize@plt>
mov    %r14,%rdi
mov    $0x100000,%esi
xor    %edx,%edx
call   1090 <addBytes@plt>
lea    0xe59(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe5f(%rip),%rdi
mov    %r15,%rsi
mov    $0x600000,%edx
call   1030 <checkFileSize@plt>
mov    %r14,%rdi
mov    $0x200000,%esi
call   1050 <truncate@plt>
lea    0xe64(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    $0x1,%r8d
call   1070 <syncAndCheckMd4@plt>
lea    0xe69(%rip),%rdi
mov    %r15,%rsi
mov    $0x200000,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <checkFileSize@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"testSource.bin\00"
@.str.1 = [18 x i8] c"zero sized source\00"
@.str.2 = [13 x i8] c"testDest.bin\00"
@.str.3 = [34 x i8] c"changed byte (zero sized source) \00"
@.str.4 = [40 x i8] c"changed byte (zero sized source) (size)\00"
@.str.5 = [32 x i8] c"added 1 md (zero sized source) \00"
@.str.6 = [38 x i8] c"added 1 md (zero sized source) (size)\00"
@.str.7 = [31 x i8] c"truncated (zero sized source) \00"
@.str.8 = [37 x i8] c"truncated (zero sized source) (size)\00"
define void @testZeroSizedSource(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @cleanup()
%4 = call i32 @createZeroFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 5242880)
%5 = load i32, i32* %2
%6 = call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 1)
%7 = call i32 @checkFileSize(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 5242880)
%8 = call i32 @changeByte(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 5, i8 signext 99)
%9 = load i32, i32* %2
%10 = call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 1)
%11 = call i32 @checkFileSize(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 5242880)
%12 = call i32 @addBytes(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 1048576, i32 0)
%13 = load i32, i32* %2
%14 = call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 1)
%15 = call i32 @checkFileSize(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 6291456)
%16 = call i32 @truncate(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 2097152)
%17 = load i32, i32* %2
%18 = call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 1)
%19 = call i32 @checkFileSize(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 2097152)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"testSource.bin\00"
@.str.1 = [18 x i8] c"zero sized source\00"
@.str.2 = [13 x i8] c"testDest.bin\00"
@.str.3 = [34 x i8] c"changed byte (zero sized source) \00"
@.str.4 = [40 x i8] c"changed byte (zero sized source) (size)\00"
@.str.5 = [32 x i8] c"added 1 md (zero sized source) \00"
@.str.6 = [38 x i8] c"added 1 md (zero sized source) (size)\00"
@.str.7 = [31 x i8] c"truncated (zero sized source) \00"
@.str.8 = [37 x i8] c"truncated (zero sized source) (size)\00"
define void @testZeroSizedSource(i32 %0) {
%2 = tail call i32 (...) @cleanup()
%3 = tail call i32 @createZeroFile(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 5242880)
%4 = tail call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 1)
%5 = tail call i32 @checkFileSize(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 5242880)
%6 = tail call i32 @changeByte(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 5, i8 signext 99)
%7 = tail call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 1)
%8 = tail call i32 @checkFileSize(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 5242880)
%9 = tail call i32 @addBytes(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 1048576, i32 0)
%10 = tail call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 1)
%11 = tail call i32 @checkFileSize(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 6291456)
%12 = tail call i32 @truncate(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 2097152)
%13 = tail call i32 @syncAndCheckMd4(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 1)
%14 = tail call i32 @checkFileSize(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 2097152)
ret void
}