#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*/ LOG_ERR;
int PATH_MAX;
scalar_t__ apply_cipso(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *);
void modify_cipso_rules(char *file) {
  char path[PATH_MAX];
  sprintf(path, "%s/%s", "/etc/smack/cipso.d", file);
  if (apply_cipso(path))
    syslog(LOG_ERR, "Failed to load cipso rules (%s) : %m", path);
}


x86 assembly (clang, -O0):
<modify_cipso_rules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x20(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
lea    0xe8d(%rip),%rsi
lea    0xe8c(%rip),%rdx
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <apply_cipso@plt>
cmp    $0x0,%rax
je     11ab <modify_cipso_rules+0x7b>
mov    -0x20(%rbp),%rdx
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1030 <syslog@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modify_cipso_rules>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdi,%rcx
mov    0x2eb0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xea6(%rip),%rsi
lea    0xea5(%rip),%rdx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <apply_cipso@plt>
test   %rax,%rax
je     118e <modify_cipso_rules+0x5e>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
mov    %rbx,%rdx
call   1030 <syslog@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [19 x i8] c"/etc/smack/cipso.d\00"
@LOG_ERR = global i32 0
@.str.2 = [37 x i8] c"Failed to load cipso rules (%s) : %m\00"
define void @modify_cipso_rules(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
%9 = load i8*, i8** %2
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i64 @apply_cipso(i8* %8)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* @LOG_ERR
%15 = call i32 @syslog(i32 %14, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %16
16: ; preds = %13, %1
%17 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [19 x i8] c"/etc/smack/cipso.d\00"
@LOG_ERR = global i32 0
@.str.2 = [37 x i8] c"Failed to load cipso rules (%s) : %m\00"
define void @modify_cipso_rules(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = call i64 @apply_cipso(i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @LOG_ERR
%10 = call i32 @syslog(i32 %9, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %11
11: ; preds = %8, %1
ret void
}