#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, int, char *, char *);
scalar_t__ smack_set_rule(char const *, char const *, char const *);
char *strerror(int /*<<< orphan*/);
void write_smack_rules(const char *rules[][3]) {
  size_t i;
  for (i = 0; rules[i][0] != NULL; ++i) {
    if (smack_set_rule(rules[i][0], rules[i][1], rules[i][2]) != 0)
      do {
        printf("\x1b[31m"
               "%s:%d: %s: %s\n"
               "\x1b[0m",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/Havner/ltp/refs/heads/"
               "smack-ns/testcases/kernel/security/smack/ns/smack_ns_launch.c",
               186, "smack_set_rule()", strerror(errno));
        exit(EXIT_FAILURE);
      } while (0);
  }
}


x86 assembly (clang, -O0):
<write_smack_rules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x18,-0x10(%rbp),%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     1201 <write_smack_rules+0xc1>
mov    -0x8(%rbp),%rax
imul   $0x18,-0x10(%rbp),%rcx
add    %rcx,%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rax
imul   $0x18,-0x10(%rbp),%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
mov    -0x8(%rbp),%rax
imul   $0x18,-0x10(%rbp),%rcx
add    %rcx,%rax
mov    0x10(%rax),%rdx
call   1040 <smack_set_rule@plt>
cmp    $0x0,%rax
je     11eb <write_smack_rules+0xab>
jmp    11ad <write_smack_rules+0x6d>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xe3b(%rip),%rdi
lea    0xe4c(%rip),%rsi
mov    $0xba,%edx
lea    0xeee(%rip),%rcx
call   1030 <printf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11f0 <write_smack_rules+0xb0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <write_smack_rules+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_smack_rules>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     116e <write_smack_rules+0x2e>
add    $0x18,%rbx
mov    -0x10(%rbx),%rsi
mov    -0x8(%rbx),%rdx
call   1040 <smack_set_rule@plt>
test   %rax,%rax
jne    1170 <write_smack_rules+0x30>
mov    (%rbx),%rdi
add    $0x18,%rbx
test   %rdi,%rdi
jne    1150 <write_smack_rules+0x10>
pop    %rbx
ret
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe7b(%rip),%rdi
lea    0xe8c(%rip),%rsi
lea    0xf33(%rip),%rcx
mov    $0xba,%edx
mov    %rax,%r8
call   1030 <printf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"\1B[31m%s:%d: %s: %s\0A\1B[0m\00"
@.str.1 = [174 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Havner/ltp/refs/heads/smack-ns/testcases/kernel/security/smack/ns/smack_ns_launch.c\00"
@.str.2 = [17 x i8] c"smack_set_rule()\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @write_smack_rules([3 x i8*]* %0) {
%2 = alloca [3 x i8*]*
%3 = alloca i64
store [3 x i8*]* %0, [3 x i8*]** %2
store i64 0, i64* %3
br label %4
4: ; preds = %38, %1
%5 = load [3 x i8*]*, [3 x i8*]** %2
%6 = load i64, i64* %3
%7 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 %6
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %41
11: ; preds = %4
%12 = load [3 x i8*]*, [3 x i8*]** %2
%13 = load i64, i64* %3
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %12, i64 %13
%15 = getelementptr inbounds [3 x i8*], [3 x i8*]* %14, i64 0, i64 0
%16 = load i8*, i8** %15
%17 = load [3 x i8*]*, [3 x i8*]** %2
%18 = load i64, i64* %3
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %17, i64 %18
%20 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 1
%21 = load i8*, i8** %20
%22 = load [3 x i8*]*, [3 x i8*]** %2
%23 = load i64, i64* %3
%24 = getelementptr inbounds [3 x i8*], [3 x i8*]* %22, i64 %23
%25 = getelementptr inbounds [3 x i8*], [3 x i8*]* %24, i64 0, i64 2
%26 = load i8*, i8** %25
%27 = call i64 @smack_set_rule(i8* %16, i8* %21, i8* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %11
br label %30
30: ; preds = %29
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str.1, i64 0, i64 0), i32 186, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; No predecessors!
br label %37
37: ; preds = %36, %11
br label %38
38: ; preds = %37
%39 = load i64, i64* %3
%40 = add i64 %39, 1
store i64 %40, i64* %3
br label %4
41: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"\1B[31m%s:%d: %s: %s\0A\1B[0m\00"
@.str.1 = [174 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Havner/ltp/refs/heads/smack-ns/testcases/kernel/security/smack/ns/smack_ns_launch.c\00"
@.str.2 = [17 x i8] c"smack_set_rule()\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @write_smack_rules([3 x i8*]* nocapture %0) {
%2 = getelementptr inbounds [3 x i8*], [3 x i8*]* %0, i64 0, i64 0
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %25, label %9
5: ; preds = %9
%6 = getelementptr inbounds [3 x i8*], [3 x i8*]* %0, i64 %18, i64 0
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %25, label %9
9: ; preds = %1, %5
%10 = phi i8* [ %7, %5 ], [ %3, %1 ]
%11 = phi i64 [ %18, %5 ], [ 0, %1 ]
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %0, i64 %11, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds [3 x i8*], [3 x i8*]* %0, i64 %11, i64 2
%15 = load i8*, i8** %14
%16 = tail call i64 @smack_set_rule(i8* %10, i8* %13, i8* %15)
%17 = icmp eq i64 %16, 0
%18 = add i64 %11, 1
br i1 %17, label %5, label %19
19: ; preds = %9
%20 = load i32, i32* @errno
%21 = tail call i8* @strerror(i32 %20)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str.1, i64 0, i64 0), i32 186, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %5, %1
ret void
}