#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*/ strncpy(char *, char *, int);
int writeSector(char *);
int writeDirectory(char *name) {
  char buf[512];
  for (int i = 0; i < 512; i++)
    buf[i] = 0;
  strncpy(buf, name, 8);
  buf[2] |= 0x80;
  buf[3] |= 0x80;
  return writeSector(buf);
}


x86 assembly (clang, -O0):
<writeDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x214(%rbp)
cmpl   $0x200,-0x214(%rbp)
jge    116c <writeDirectory+0x4c>
movslq -0x214(%rbp),%rax
movb   $0x0,-0x210(%rbp,%rax,1)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    1139 <writeDirectory+0x19>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
movsbl -0x20e(%rbp),%eax
or     $0x80,%eax
mov    %al,-0x20e(%rbp)
movsbl -0x20d(%rbp),%eax
or     $0x80,%eax
mov    %al,-0x20d(%rbp)
lea    -0x210(%rbp),%rdi
call   1040 <writeSector@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeDirectory>:
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    $0x200,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <strncpy@plt>
orb    $0x80,0x2(%rsp)
orb    $0x80,0x3(%rsp)
mov    %r14,%rdi
call   1040 <writeSector@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @writeDirectory(i8* %0) {
%2 = alloca i8*
%3 = alloca [512 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %12, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 512
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %10
store i8 0, i8* %11
br label %12
12: ; preds = %8
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
br label %5
15: ; preds = %5
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32 @strncpy(i8* %16, i8* %17, i32 8)
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = or i32 %21, 128
%23 = trunc i32 %22 to i8
store i8 %23, i8* %19
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = or i32 %26, 128
%28 = trunc i32 %27 to i8
store i8 %28, i8* %24
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%30 = call i32 @writeSector(i8* %29)
ret i32 %30
}

LLVM IR (-O2):
define i32 @writeDirectory(i8* %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* %0, i32 8)
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 2
%7 = load i8, i8* %6
%8 = or i8 %7, -128
store i8 %8, i8* %6
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 3
%10 = load i8, i8* %9
%11 = or i8 %10, -128
store i8 %11, i8* %9
%12 = call i32 @writeSector(i8* %4)
ret i32 %12
}