#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*/ my_error(int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void AddPart(char *d, char *s, int mlen) {
  int m, n;
  m = strlen(d);
  n = strlen(s);
  if (mlen < m + n + 2) {
    my_error(5, "Addpart len");
  } else {
    if (*(d + m - 1) != '/' && *s != '/') {
      if (*d)
        (void)strcat(d, "/");
    }
    (void)strcat(d, s);
  }
}


x86 assembly (clang, -O0):
<AddPart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1185 <AddPart+0x55>
mov    $0x5,%edi
lea    0xe85(%rip),%rsi
call   1050 <my_error@plt>
jmp    11da <AddPart+0xaa>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     11cd <AddPart+0x9d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     11cd <AddPart+0x9d>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c8 <AddPart+0x98>
mov    -0x8(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcat@plt>
jmp    11cd <AddPart+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddPart>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
add    $0x2,%eax
cmp    %ebp,%eax
jle    1172 <AddPart+0x42>
lea    0xea2(%rip),%rsi
mov    $0x5,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <my_error@plt>
movslq %ebx,%rax
cmpb   $0x2f,-0x1(%r15,%rax,1)
je     1198 <AddPart+0x68>
cmpb   $0x2f,(%r14)
je     1198 <AddPart+0x68>
cmpb   $0x0,(%r15)
je     1198 <AddPart+0x68>
lea    0xe7c(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcat@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Addpart len\00"
@.str.1 = [2 x i8] c"/\00"
define void @AddPart(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
%11 = load i8*, i8** %5
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = add nsw i32 %14, %15
%17 = add nsw i32 %16, 2
%18 = icmp slt i32 %13, %17
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = call i32 @my_error(i32 5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %47
21: ; preds = %3
%22 = load i8*, i8** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 -1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 47
br i1 %29, label %30, label %43
30: ; preds = %21
%31 = load i8*, i8** %5
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 47
br i1 %34, label %35, label %43
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i8*, i8** %4
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42, %30, %21
%44 = load i8*, i8** %4
%45 = load i8*, i8** %5
%46 = call i32 @strcat(i8* %44, i8* %45)
br label %47
47: ; preds = %43, %19
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Addpart len\00"
@.str.1 = [2 x i8] c"/\00"
define void @AddPart(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, 2
%7 = add i32 %6, %5
%8 = icmp sgt i32 %7, %2
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @my_error(i32 5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %27
11: ; preds = %3
%12 = sext i32 %4 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 -1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %25, label %17
17: ; preds = %11
%18 = load i8, i8* %1
%19 = icmp eq i8 %18, 47
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = load i8, i8* %0
%22 = icmp eq i8 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %20, %23, %17, %11
%26 = tail call i32 @strcat(i8* %0, i8* %1)
br label %27
27: ; preds = %25, %9
ret void
}