#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*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
int unlink(char *);
int remove_file(char const *dir, char const *name) {
  char buf[strlen(dir) + strlen(name) + sizeof("/")];
  strcpy(buf, dir);
  strcat(buf, "/");
  strcat(buf, name);
  return unlink(buf);
}


x86 assembly (clang, -O0):
<remove_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,%rdx
lea    0x2(%rcx,%rdx,1),%rax
mov    %rsp,%rsi
mov    %rsi,-0x18(%rbp)
lea    0x11(%rcx,%rdx,1),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %rbx,%rax
add    $0x11,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i32 @remove_file(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %8, %10
%12 = add i64 %11, 2
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i8, i64 %12
store i64 %12, i64* %6
%15 = load i8*, i8** %3
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = load i8*, i8** %4
%19 = call i32 @strcat(i8* %14, i8* %18)
%20 = call i32 @unlink(i8* %14)
%21 = load i8*, i8** %5
ret i32 %20
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i32 @remove_file(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add i64 %3, 2
%6 = add i64 %5, %4
%7 = alloca i8, i64 %6
%8 = call i32 @strcpy(i8* %7, i8* %0)
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcat(i8* %7, i8* %1)
%11 = call i32 @unlink(i8* %7)
ret i32 %11
}