#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*/ memcpy(unsigned char *, unsigned char const **, int);
int write_MBR_code_i386_aux(unsigned char *buffer) {
  const unsigned char mbr_code_testdisk[0x200u] = {
      0xfc, 0x31, 0xc0, 0x8e, 0xd0, 0x31, 0xe4, 0x8e, 0xd8, 0x8e, 0xc0, 0xbe,
      0x00, 0x7c, 0xbf, 0x00, 0x06, 0xb9, 0x00, 0x01, 0xf3, 0xa5, 0xbe, 0xee,
      0x07, 0xb0, 0x08, 0xea, 0x20, 0x06, 0x00, 0x00, 0x80, 0x3e, 0xb3, 0x07,
      0xff, 0x75, 0x04, 0x88, 0x16, 0xb3, 0x07, 0x80, 0x3c, 0x00, 0x74, 0x04,
      0x08, 0x06, 0xaf, 0x07, 0x83, 0xee, 0x10, 0xd0, 0xe8, 0x73, 0xf0, 0x90,
      0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
      0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
      0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
      0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
      0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
      0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0xbe, 0xbe, 0x07, 0xb0, 0x00, 0xb9,
      0x04, 0x00, 0x80, 0x3c, 0x00, 0x75, 0x6e, 0xfe, 0xc0, 0x83, 0xc6, 0x10,
      0xe2, 0xf4, 0x31, 0xdb, 0xb4, 0x0e, 0xbe, 0x9d, 0x07, 0x8a, 0x0e, 0xaf,
      0x07, 0xac, 0xd0, 0xe9, 0x73, 0x02, 0xcd, 0x10, 0x08, 0xc9, 0x75, 0xf5,
      0xb0, 0x3a, 0xcd, 0x10, 0x31, 0xc0, 0xcd, 0x16, 0x3c, 0x00, 0x74, 0xf8,
      0xbe, 0x8b, 0x07, 0xb9, 0x02, 0x00, 0xe8, 0xba, 0x00, 0x3c, 0x0d, 0x74,
      0xb4, 0x3c, 0x61, 0x72, 0x06, 0x3c, 0x7a, 0x77, 0x02, 0x2c, 0x20, 0x88,
      0xc3, 0xbe, 0x9d, 0x07, 0x8a, 0x0e, 0xaf, 0x07, 0xac, 0xd0, 0xe9, 0x73,
      0x04, 0x38, 0xc3, 0x74, 0x06, 0x08, 0xc9, 0x75, 0xf3, 0xeb, 0xaf, 0xb8,
      0x0d, 0x0e, 0x31, 0xdb, 0xcd, 0x10, 0x8d, 0x84, 0x62, 0x00, 0x3c, 0x07,
      0x75, 0x07, 0xb0, 0x1f, 0xa2, 0xaf, 0x07, 0xeb, 0x99, 0x31, 0xd2, 0xb9,
      0x01, 0x00, 0x3c, 0x04, 0x74, 0x11, 0x73, 0xf3, 0x30, 0xe4, 0xb1, 0x04,
      0xd2, 0xe0, 0xbe, 0xbe, 0x07, 0x01, 0xc6, 0x8a, 0x16, 0xb3, 0x07, 0xbf,
      0x05, 0x00, 0x56, 0xf6, 0xc2, 0x80, 0x74, 0x31, 0xb4, 0x41, 0xbb, 0xaa,
      0x55, 0x52, 0xcd, 0x13, 0x5a, 0x5e, 0x56, 0x72, 0x1e, 0x81, 0xfb, 0x55,
      0xaa, 0x75, 0x18, 0xf6, 0xc1, 0x01, 0x74, 0x13, 0x8b, 0x44, 0x08, 0x8b,
      0x5c, 0x0a, 0xbe, 0x8d, 0x07, 0x89, 0x44, 0x08, 0x89, 0x5c, 0x0a, 0xb4,
      0x42, 0xeb, 0x0c, 0x8a, 0x74, 0x01, 0x8b, 0x4c, 0x02, 0xb8, 0x01, 0x02,
      0xbb, 0x00, 0x7c, 0x50, 0xc6, 0x06, 0x8f, 0x07, 0x01, 0xcd, 0x13, 0x58,
      0x5e, 0x73, 0x05, 0x4f, 0x75, 0xb4, 0xeb, 0x93, 0x81, 0x3e, 0xfe, 0x7d,
      0x55, 0xaa, 0x75, 0xf6, 0xea, 0x00, 0x7c, 0x00, 0x00, 0xbe, 0x83, 0x07,
      0xb9, 0x0a, 0x00, 0x50, 0xb4, 0x0e, 0x31, 0xdb, 0xac, 0xcd, 0x10, 0xe2,
      0xfb, 0x58, 0xc3, 'T',  'e',  's',  't',  'D',  'i',  's',  'k',  0x0d,
      0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, '1',  '2',  '3',  '4',  'F',  0x00, 0x00,
      0x41, 'N',  'D',  'T',  'm',  'b',  'r',  0x00, 0x02, 0x02, 0x02, 0x1f,
      0xc7, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0xa5, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa};
  memcpy(buffer, &mbr_code_testdisk, 0x1b8);
  buffer[0x1FE] = (unsigned char)0x55;
  buffer[0x1FF] = (unsigned char)0xAA;
  return 0;
}


