#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int sd_write_sector(int, unsigned char *);
int cmd_sdwrtest(int argc, char **argv) {
  unsigned char buffer[512];
  int i;
  for (i = 0; i < sizeof(buffer); i++)
    buffer[i] = i ^ 0xFF;
  i = sd_write_sector(1, buffer);
  if (i) {
    printf("ERROR: sd_write_sector function returned with %d\n", i);
    return -1;
  } else {
    printf("Nice, test seems to be OK :-)\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<cmd_sdwrtest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x214(%rbp)
movslq -0x214(%rbp),%rax
cmp    $0x200,%rax
jae    117e <cmd_sdwrtest+0x5e>
mov    -0x214(%rbp),%eax
xor    $0xff,%eax
mov    %al,%cl
movslq -0x214(%rbp),%rax
mov    %cl,-0x210(%rbp,%rax,1)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    113c <cmd_sdwrtest+0x1c>
lea    -0x210(%rbp),%rsi
mov    $0x1,%edi
call   1040 <sd_write_sector@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     11c2 <cmd_sdwrtest+0xa2>
mov    -0x214(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d7 <cmd_sdwrtest+0xb7>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_sdwrtest>:
sub    $0x208,%rsp
movaps 0xec1(%rip),%xmm8
movaps %xmm8,(%rsp)
movaps 0xec4(%rip),%xmm9
movaps %xmm9,0x10(%rsp)
movaps 0xec6(%rip),%xmm10
movaps %xmm10,0x20(%rsp)
movaps 0xec8(%rip),%xmm11
movaps %xmm11,0x30(%rsp)
movaps 0xeca(%rip),%xmm12
movaps %xmm12,0x40(%rsp)
movaps 0xecc(%rip),%xmm13
movaps %xmm13,0x50(%rsp)
movaps 0xece(%rip),%xmm14
movaps %xmm14,0x60(%rsp)
movaps 0xed0(%rip),%xmm15
movaps %xmm15,0x70(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xed4(%rip),%xmm1
movaps %xmm1,0x90(%rsp)
movaps 0xed5(%rip),%xmm2
movaps %xmm2,0xa0(%rsp)
movaps 0xed6(%rip),%xmm3
movaps %xmm3,0xb0(%rsp)
movaps 0xed7(%rip),%xmm4
movaps %xmm4,0xc0(%rsp)
movaps 0xed8(%rip),%xmm5
movaps %xmm5,0xd0(%rsp)
movaps 0xed9(%rip),%xmm6
movaps %xmm6,0xe0(%rsp)
movaps 0xeda(%rip),%xmm7
movaps %xmm7,0xf0(%rsp)
movaps %xmm8,0x100(%rsp)
movaps %xmm9,0x110(%rsp)
movaps %xmm10,0x120(%rsp)
movaps %xmm11,0x130(%rsp)
movaps %xmm12,0x140(%rsp)
movaps %xmm13,0x150(%rsp)
movaps %xmm14,0x160(%rsp)
movaps %xmm15,0x170(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm1,0x190(%rsp)
movaps %xmm2,0x1a0(%rsp)
movaps %xmm3,0x1b0(%rsp)
movaps %xmm4,0x1c0(%rsp)
movaps %xmm5,0x1d0(%rsp)
movaps %xmm6,0x1e0(%rsp)
movaps %xmm7,0x1f0(%rsp)
mov    %rsp,%rsi
mov    $0x1,%edi
call   1050 <sd_write_sector@plt>
test   %eax,%eax
je     12d4 <cmd_sdwrtest+0x1a4>
lea    0xe42(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x208,%rsp
ret
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x208,%rsp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"ERROR: sd_write_sector function returned with %d\0A\00"
@.str.1 = [31 x i8] c"Nice, test seems to be OK :-)\0A\00"
define i32 @cmd_sdwrtest(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %19, %2
%9 = load i32, i32* %7
%10 = sext i32 %9 to i64
%11 = icmp ult i64 %10, 512
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32, i32* %7
%14 = xor i32 %13, 255
%15 = trunc i32 %14 to i8
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %17
store i8 %15, i8* %18
br label %19
19: ; preds = %12
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %8
22: ; preds = %8
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%24 = call i32 @sd_write_sector(i32 1, i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %28)
store i32 -1, i32* %3
br label %32
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %32
32: ; preds = %30, %27
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [50 x i8] c"ERROR: sd_write_sector function returned with %d\0A\00"
@str = [30 x i8] c"Nice, test seems to be OK :-)\00"
define i32 @cmd_sdwrtest(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = bitcast [512 x i8]* %3 to <16 x i8>*
store <16 x i8> <i8 -1, i8 -2, i8 -3, i8 -4, i8 -5, i8 -6, i8 -7, i8 -8, i8 -9, i8 -10, i8 -11, i8 -12, i8 -13, i8 -14, i8 -15, i8 -16>, <16 x i8>* %5
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 16
%7 = bitcast i8* %6 to <16 x i8>*
store <16 x i8> <i8 -17, i8 -18, i8 -19, i8 -20, i8 -21, i8 -22, i8 -23, i8 -24, i8 -25, i8 -26, i8 -27, i8 -28, i8 -29, i8 -30, i8 -31, i8 -32>, <16 x i8>* %7
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 32
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> <i8 -33, i8 -34, i8 -35, i8 -36, i8 -37, i8 -38, i8 -39, i8 -40, i8 -41, i8 -42, i8 -43, i8 -44, i8 -45, i8 -46, i8 -47, i8 -48>, <16 x i8>* %9
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 48
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> <i8 -49, i8 -50, i8 -51, i8 -52, i8 -53, i8 -54, i8 -55, i8 -56, i8 -57, i8 -58, i8 -59, i8 -60, i8 -61, i8 -62, i8 -63, i8 -64>, <16 x i8>* %11
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 64
%13 = bitcast i8* %12 to <16 x i8>*
store <16 x i8> <i8 -65, i8 -66, i8 -67, i8 -68, i8 -69, i8 -70, i8 -71, i8 -72, i8 -73, i8 -74, i8 -75, i8 -76, i8 -77, i8 -78, i8 -79, i8 -80>, <16 x i8>* %13
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 80
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> <i8 -81, i8 -82, i8 -83, i8 -84, i8 -85, i8 -86, i8 -87, i8 -88, i8 -89, i8 -90, i8 -91, i8 -92, i8 -93, i8 -94, i8 -95, i8 -96>, <16 x i8>* %15
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 96
%17 = bitcast i8* %16 to <16 x i8>*
store <16 x i8> <i8 -97, i8 -98, i8 -99, i8 -100, i8 -101, i8 -102, i8 -103, i8 -104, i8 -105, i8 -106, i8 -107, i8 -108, i8 -109, i8 -110, i8 -111, i8 -112>, <16 x i8>* %17
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 112
%19 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> <i8 -113, i8 -114, i8 -115, i8 -116, i8 -117, i8 -118, i8 -119, i8 -120, i8 -121, i8 -122, i8 -123, i8 -124, i8 -125, i8 -126, i8 -127, i8 -128>, <16 x i8>* %19
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 128
%21 = bitcast i8* %20 to <16 x i8>*
store <16 x i8> <i8 127, i8 126, i8 125, i8 124, i8 123, i8 122, i8 121, i8 120, i8 119, i8 118, i8 117, i8 116, i8 115, i8 114, i8 113, i8 112>, <16 x i8>* %21
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 144
%23 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> <i8 111, i8 110, i8 109, i8 108, i8 107, i8 106, i8 105, i8 104, i8 103, i8 102, i8 101, i8 100, i8 99, i8 98, i8 97, i8 96>, <16 x i8>* %23
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 160
%25 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> <i8 95, i8 94, i8 93, i8 92, i8 91, i8 90, i8 89, i8 88, i8 87, i8 86, i8 85, i8 84, i8 83, i8 82, i8 81, i8 80>, <16 x i8>* %25
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 176
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> <i8 79, i8 78, i8 77, i8 76, i8 75, i8 74, i8 73, i8 72, i8 71, i8 70, i8 69, i8 68, i8 67, i8 66, i8 65, i8 64>, <16 x i8>* %27
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 192
%29 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> <i8 63, i8 62, i8 61, i8 60, i8 59, i8 58, i8 57, i8 56, i8 55, i8 54, i8 53, i8 52, i8 51, i8 50, i8 49, i8 48>, <16 x i8>* %29
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 208
%31 = bitcast i8* %30 to <16 x i8>*
store <16 x i8> <i8 47, i8 46, i8 45, i8 44, i8 43, i8 42, i8 41, i8 40, i8 39, i8 38, i8 37, i8 36, i8 35, i8 34, i8 33, i8 32>, <16 x i8>* %31
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 224
%33 = bitcast i8* %32 to <16 x i8>*
store <16 x i8> <i8 31, i8 30, i8 29, i8 28, i8 27, i8 26, i8 25, i8 24, i8 23, i8 22, i8 21, i8 20, i8 19, i8 18, i8 17, i8 16>, <16 x i8>* %33
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 240
%35 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> <i8 15, i8 14, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>, <16 x i8>* %35
%36 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 256
%37 = bitcast i8* %36 to <16 x i8>*
store <16 x i8> <i8 -1, i8 -2, i8 -3, i8 -4, i8 -5, i8 -6, i8 -7, i8 -8, i8 -9, i8 -10, i8 -11, i8 -12, i8 -13, i8 -14, i8 -15, i8 -16>, <16 x i8>* %37
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 272
%39 = bitcast i8* %38 to <16 x i8>*
store <16 x i8> <i8 -17, i8 -18, i8 -19, i8 -20, i8 -21, i8 -22, i8 -23, i8 -24, i8 -25, i8 -26, i8 -27, i8 -28, i8 -29, i8 -30, i8 -31, i8 -32>, <16 x i8>* %39
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 288
%41 = bitcast i8* %40 to <16 x i8>*
store <16 x i8> <i8 -33, i8 -34, i8 -35, i8 -36, i8 -37, i8 -38, i8 -39, i8 -40, i8 -41, i8 -42, i8 -43, i8 -44, i8 -45, i8 -46, i8 -47, i8 -48>, <16 x i8>* %41
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 304
%43 = bitcast i8* %42 to <16 x i8>*
store <16 x i8> <i8 -49, i8 -50, i8 -51, i8 -52, i8 -53, i8 -54, i8 -55, i8 -56, i8 -57, i8 -58, i8 -59, i8 -60, i8 -61, i8 -62, i8 -63, i8 -64>, <16 x i8>* %43
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 320
%45 = bitcast i8* %44 to <16 x i8>*
store <16 x i8> <i8 -65, i8 -66, i8 -67, i8 -68, i8 -69, i8 -70, i8 -71, i8 -72, i8 -73, i8 -74, i8 -75, i8 -76, i8 -77, i8 -78, i8 -79, i8 -80>, <16 x i8>* %45
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 336
%47 = bitcast i8* %46 to <16 x i8>*
store <16 x i8> <i8 -81, i8 -82, i8 -83, i8 -84, i8 -85, i8 -86, i8 -87, i8 -88, i8 -89, i8 -90, i8 -91, i8 -92, i8 -93, i8 -94, i8 -95, i8 -96>, <16 x i8>* %47
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 352
%49 = bitcast i8* %48 to <16 x i8>*
store <16 x i8> <i8 -97, i8 -98, i8 -99, i8 -100, i8 -101, i8 -102, i8 -103, i8 -104, i8 -105, i8 -106, i8 -107, i8 -108, i8 -109, i8 -110, i8 -111, i8 -112>, <16 x i8>* %49
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 368
%51 = bitcast i8* %50 to <16 x i8>*
store <16 x i8> <i8 -113, i8 -114, i8 -115, i8 -116, i8 -117, i8 -118, i8 -119, i8 -120, i8 -121, i8 -122, i8 -123, i8 -124, i8 -125, i8 -126, i8 -127, i8 -128>, <16 x i8>* %51
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 384
%53 = bitcast i8* %52 to <16 x i8>*
store <16 x i8> <i8 127, i8 126, i8 125, i8 124, i8 123, i8 122, i8 121, i8 120, i8 119, i8 118, i8 117, i8 116, i8 115, i8 114, i8 113, i8 112>, <16 x i8>* %53
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 400
%55 = bitcast i8* %54 to <16 x i8>*
store <16 x i8> <i8 111, i8 110, i8 109, i8 108, i8 107, i8 106, i8 105, i8 104, i8 103, i8 102, i8 101, i8 100, i8 99, i8 98, i8 97, i8 96>, <16 x i8>* %55
%56 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 416
%57 = bitcast i8* %56 to <16 x i8>*
store <16 x i8> <i8 95, i8 94, i8 93, i8 92, i8 91, i8 90, i8 89, i8 88, i8 87, i8 86, i8 85, i8 84, i8 83, i8 82, i8 81, i8 80>, <16 x i8>* %57
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 432
%59 = bitcast i8* %58 to <16 x i8>*
store <16 x i8> <i8 79, i8 78, i8 77, i8 76, i8 75, i8 74, i8 73, i8 72, i8 71, i8 70, i8 69, i8 68, i8 67, i8 66, i8 65, i8 64>, <16 x i8>* %59
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 448
%61 = bitcast i8* %60 to <16 x i8>*
store <16 x i8> <i8 63, i8 62, i8 61, i8 60, i8 59, i8 58, i8 57, i8 56, i8 55, i8 54, i8 53, i8 52, i8 51, i8 50, i8 49, i8 48>, <16 x i8>* %61
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 464
%63 = bitcast i8* %62 to <16 x i8>*
store <16 x i8> <i8 47, i8 46, i8 45, i8 44, i8 43, i8 42, i8 41, i8 40, i8 39, i8 38, i8 37, i8 36, i8 35, i8 34, i8 33, i8 32>, <16 x i8>* %63
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 480
%65 = bitcast i8* %64 to <16 x i8>*
store <16 x i8> <i8 31, i8 30, i8 29, i8 28, i8 27, i8 26, i8 25, i8 24, i8 23, i8 22, i8 21, i8 20, i8 19, i8 18, i8 17, i8 16>, <16 x i8>* %65
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 496
%67 = bitcast i8* %66 to <16 x i8>*
store <16 x i8> <i8 15, i8 14, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>, <16 x i8>* %67
%68 = call i32 @sd_write_sector(i32 1, i8* %4)
%69 = icmp eq i32 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %2
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %68)
br label %74
72: ; preds = %2
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
%75 = phi i32 [ -1, %70 ], [ 0, %72 ]
ret i32 %75
}