#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 getpid();
int /*<<< orphan*/ gettaskcon();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ settaskcon();
int /*<<< orphan*/ sleep(int);
int main() {
  printf("pid: %d\n", getpid());
  printf("before change:\n");
  gettaskcon();
  if (settaskcon() != 0)
    return -1;
  printf("\n\nafter change:\n");
  gettaskcon();
  sleep(20);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <gettaskcon@plt>
mov    $0x0,%al
call   1050 <settaskcon@plt>
cmp    $0x0,%rax
je     11a8 <main+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <main+0x7e>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <gettaskcon@plt>
mov    $0x14,%edi
call   1060 <sleep@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <gettaskcon@plt>
xor    %eax,%eax
call   1060 <settaskcon@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     11a1 <main+0x41>
pop    %rcx
ret
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <gettaskcon@plt>
mov    $0x14,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"pid: %d\0A\00"
@.str.1 = [16 x i8] c"before change:\0A\00"
@.str.2 = [17 x i8] c"\0A\0Aafter change:\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @getpid()
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 (...) @gettaskcon()
%6 = call i64 (...) @settaskcon()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %13
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (...) @gettaskcon()
%12 = call i32 @sleep(i32 20)
store i32 0, i32* %1
br label %13
13: ; preds = %9, %8
%14 = load i32, i32* %1
ret i32 %14
}

LLVM IR (-O2):
@.str = [9 x i8] c"pid: %d\0A\00"
@str = [15 x i8] c"before change:\00"
@str.3 = [16 x i8] c"\0A\0Aafter change:\00"
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @gettaskcon()
%5 = tail call i64 (...) @settaskcon()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
%9 = tail call i32 (...) @gettaskcon()
%10 = tail call i32 @sleep(i32 20)
br label %11
11: ; preds = %0, %7
%12 = phi i32 [ 0, %7 ], [ -1, %0 ]
ret i32 %12
}