#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*/ lBuff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int sscanf(char *, char *, int *, int *);
int osx9orBetter() {
  static int lOsx9orBetter = -1;
  char lBuff[1024];
  FILE *lIn;
  int V, v;
  if (lOsx9orBetter < 0) {
    lOsx9orBetter = 0;
    lIn = popen("osascript -e 'set osver to system version of (system info)'",
                "r");
    if ((fgets(lBuff, sizeof(lBuff), lIn) != NULL) &&
        (2 == sscanf(lBuff, "%d.%d", &V, &v))) {
      V = V * 100 + v;
      if (V >= 1009) {
        lOsx9orBetter = 1;
      }
    }
    pclose(lIn);
  }
  return lOsx9orBetter;
}


x86 assembly (clang, -O0):
<osx9orBetter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
cmpl   $0x0,0x2eee(%rip)
jge    120c <osx9orBetter+0xcc>
movl   $0x0,0x2ede(%rip)
lea    0xe97(%rip),%rdi
lea    0xecc(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x408(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1200 <osx9orBetter+0xc0>
lea    -0x400(%rbp),%rdi
lea    0xe92(%rip),%rsi
lea    -0x40c(%rbp),%rdx
lea    -0x410(%rbp),%rcx
call   1050 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
jne    1200 <osx9orBetter+0xc0>
imul   $0x64,-0x40c(%rbp),%eax
add    -0x410(%rbp),%eax
mov    %eax,-0x40c(%rbp)
cmpl   $0x3f1,-0x40c(%rbp)
jl     11fb <osx9orBetter+0xbb>
movl   $0x1,0x2e45(%rip)
jmp    1200 <osx9orBetter+0xc0>
mov    -0x408(%rbp),%rdi
call   1030 <pclose@plt>
mov    0x2e2e(%rip),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<osx9orBetter>:
push   %rbx
sub    $0x410,%rsp
mov    0x2ef2(%rip),%eax
test   %eax,%eax
jns    11d9 <osx9orBetter+0x99>
movl   $0x0,0x2ee0(%rip)
lea    0xe99(%rip),%rdi
lea    0xece(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11cb <osx9orBetter+0x8b>
lea    0xeaa(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <sscanf@plt>
cmp    $0x2,%eax
jne    11cb <osx9orBetter+0x8b>
imul   $0x64,0x8(%rsp),%eax
add    0xc(%rsp),%eax
mov    %eax,0x8(%rsp)
cmp    $0x3f1,%eax
jl     11cb <osx9orBetter+0x8b>
movl   $0x1,0x2e75(%rip)
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    0x2e67(%rip),%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@osx9orBetter.lOsx9orBetter = internal global i32 -1
@.str = [60 x i8] c"osascript -e 'set osver to system version of (system info)'\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d.%d\00"
define i32 @osx9orBetter() {
%1 = alloca [1024 x i8]
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = load i32, i32* @osx9orBetter.lOsx9orBetter
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %29
7: ; preds = %0
store i32 0, i32* @osx9orBetter.lOsx9orBetter
%8 = call i32* @popen(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32* @fgets(i8* %9, i32 1024, i32* %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %26
13: ; preds = %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4)
%16 = icmp eq i32 2, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 100
%20 = load i32, i32* %4
%21 = add nsw i32 %19, %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = icmp sge i32 %22, 1009
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 1, i32* @osx9orBetter.lOsx9orBetter
br label %25
25: ; preds = %24, %17
br label %26
26: ; preds = %25, %13, %7
%27 = load i32*, i32** %2
%28 = call i32 @pclose(i32* %27)
br label %29
29: ; preds = %26, %0
%30 = load i32, i32* @osx9orBetter.lOsx9orBetter
ret i32 %30
}

LLVM IR (-O2):
@osx9orBetter.lOsx9orBetter = internal unnamed_addr global i32 -1
@.str = [60 x i8] c"osascript -e 'set osver to system version of (system info)'\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d.%d\00"
define i32 @osx9orBetter() {
%1 = alloca [1024 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @osx9orBetter.lOsx9orBetter
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %0
store i32 0, i32* @osx9orBetter.lOsx9orBetter
%10 = tail call i32* @popen(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32* @fgets(i8* %4, i32 1024, i32* %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %23, label %13
13: ; preds = %9
%14 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3)
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, 100
%19 = load i32, i32* %3
%20 = add nsw i32 %18, %19
store i32 %20, i32* %2
%21 = icmp sgt i32 %20, 1008
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 1, i32* @osx9orBetter.lOsx9orBetter
br label %23
23: ; preds = %16, %22, %13, %9
%24 = call i32 @pclose(i32* %10)
%25 = load i32, i32* @osx9orBetter.lOsx9orBetter
br label %26
26: ; preds = %23, %0
%27 = phi i32 [ %25, %23 ], [ %7, %0 ]
ret i32 %27
}