x86 assembly (clang, -O0):
<write_MBR_code_i386_aux>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xed3(%rip),%rsi
mov    $0x200,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rsi
mov    $0x1b8,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x55,0x1fe(%rax)
mov    -0x8(%rbp),%rax
movb   $0xaa,0x1ff(%rax)
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_MBR_code_i386_aux>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%rbx
lea    0xedc(%rip),%rsi
mov    %rsp,%r14
mov    $0x200,%edx
mov    %r14,%rdi
call   1030 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1b8,%edx
call   1030 <memcpy@plt>
movw   $0xaa55,0x1fe(%rbx)
55 aa
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.write_MBR_code_i386_aux.mbr_code_testdisk = [512 x i8] c"\FC1\C0\8E\D01\E4\8E\D8\8E\C0\BE\00|\BF\00\06\B9\00\01\F3\A5\BE\EE\07\B0\08\EA \06\00\00\80>\B3\07\FFu\04\88\16\B3\07\80<\00t\04\08\06\AF\07\83\EE\10\D0\E8s\F0\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\BE\BE\07\B0\00\B9\04\00\80<\00un\FE\C0\83\C6\10\E2\F41\DB\B4\0E\BE\9D\07\8A\0E\AF\07\AC\D0\E9s\02\CD\10\08\C9u\F5\B0:\CD\101\C0\CD\16<\00t\F8\BE\8B\07\B9\02\00\E8\BA\00<\0Dt\B4<ar\06<zw\02, \88\C3\BE\9D\07\8A\0E\AF\07\AC\D0\E9s\048\C3t\06\08\C9u\F3\EB\AF\B8\0D\0E1\DB\CD\10\8D\84b\00<\07u\07\B0\1F\A2\AF\07\EB\991\D2\B9\01\00<\04t\11s\F30\E4\B1\04\D2\E0\BE\BE\07\01\C6\8A\16\B3\07\BF\05\00V\F6\C2\80t1\B4A\BB\AAUR\CD\13Z^Vr\1E\81\FBU\AAu\18\F6\C1\01t\13\8BD\08\8B\\\0A\BE\8D\07\89D\08\89\\\0A\B4B\EB\0C\8At\01\8BL\02\B8\01\02\BB\00|P\C6\06\8F\07\01\CD\13X^s\05Ou\B4\EB\93\81>\FE}U\AAu\F6\EA\00|\00\00\BE\83\07\B9\0A\00P\B4\0E1\DB\AC\CD\10\E2\FBX\C3TestDisk\0D\0A\10\00\01\00\00|\00\00\00\00\00\00\00\00\00\001234F\00\00ANDTmbr\00\02\02\02\1F\C7\00\00\80\00\00\00\00\00\00\00\00\A5\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00U\AA"
define i32 @write_MBR_code_i386_aux(i8* %0) {
%2 = alloca i8*
%3 = alloca [512 x i8]
store i8* %0, i8** %2
%4 = bitcast [512 x i8]* %3 to i8*
%5 = load i8*, i8** %2
%6 = bitcast [512 x i8]* %3 to i8**
%7 = call i32 @memcpy(i8* %5, i8** %6, i32 440)
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 510
store i8 85, i8* %9
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 511
store i8 -86, i8* %11
ret i32 0
}

LLVM IR (-O2):
@__const.write_MBR_code_i386_aux.mbr_code_testdisk = [512 x i8] c"\FC1\C0\8E\D01\E4\8E\D8\8E\C0\BE\00|\BF\00\06\B9\00\01\F3\A5\BE\EE\07\B0\08\EA \06\00\00\80>\B3\07\FFu\04\88\16\B3\07\80<\00t\04\08\06\AF\07\83\EE\10\D0\E8s\F0\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\90\BE\BE\07\B0\00\B9\04\00\80<\00un\FE\C0\83\C6\10\E2\F41\DB\B4\0E\BE\9D\07\8A\0E\AF\07\AC\D0\E9s\02\CD\10\08\C9u\F5\B0:\CD\101\C0\CD\16<\00t\F8\BE\8B\07\B9\02\00\E8\BA\00<\0Dt\B4<ar\06<zw\02, \88\C3\BE\9D\07\8A\0E\AF\07\AC\D0\E9s\048\C3t\06\08\C9u\F3\EB\AF\B8\0D\0E1\DB\CD\10\8D\84b\00<\07u\07\B0\1F\A2\AF\07\EB\991\D2\B9\01\00<\04t\11s\F30\E4\B1\04\D2\E0\BE\BE\07\01\C6\8A\16\B3\07\BF\05\00V\F6\C2\80t1\B4A\BB\AAUR\CD\13Z^Vr\1E\81\FBU\AAu\18\F6\C1\01t\13\8BD\08\8B\\\0A\BE\8D\07\89D\08\89\\\0A\B4B\EB\0C\8At\01\8BL\02\B8\01\02\BB\00|P\C6\06\8F\07\01\CD\13X^s\05Ou\B4\EB\93\81>\FE}U\AAu\F6\EA\00|\00\00\BE\83\07\B9\0A\00P\B4\0E1\DB\AC\CD\10\E2\FBX\C3TestDisk\0D\0A\10\00\01\00\00|\00\00\00\00\00\00\00\00\00\001234F\00\00ANDTmbr\00\02\02\02\1F\C7\00\00\80\00\00\00\00\00\00\00\00\A5\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00U\AA"
define i32 @write_MBR_code_i386_aux(i8* %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = bitcast [512 x i8]* %2 to i8**
%5 = call i32 @memcpy(i8* %0, i8** %4, i32 440)
%6 = getelementptr inbounds i8, i8* %0, i64 510
store i8 85, i8* %6
%7 = getelementptr inbounds i8, i8* %0, i64 511
store i8 -86, i8* %7
ret i32 0
}