void setDFmacro(name, val) char *name;
char *val;
{
  char *c, *tmp;
  int len;
  static char filename[] = "@F";
  static char dirname[] = "@D";
  setmacro(name, val);
  *filename = *name;
  *dirname = *name;
  if (!(*val)) {
    setmacro(filename, "");
    setmacro(dirname, "");
    return;
  }
  if (!(c = strrchr(val, (int)'/'))) {
    setmacro(filename, val);
    setmacro(dirname, "./");
    return;
  }
  setmacro(filename, c + 1);
  len = c - val + 1;
  if ((tmp = malloc(len + 1)) == (char *)0)
    fatal("No memory for tmp", (char *)0, 0);
  strncpy(tmp, val, len);
  tmp[len] = '\0';
  setmacro(dirname, tmp);
  free(tmp);
  return;
}


x86 assembly (clang, -O0):
<setDFmacro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <setmacro@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ec5(%rip)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ebc(%rip)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11d3 <setDFmacro+0x73>
lea    0x2ea5(%rip),%rdi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1060 <setmacro@plt>
lea    0x2e93(%rip),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1060 <setmacro@plt>
jmp    12ab <setDFmacro+0x14b>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    121b <setDFmacro+0xbb>
mov    -0x10(%rbp),%rsi
lea    0x2e56(%rip),%rdi
mov    $0x0,%al
call   1060 <setmacro@plt>
lea    0x2e4b(%rip),%rdi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1060 <setmacro@plt>
jmp    12ab <setDFmacro+0x14b>
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
lea    0x2e26(%rip),%rdi
mov    $0x0,%al
call   1060 <setmacro@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1273 <setDFmacro+0x113>
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1080 <fatal@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x24(%rbp),%rdx
call   1040 <strncpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0x2db8(%rip),%rdi
mov    $0x0,%al
call   1060 <setmacro@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setDFmacro>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <setmacro@plt>
mov    (%rbx),%al
mov    %al,0x2ed6(%rip)
mov    (%rbx),%al
mov    %al,0x2ed1(%rip)
cmpb   $0x0,(%r14)
je     1233 <setDFmacro+0xd3>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1257 <setDFmacro+0xf7>
mov    %rax,%rbx
mov    %rax,%rsi
add    $0x1,%rsi
lea    0x2e9d(%rip),%rdi
xor    %eax,%eax
call   1060 <setmacro@plt>
sub    %r14d,%ebx
shl    $0x20,%rbx
movabs $0x200000000,%rdi
add    %rbx,%rdi
sar    $0x20,%rdi
call   1070 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11f1 <setDFmacro+0x91>
lea    0xe1d(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1080 <fatal@plt>
movabs $0x100000000,%rax
add    %rax,%rbx
sar    $0x20,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <strncpy@plt>
movb   $0x0,(%r15,%rbx,1)
lea    0x2e37(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <setmacro@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    0x2e16(%rip),%rdi
lea    0xdc1(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <setmacro@plt>
lea    0x2e01(%rip),%rdi
mov    %rbx,%rsi
jmp    1276 <setDFmacro+0x116>
lea    0x2df2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <setmacro@plt>
lea    0x2de4(%rip),%rdi
lea    0xd8a(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <setmacro@plt>

LLVM IR (-O0):
@setDFmacro.filename = internal global [3 x i8] c"@F\00"
@setDFmacro.dirname = internal global [3 x i8] c"@D\00"
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [18 x i8] c"No memory for tmp\00"
define void @setDFmacro(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* %8, i8* %9)
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
store i8 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0)
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
store i8 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0)
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%20 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %60
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = call i8* @strrchr(i8* %22, i32 47)
store i8* %23, i8** %5
%24 = icmp ne i8* %23, null
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8*, i8** %4
%27 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0), i8* %26)
%28 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %60
29: ; preds = %21
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %5
%34 = load i8*, i8** %4
%35 = ptrtoint i8* %33 to i64
%36 = ptrtoint i8* %34 to i64
%37 = sub i64 %35, %36
%38 = add nsw i64 %37, 1
%39 = trunc i64 %38 to i32
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = call i8* @malloc(i64 %42)
store i8* %43, i8** %6
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %29
%46 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @fatal to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* null, i32 0)
br label %47
47: ; preds = %45, %29
%48 = load i8*, i8** %6
%49 = load i8*, i8** %4
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = call i8* @strncpy(i8* %48, i8* %49, i64 %51)
%53 = load i8*, i8** %6
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 0, i8* %56
%57 = load i8*, i8** %6
%58 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0), i8* %57)
%59 = load i8*, i8** %6
br label %60
60: ; preds = %47, %25, %18
ret void
}

LLVM IR (-O2):
@setDFmacro.filename = internal global [3 x i8] c"@F\00"
@setDFmacro.dirname = internal global [3 x i8] c"@D\00"
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"./\00"
@.str.2 = [18 x i8] c"No memory for tmp\00"
define void @setDFmacro(i8* %0, i8* %1) {
%3 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* %0, i8* %1)
%4 = load i8, i8* %0
store i8 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0)
%5 = load i8, i8* %0
store i8 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0)
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %36
11: ; preds = %2
%12 = tail call i8* @strrchr(i8* %1, i32 47)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0), i8* %1)
%16 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %36
17: ; preds = %11
%18 = getelementptr inbounds i8, i8* %12, i64 1
%19 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.filename, i64 0, i64 0), i8* %18)
%20 = ptrtoint i8* %12 to i64
%21 = ptrtoint i8* %1 to i64
%22 = sub i64 %20, %21
%23 = shl i64 %22, 32
%24 = add i64 %23, 8589934592
%25 = ashr exact i64 %24, 32
%26 = tail call i8* @malloc(i64 %25)
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %17
%29 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @fatal to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* null, i32 0)
br label %30
30: ; preds = %28, %17
%31 = add i64 %23, 4294967296
%32 = ashr exact i64 %31, 32
%33 = tail call i8* @strncpy(i8* dereferenceable(1) %26, i8* %1, i64 %32)
%34 = getelementptr inbounds i8, i8* %26, i64 %32
store i8 0, i8* %34
%35 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @setmacro to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @setDFmacro.dirname, i64 0, i64 0), i8* %26)
tail call void @free(i8* %26)
br label %36
36: ; preds = %30, %14, %8
ret void
}