#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*/ buf;
typedef int /*<<< orphan*/ NO_CPU;

/* Variables and functions */
int atoi(char *);
int read_file(char *, char **, int);
scalar_t__ strncmp(char *, char const *, int);
int release_master() {
  static const char NO_CPU[] = "NO_CPU";
  char buf[7] = {0};
  int master = -1;
  int ret = read_file("/proc/litmus/release_master", &buf, sizeof(buf) - 1);
  if ((ret > 0) && (strncmp(buf, NO_CPU, sizeof(NO_CPU) - 1) != 0))
    master = atoi(buf);
  return master;
}


x86 assembly (clang, -O0):
<release_master>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x7(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1040 <memset@plt>
movl   $0xffffffff,-0xc(%rbp)
lea    -0x7(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x6,%edx
call   1050 <read_file@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11ac <release_master+0x6c>
lea    -0x7(%rbp),%rdi
lea    0xe74(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11ac <release_master+0x6c>
lea    -0x7(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<release_master>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xebb(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    $0x6,%edx
call   1040 <read_file@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
jle    118b <release_master+0x5b>
lea    0xe95(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     118b <release_master+0x5b>
lea    0x8(%rsp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@release_master.NO_CPU = internal constant [7 x i8] c"NO_CPU\00"
@.str = [28 x i8] c"/proc/litmus/release_master\00"
define i32 @release_master() {
%1 = alloca [7 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [7 x i8]* %1 to i8*
store i32 -1, i32* %2
%5 = bitcast [7 x i8]* %1 to i8**
%6 = call i32 @read_file(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8** %5, i32 6)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @release_master.NO_CPU, i64 0, i64 0), i32 6)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %2
br label %16
16: ; preds = %13, %9, %0
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@release_master.NO_CPU = internal constant [7 x i8] c"NO_CPU\00"
@.str = [28 x i8] c"/proc/litmus/release_master\00"
define i32 @release_master() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 x i8]* %1, i64 0, i64 0
%3 = bitcast [7 x i8]* %1 to i8**
%4 = call i32 @read_file(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8** %3, i32 6)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %0
%7 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @release_master.NO_CPU, i64 0, i64 0), i32 6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = call i32 @atoi(i8* %2)
br label %11
11: ; preds = %9, %6, %0
%12 = phi i32 [ %10, %9 ], [ -1, %6 ], [ -1, %0 ]
ret i32 %12
}