void mak_links(fpath) char *fpath;
{
  char *fname;
  int ch;
  if (mkdir(fpath, 0700))
    return;
  fname = fpath;
  while (*++fname)
    ;
  *fname++ = '/';
  fname[1] = '\0';
  ch = '0';
  for (;;) {
    *fname = ch++;
    symlink(".", fpath);
    if (ch == 'W')
      break;
    if (ch == '9' + 1)
      ch = '@';
  }
  fname[-1] = '\0';
}


x86 assembly (clang, -O0):
<mak_links>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1c0,%esi
mov    $0x0,%al
call   1030 <mkdir@plt>
cmp    $0x0,%eax
je     114a <mak_links+0x2a>
jmp    11e3 <mak_links+0xc3>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmpb   $0x0,0x1(%rax)
je     1170 <mak_links+0x50>
jmp    1152 <mak_links+0x32>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2f,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
movl   $0x30,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <symlink@plt>
cmpl   $0x57,-0x14(%rbp)
jne    11c5 <mak_links+0xa5>
jmp    11db <mak_links+0xbb>
cmpl   $0x3a,-0x14(%rbp)
jne    11d6 <mak_links+0xb6>
movl   $0x40,-0x14(%rbp)
jmp    1191 <mak_links+0x71>
mov    -0x10(%rbp),%rax
movb   $0x0,-0x1(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mak_links>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    $0x1c0,%esi
xor    %eax,%eax
call   1030 <mkdir@plt>
test   %eax,%eax
jne    11a5 <mak_links+0x85>
lea    0x2(%r15),%rbx
nop
cmpb   $0x0,-0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <mak_links+0x20>
movw   $0x302f,-0x2(%rbx)
movb   $0x0,(%rbx)
lea    0xea6(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <symlink@plt>
mov    $0x31,%eax
mov    $0x40,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x3a,%eax
cmove  %r12d,%eax
lea    0x1(%rax),%ebp
mov    %al,-0x1(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <symlink@plt>
mov    %ebp,%eax
cmp    $0x57,%ebp
jne    1180 <mak_links+0x60>
movb   $0x0,-0x2(%rbx)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define void @mak_links(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mkdir to i32 (i8*, i32, ...)*)(i8* %5, i32 448)
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
br label %40
9: ; preds = %1
%10 = load i8*, i8** %2
store i8* %10, i8** %3
br label %11
11: ; preds = %16, %9
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
br label %11
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 47, i8* %18
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8 0, i8* %21
store i32 48, i32* %4
br label %22
22: ; preds = %36, %17
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
%25 = trunc i32 %23 to i8
%26 = load i8*, i8** %3
store i8 %25, i8* %26
%27 = load i8*, i8** %2
%28 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @symlink to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 87
br i1 %30, label %31, label %32
31: ; preds = %22
br label %37
32: ; preds = %22
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 58
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 64, i32* %4
br label %36
36: ; preds = %35, %32
br label %22
37: ; preds = %31
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 -1
store i8 0, i8* %39
br label %40
40: ; preds = %37, %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define void @mak_links(i8* %0) {
%2 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @mkdir to i32 (i8*, i32, ...)*)(i8* %0, i32 448)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %22
4: ; preds = %1, %4
%5 = phi i8* [ %6, %4 ], [ %0, %1 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %5, i64 2
store i8 47, i8* %6
%11 = getelementptr inbounds i8, i8* %5, i64 3
store i8 0, i8* %11
store i8 48, i8* %10
%12 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @symlink to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %9, %13
%14 = phi i32 [ 49, %9 ], [ %17, %13 ]
%15 = icmp eq i32 %14, 58
%16 = select i1 %15, i32 64, i32 %14
%17 = add nsw i32 %16, 1
%18 = trunc i32 %16 to i8
store i8 %18, i8* %10
%19 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @symlink to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0)
%20 = icmp eq i32 %17, 87
br i1 %20, label %21, label %13
21: ; preds = %13
store i8 0, i8* %6
br label %22
22: ; preds = %1, %21
ret void
}