#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*/ abort();
int backtrace(void **, int);
int /*<<< orphan*/ backtrace_symbols_fd(void **, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char const *, int);
void enforcer(const char *pathname) {
  if (strncmp("/tmp/", pathname, 5) == 0) {
    int nframes;
    void *buffer[(100)];
    fprintf(stderr, "tmperamental: caught a write to /tmp.\n");
    nframes = backtrace(buffer, (100));
    if (nframes > (1))
      backtrace_symbols_fd(buffer + (1), nframes + (1), 2);
    abort();
  }
}


x86 assembly (clang, -O0):
<enforcer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x330,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x5,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    11d3 <enforcer+0x83>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1070 <fprintf@plt>
lea    -0x330(%rbp),%rdi
mov    $0x64,%esi
call   1060 <backtrace@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    11cc <enforcer+0x7c>
lea    -0x330(%rbp),%rdi
add    $0x8,%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    $0x2,%edx
call   1030 <backtrace_symbols_fd@plt>
mov    $0x0,%al
call   1040 <abort@plt>
add    $0x330,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enforcer>:
sub    $0x328,%rsp
mov    %rdi,%rsi
lea    0xe9f(%rip),%rdi
mov    $0x5,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1178 <enforcer+0x28>
add    $0x328,%rsp
ret
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1070 <fprintf@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1060 <backtrace@plt>
cmp    $0x2,%eax
jl     11b3 <enforcer+0x63>
lea    0x8(%rsp),%rdi
add    $0x1,%eax
mov    %eax,%esi
mov    $0x2,%edx
call   1030 <backtrace_symbols_fd@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"/tmp/\00"
@stderr = global i32 0
@.str.1 = [39 x i8] c"tmperamental: caught a write to /tmp.\0A\00"
define void @enforcer(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [100 x i8*]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i32 5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8*], [100 x i8*]* %4, i64 0, i64 0
%12 = call i32 @backtrace(i8** %11, i32 100)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %8
%16 = getelementptr inbounds [100 x i8*], [100 x i8*]* %4, i64 0, i64 0
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = call i32 @backtrace_symbols_fd(i8** %17, i32 %19, i32 2)
br label %21
21: ; preds = %15, %8
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %1
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"/tmp/\00"
@stderr = global i32 0
@.str.1 = [39 x i8] c"tmperamental: caught a write to /tmp.\0A\00"
define void @enforcer(i8* %0) {
%2 = alloca [100 x i8*]
%3 = tail call i64 @strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i32 5)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %1
%6 = bitcast [100 x i8*]* %2 to i8*
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 0
%10 = call i32 @backtrace(i8** %9, i32 100)
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %5
%13 = getelementptr inbounds [100 x i8*], [100 x i8*]* %2, i64 0, i64 1
%14 = add nuw nsw i32 %10, 1
%15 = call i32 @backtrace_symbols_fd(i8** %13, i32 %14, i32 2)
br label %16
16: ; preds = %12, %5
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %1
ret void
}