#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 */
struct sysinfo {
  int procs;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
int main(int argc, char *argv[]) {
  int count;
  FILE *ps = popen("ps axHo lwp,cmd|wc -l", "r");
  fscanf(ps, "%d", &count);
  pclose(ps);
  struct sysinfo si;
  sysinfo(&si);
  if (si.procs - 200 > count && argc == 1) {
    printf("[!] definitely in LXC\n");
    return 1;
  }
  printf("[+] either not in LXC or an LXC environment was not detected\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe90(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <pclose@plt>
lea    -0x28(%rbp),%rdi
call   1070 <sysinfo@plt>
mov    -0x28(%rbp),%eax
sub    $0xc8,%eax
cmp    -0x14(%rbp),%eax
jle    11d6 <main+0x86>
cmpl   $0x1,-0x8(%rbp)
jne    11d6 <main+0x86>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <main+0x99>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xea4(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%rbx
lea    0xea6(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <pclose@plt>
mov    %rsp,%rdi
call   1070 <sysinfo@plt>
mov    $0xffffff38,%eax
add    (%rsp),%eax
cmp    0x4(%rsp),%eax
setg   %al
cmp    $0x1,%ebp
sete   %cl
and    %al,%cl
lea    0xeab(%rip),%rax
lea    0xe67(%rip),%rdi
cmovne %rax,%rdi
movzbl %cl,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32 }
@.str = [22 x i8] c"ps axHo lwp,cmd|wc -l\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"[!] definitely in LXC\0A\00"
@.str.4 = [62 x i8] c"[+] either not in LXC or an LXC environment was not detected\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca %struct.sysinfo
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @popen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%12 = load i32*, i32** %7
%13 = call i32 @pclose(i32* %12)
%14 = call i32 @sysinfo(%struct.sysinfo* %8)
%15 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %8, i32 0, i32 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %16, 200
%18 = load i32, i32* %6
%19 = icmp sgt i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %27
25: ; preds = %20, %2
%26 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %27
27: ; preds = %25, %23
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.sysinfo = type { i32 }
@.str = [22 x i8] c"ps axHo lwp,cmd|wc -l\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [61 x i8] c"[+] either not in LXC or an LXC environment was not detected\00"
@str.5 = [22 x i8] c"[!] definitely in LXC\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca %struct.sysinfo
%5 = bitcast i32* %3 to i8*
%6 = tail call i32* @popen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%8 = call i32 @pclose(i32* %6)
%9 = bitcast %struct.sysinfo* %4 to i8*
%10 = call i32 @sysinfo(%struct.sysinfo* %4)
%11 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %4, i64 0, i32 0
%12 = load i32, i32* %11
%13 = add nsw i32 %12, -200
%14 = load i32, i32* %3
%15 = icmp sgt i32 %13, %14
%16 = icmp eq i32 %0, 1
%17 = and i1 %16, %15
%18 = select i1 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0)
%19 = zext i1 %17 to i32
%20 = call i32 @puts(i8* dereferenceable(1) %18)
ret i32 %19
}