#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 WEXITSTATUS(int);
int create_net_namespace(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdout;
int system(char *);
int main(void) {
  int ret, status = 0;
  ret = system("netns_parent_share.sh");
  status = WEXITSTATUS(ret);
  if (ret == -1 || status != 0) {
    printf("Error while executing the script %s\n", "netns_parent_share.sh");
    fflush(stdout);
    exit(1);
  }
  status =
      create_net_namespace("netns_parent_view.sh", "netns_child_propagate.sh");
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe83(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     11a4 <main+0x44>
cmpl   $0x0,-0xc(%rbp)
je     11cf <main+0x6f>
lea    0xe6b(%rip),%rdi
lea    0xe4e(%rip),%rsi
call   1050 <printf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe65(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1030 <create_net_namespace@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe98(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <WEXITSTATUS@plt>
cmp    $0xffffffff,%ebx
je     1193 <main+0x33>
test   %eax,%eax
jne    1193 <main+0x33>
lea    0xeb5(%rip),%rdi
lea    0xec3(%rip),%rsi
pop    %rbx
jmp    1030 <create_net_namespace@plt>
lea    0xe7c(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"netns_parent_share.sh\00"
@.str.1 = [37 x i8] c"Error while executing the script %s\0A\00"
@stdout = global i32 0
@.str.2 = [21 x i8] c"netns_parent_view.sh\00"
@.str.3 = [25 x i8] c"netns_child_propagate.sh\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @WEXITSTATUS(i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9, %0
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %9
%18 = call i32 @create_net_namespace(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 %18, i32* %3
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [22 x i8] c"netns_parent_share.sh\00"
@.str.1 = [37 x i8] c"Error while executing the script %s\0A\00"
@stdout = global i32 0
@.str.2 = [21 x i8] c"netns_parent_view.sh\00"
@.str.3 = [25 x i8] c"netns_child_propagate.sh\00"
define i32 @main() {
%1 = tail call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @WEXITSTATUS(i32 %1)
%3 = icmp eq i32 %1, -1
%4 = icmp ne i32 %2, 0
%5 = select i1 %3, i1 true, i1 %4
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = tail call i32 @fflush(i32 %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = tail call i32 @create_net_namespace(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
ret i32 %12
}