#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*/ IPPROTO_UDP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ exit(int);
int fsetxattr(int, char *, char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char message[256];
  char *anin = "security.SMACK64IPIN";
  char *anout = "security.SMACK64IPOUT";
  char *annot = "security.SMACK64IPNOT";
  char *avin = "TheOne";
  char *avout = "TheOther";
  char *avnot = "TheBadValue";
  int sock;
  int rc;
  if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
    sprintf(message, "%s Socket creation failure", argv[0]);
    perror(message);
    exit(1);
  }
  rc = fsetxattr(sock, anin, avin, strlen(avin) + 1, 0);
  if (rc < 0) {
    sprintf(message, "%s fsetxattr of %s to %s failure", argv[0], anin, avin);
    perror(message);
    exit(1);
  }
  rc = fsetxattr(sock, anout, avout, strlen(avout) + 1, 0);
  if (rc < 0) {
    sprintf(message, "%s fsetxattr of %s to %s failure", argv[0], anout, avout);
    perror(message);
    exit(1);
  }
  rc = fsetxattr(sock, annot, avnot, strlen(avnot) + 1, 0);
  if (rc >= 0) {
    sprintf(message, "%s fsetxattr of %s to %s succeeded in error", argv[0],
            anout, avout);
    perror(message);
    exit(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x118(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x120(%rbp)
lea    0xe8f(%rip),%rax
mov    %rax,-0x128(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x130(%rbp)
lea    0xe90(%rip),%rax
mov    %rax,-0x138(%rbp)
lea    0xe8b(%rip),%rax
mov    %rax,-0x140(%rbp)
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
mov    0x2de2(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,-0x144(%rbp)
cmp    $0x0,%eax
jge    122e <main+0xce>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x144(%rbp),%eax
mov    %eax,-0x15c(%rbp)
mov    -0x118(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x130(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x15c(%rbp),%edi
mov    -0x158(%rbp),%rsi
mov    -0x150(%rbp),%rdx
mov    %rax,%rcx
add    $0x1,%rcx
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
mov    %eax,-0x148(%rbp)
cmpl   $0x0,-0x148(%rbp)
jge    12d8 <main+0x178>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x118(%rbp),%rcx
mov    -0x130(%rbp),%r8
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x144(%rbp),%eax
mov    %eax,-0x174(%rbp)
mov    -0x120(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x138(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x174(%rbp),%edi
mov    -0x170(%rbp),%rsi
mov    -0x168(%rbp),%rdx
mov    %rax,%rcx
add    $0x1,%rcx
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
mov    %eax,-0x148(%rbp)
cmpl   $0x0,-0x148(%rbp)
jge    1382 <main+0x222>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x120(%rbp),%rcx
mov    -0x138(%rbp),%r8
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x144(%rbp),%eax
mov    %eax,-0x18c(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x140(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x140(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x18c(%rbp),%edi
mov    -0x188(%rbp),%rsi
mov    -0x180(%rbp),%rdx
mov    %rax,%rcx
add    $0x1,%rcx
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
mov    %eax,-0x148(%rbp)
cmpl   $0x0,-0x148(%rbp)
jl     142c <main+0x2cc>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x120(%rbp),%rcx
mov    -0x138(%rbp),%r8
lea    0xc8a(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
test   %eax,%eax
jns    119c <main+0x4c>
mov    (%rbx),%rdx
lea    0xed3(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    124c <main+0xfc>
mov    %eax,%ebp
lea    0xe5b(%rip),%rsi
lea    0xe95(%rip),%rdx
mov    $0x7,%ecx
mov    %eax,%edi
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
test   %eax,%eax
jns    11d9 <main+0x89>
mov    (%rbx),%rdx
lea    0xeaf(%rip),%rsi
lea    0xe30(%rip),%rcx
lea    0xe6a(%rip),%r8
jmp    123f <main+0xef>
lea    0xe35(%rip),%rsi
lea    0xe61(%rip),%rdx
mov    $0x9,%ecx
mov    %ebp,%edi
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
test   %eax,%eax
jns    1206 <main+0xb6>
mov    (%rbx),%rdx
lea    0xe74(%rip),%rsi
jmp    1231 <main+0xe1>
lea    0xe1e(%rip),%rsi
lea    0xe3d(%rip),%rdx
mov    $0xc,%ecx
mov    %ebp,%edi
xor    %r8d,%r8d
call   1030 <fsetxattr@plt>
test   %eax,%eax
js     125e <main+0x10e>
mov    (%rbx),%rdx
lea    0xe68(%rip),%rsi
lea    0xddd(%rip),%rcx
lea    0xe09(%rip),%r8
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"security.SMACK64IPIN\00"
@.str.1 = [22 x i8] c"security.SMACK64IPOUT\00"
@.str.2 = [22 x i8] c"security.SMACK64IPNOT\00"
@.str.3 = [7 x i8] c"TheOne\00"
@.str.4 = [9 x i8] c"TheOther\00"
@.str.5 = [12 x i8] c"TheBadValue\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.6 = [27 x i8] c"%s Socket creation failure\00"
@.str.7 = [33 x i8] c"%s fsetxattr of %s to %s failure\00"
@.str.8 = [44 x i8] c"%s fsetxattr of %s to %s succeeded in error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8** %12
%15 = load i32, i32* @PF_INET
%16 = load i32, i32* @SOCK_DGRAM
%17 = load i32, i32* @IPPROTO_UDP
%18 = call i32 @socket(i32 %15, i32 %16, i32 %17)
store i32 %18, i32* %13
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %2
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%27 = call i32 @perror(i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* %13
%31 = load i8*, i8** %7
%32 = load i8*, i8** %10
%33 = load i8*, i8** %10
%34 = call i64 @strlen(i8* %33)
%35 = add nsw i64 %34, 1
%36 = call i32 @fsetxattr(i32 %30, i8* %31, i8* %32, i64 %35, i32 0)
store i32 %36, i32* %14
%37 = load i32, i32* %14
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %29
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = load i8*, i8** %7
%45 = load i8*, i8** %10
%46 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %43, i8* %44, i8* %45)
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%48 = call i32 @perror(i8* %47)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %29
%51 = load i32, i32* %13
%52 = load i8*, i8** %8
%53 = load i8*, i8** %11
%54 = load i8*, i8** %11
%55 = call i64 @strlen(i8* %54)
%56 = add nsw i64 %55, 1
%57 = call i32 @fsetxattr(i32 %51, i8* %52, i8* %53, i64 %56, i32 0)
store i32 %57, i32* %14
%58 = load i32, i32* %14
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %71
60: ; preds = %50
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = load i8*, i8** %8
%66 = load i8*, i8** %11
%67 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %61, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %64, i8* %65, i8* %66)
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%69 = call i32 @perror(i8* %68)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %50
%72 = load i32, i32* %13
%73 = load i8*, i8** %9
%74 = load i8*, i8** %12
%75 = load i8*, i8** %12
%76 = call i64 @strlen(i8* %75)
%77 = add nsw i64 %76, 1
%78 = call i32 @fsetxattr(i32 %72, i8* %73, i8* %74, i64 %77, i32 0)
store i32 %78, i32* %14
%79 = load i32, i32* %14
%80 = icmp sge i32 %79, 0
br i1 %80, label %81, label %92
81: ; preds = %71
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = load i8*, i8** %8
%87 = load i8*, i8** %11
%88 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %82, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i8* %85, i8* %86, i8* %87)
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%90 = call i32 @perror(i8* %89)
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %71
%93 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [21 x i8] c"security.SMACK64IPIN\00"
@.str.1 = [22 x i8] c"security.SMACK64IPOUT\00"
@.str.2 = [22 x i8] c"security.SMACK64IPNOT\00"
@.str.3 = [7 x i8] c"TheOne\00"
@.str.4 = [9 x i8] c"TheOther\00"
@.str.5 = [12 x i8] c"TheBadValue\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.6 = [27 x i8] c"%s Socket creation failure\00"
@.str.7 = [33 x i8] c"%s fsetxattr of %s to %s failure\00"
@.str.8 = [44 x i8] c"%s fsetxattr of %s to %s succeeded in error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @PF_INET
%6 = load i32, i32* @SOCK_DGRAM
%7 = load i32, i32* @IPPROTO_UDP
%8 = tail call i32 @socket(i32 %5, i32 %6, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %11)
%13 = call i32 @perror(i8* %4)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = tail call i32 @fsetxattr(i32 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 7, i32 0)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8*, i8** %1
%20 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @perror(i8* %4)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %15
%24 = tail call i32 @fsetxattr(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i64 9, i32 0)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8*, i8** %1
%28 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @perror(i8* %4)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %23
%32 = tail call i32 @fsetxattr(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 12, i32 0)
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i8*, i8** %1
%36 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i8* %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%37 = call i32 @perror(i8* %4)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %31
%40 = tail call i32 @exit(i32 0)
unreachable
}