#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int /*<<< orphan*/ strncmp(char *, char const *, int);
int system(char *);
int /*<<< orphan*/ tst_warn(char *, ...);
void remove_tmpdir(const char *path) {
  if (!strncmp("/tmp/", path, sizeof("/tmp/"))) {
    tst_warn("Path '%s' doesn't start with /tmp/, "
             "omitting cleanup",
             path);
    return;
  }
  char buf[256];
  int ret;
  snprintf(buf, sizeof(buf), "rm -rf '%s'", path);
  ret = system(buf);
  if (ret)
    tst_warn("Failed to clean temp dir.");
}


x86 assembly (clang, -O0):
<remove_tmpdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1184 <remove_tmpdir+0x44>
mov    -0x8(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1060 <tst_warn@plt>
jmp    11cd <remove_tmpdir+0x8d>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x100,%esi
lea    0xea0(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
je     11cd <remove_tmpdir+0x8d>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1060 <tst_warn@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_tmpdir>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11a4 <remove_tmpdir+0x64>
lea    0xecf(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
test   %eax,%eax
je     1199 <remove_tmpdir+0x59>
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1060 <tst_warn@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
jmp    1060 <tst_warn@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"/tmp/\00"
@.str.1 = [53 x i8] c"Path '%s' doesn't start with /tmp/, omitting cleanup\00"
@.str.2 = [12 x i8] c"rm -rf '%s'\00"
@.str.3 = [26 x i8] c"Failed to clean temp dir.\00"
define void @remove_tmpdir(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i32 6)
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @tst_warn(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %21
11: ; preds = %1
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 @snprintf(i8* %12, i32 256, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i32 @system(i8* %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 (i8*, ...) @tst_warn(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %8, %19, %11
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"/tmp/\00"
@.str.1 = [53 x i8] c"Path '%s' doesn't start with /tmp/, omitting cleanup\00"
@.str.2 = [12 x i8] c"rm -rf '%s'\00"
@.str.3 = [26 x i8] c"Failed to clean temp dir.\00"
define void @remove_tmpdir(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i32 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i32 6)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @tst_warn(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
7: ; preds = %1
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @snprintf(i8* %8, i32 256, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%10 = call i32 @system(i8* %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = call i32 (i8*, ...) @tst_warn(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
br label %15
15: ; preds = %14, %5
ret void
}