#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*/ pid_t;

/* 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_map_label(int /*<<< orphan*/, char const *, char const *);
char *strerror(int /*<<< orphan*/);
void write_smack_map(pid_t pid, const char *map[][2]) {
  size_t i;
  for (i = 0; map[i][0] != NULL; ++i) {
    if (smack_map_label(pid, map[i][0], map[i][1]) != 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",
               203, "smack_map_label()", strerror(errno));
        exit(EXIT_FAILURE);
      } while (0);
  }
}


x86 assembly (clang, -O0):
<write_smack_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     1200 <write_smack_map+0xc0>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
call   1040 <smack_map_label@plt>
cmp    $0x0,%rax
je     11ea <write_smack_map+0xaa>
jmp    11ac <write_smack_map+0x6c>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    %rax,%r8
lea    0xe3c(%rip),%rdi
lea    0xe4d(%rip),%rsi
mov    $0xcb,%edx
lea    0xeef(%rip),%rcx
call   1030 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11ef <write_smack_map+0xaf>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1157 <write_smack_map+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_smack_map>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rsi),%rsi
test   %rsi,%rsi
je     117c <write_smack_map+0x3c>
mov    %edi,%ebp
add    $0x10,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    -0x8(%rbx),%rdx
mov    %ebp,%edi
call   1040 <smack_map_label@plt>
test   %rax,%rax
jne    1183 <write_smack_map+0x43>
mov    (%rbx),%rsi
add    $0x10,%rbx
test   %rsi,%rsi
jne    1160 <write_smack_map+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe68(%rip),%rdi
lea    0xe79(%rip),%rsi
lea    0xf20(%rip),%rcx
mov    $0xcb,%edx
mov    %rax,%r8
call   1030 <printf@plt>
mov    0x2e1e(%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 = [18 x i8] c"smack_map_label()\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @write_smack_map(i32 %0, [2 x i8*]* %1) {
%3 = alloca i32
%4 = alloca [2 x i8*]*
%5 = alloca i64
store i32 %0, i32* %3
store [2 x i8*]* %1, [2 x i8*]** %4
store i64 0, i64* %5
br label %6
6: ; preds = %36, %2
%7 = load [2 x i8*]*, [2 x i8*]** %4
%8 = load i64, i64* %5
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 %8
%10 = getelementptr inbounds [2 x i8*], [2 x i8*]* %9, i64 0, i64 0
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %39
13: ; preds = %6
%14 = load i32, i32* %3
%15 = load [2 x i8*]*, [2 x i8*]** %4
%16 = load i64, i64* %5
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %15, i64 %16
%18 = getelementptr inbounds [2 x i8*], [2 x i8*]* %17, i64 0, i64 0
%19 = load i8*, i8** %18
%20 = load [2 x i8*]*, [2 x i8*]** %4
%21 = load i64, i64* %5
%22 = getelementptr inbounds [2 x i8*], [2 x i8*]* %20, i64 %21
%23 = getelementptr inbounds [2 x i8*], [2 x i8*]* %22, i64 0, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @smack_map_label(i32 %14, i8* %19, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = 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 203, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; No predecessors!
br label %35
35: ; preds = %34, %13
br label %36
36: ; preds = %35
%37 = load i64, i64* %5
%38 = add i64 %37, 1
store i64 %38, i64* %5
br label %6
39: ; preds = %6
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 = [18 x i8] c"smack_map_label()\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @write_smack_map(i32 %0, [2 x i8*]* nocapture %1) {
%3 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %24, label %10
6: ; preds = %10
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 %17, i64 0
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %24, label %10
10: ; preds = %2, %6
%11 = phi i8* [ %8, %6 ], [ %4, %2 ]
%12 = phi i64 [ %17, %6 ], [ 0, %2 ]
%13 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 %12, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @smack_map_label(i32 %0, i8* %11, i8* %14)
%16 = icmp eq i64 %15, 0
%17 = add i64 %12, 1
br i1 %16, label %6, label %18
18: ; preds = %10
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = 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 203, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %6, %2
ret void
}