#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*/ fatalx(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void makedfn(char *dirname, char *fname, char *outname, int maxstr) {
  char *ss;
  int len;
  if ((dirname == NULL) || (fname[0] == '/')) {
    len = strlen(fname);
    if (len >= maxstr)
      fatalx("(makedfn) maxstr too short\n");
    strcpy(outname, fname);
    return;
  }
  len = strlen(dirname) + strlen(fname) + 1;
  if (len >= maxstr)
    fatalx("(makedfn) maxstr too short\n");
  ss = outname;
  strcpy(ss, dirname);
  ss = ss + strlen(dirname);
  ss[0] = '/';
  ++ss;
  strcpy(ss, fname);
}


x86 assembly (clang, -O0):
<makedfn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1162 <makedfn+0x32>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1198 <makedfn+0x68>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     1186 <makedfn+0x56>
lea    0xe7f(%rip),%rdi
call   1040 <fatalx@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1228 <makedfn+0xf8>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11d2 <makedfn+0xa2>
lea    0xe33(%rip),%rdi
call   1040 <fatalx@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makedfn>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
test   %rdi,%rdi
je     114b <makedfn+0x1b>
cmpb   $0x2f,(%r15)
jne    1168 <makedfn+0x38>
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    %ebp,%eax
jl     1163 <makedfn+0x33>
lea    0xea2(%rip),%rdi
call   1040 <fatalx@plt>
mov    %r14,%rdi
jmp    11b3 <makedfn+0x83>
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1050 <strlen@plt>
add    %r12d,%eax
add    $0x1,%eax
cmp    %ebp,%eax
jl     1191 <makedfn+0x61>
lea    0xe74(%rip),%rdi
call   1040 <fatalx@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x2f,(%r14,%rax,1)
lea    (%r14,%rax,1),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"(makedfn) maxstr too short\0A\00"
define void @makedfn(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = icmp eq i8* %11, null
br i1 %12, label %19, label %13
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
br i1 %18, label %19, label %31
19: ; preds = %13, %4
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = load i32, i32* %8
%24 = icmp sge i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @fatalx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
%28 = load i8*, i8** %7
%29 = load i8*, i8** %6
%30 = call i32 @strcpy(i8* %28, i8* %29)
br label %60
31: ; preds = %13
%32 = load i8*, i8** %5
%33 = call i32 @strlen(i8* %32)
%34 = load i8*, i8** %6
%35 = call i32 @strlen(i8* %34)
%36 = add nsw i32 %33, %35
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
%38 = load i32, i32* %10
%39 = load i32, i32* %8
%40 = icmp sge i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %31
%42 = call i32 @fatalx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %31
%44 = load i8*, i8** %7
store i8* %44, i8** %9
%45 = load i8*, i8** %9
%46 = load i8*, i8** %5
%47 = call i32 @strcpy(i8* %45, i8* %46)
%48 = load i8*, i8** %9
%49 = load i8*, i8** %5
%50 = call i32 @strlen(i8* %49)
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8* %52, i8** %9
%53 = load i8*, i8** %9
%54 = getelementptr inbounds i8, i8* %53, i64 0
store i8 47, i8* %54
%55 = load i8*, i8** %9
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %9
%57 = load i8*, i8** %9
%58 = load i8*, i8** %6
%59 = call i32 @strcpy(i8* %57, i8* %58)
br label %60
60: ; preds = %43, %27
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"(makedfn) maxstr too short\0A\00"
define void @makedfn(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 47
br i1 %8, label %9, label %16
9: ; preds = %6, %4
%10 = tail call i32 @strlen(i8* %1)
%11 = icmp slt i32 %10, %3
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @fatalx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = tail call i32 @strcpy(i8* %2, i8* %1)
br label %31
16: ; preds = %6
%17 = tail call i32 @strlen(i8* %0)
%18 = tail call i32 @strlen(i8* %1)
%19 = add i32 %17, 1
%20 = add i32 %19, %18
%21 = icmp slt i32 %20, %3
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = tail call i32 @fatalx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %16
%25 = tail call i32 @strcpy(i8* %2, i8* %0)
%26 = tail call i32 @strlen(i8* %0)
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %2, i64 %27
store i8 47, i8* %28
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = tail call i32 @strcpy(i8* %29, i8* %1)
br label %31
31: ; preds = %24, %14
ret void
}