#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 utsname {
  int /*<<< orphan*/ release;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sscanf(int /*<<< orphan*/, char *, int *, int *, int *);
scalar_t__ uname(struct utsname *);
int __detect_PLATFORM_ENV_OS_VER_DETAIL() {
  struct utsname name;
  int v, v1, v2, v3;
  if (uname(&name) < 0) {
    printf("TT_ENV_OS_VER_UNKNOWN");
    return 0;
  }
  v1 = v2 = v3 = 0;
  if (sscanf(name.release, "%d.%d.%d", &v1, &v2, &v3) <= 0) {
    printf("TT_ENV_OS_VER_UNKNOWN");
    return 0;
  }
  v = (v1) << 16 | (v2) << 8 | (v3);
  printf("0x%x", v);
  return 0;
}


x86 assembly (clang, -O0):
<__detect_PLATFORM_ENV_OS_VER_DETAIL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
call   1040 <uname@plt>
cmp    $0x0,%rax
jge    1165 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0x35>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0xb5>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    0xe92(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1050 <sscanf@plt>
cmp    $0x0,%rax
jg     11b9 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0x89>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0xb5>
mov    -0x10(%rbp),%eax
shl    $0x10,%eax
mov    -0x14(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__detect_PLATFORM_ENV_OS_VER_DETAIL>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
call   1040 <uname@plt>
test   %rax,%rax
js     11a3 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0x73>
movl   $0x0,0x4(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    0x10(%rsp),%edi
lea    0xeb0(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1050 <sscanf@plt>
test   %rax,%rax
jle    11a3 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0x73>
mov    0xc(%rsp),%eax
shl    $0x10,%eax
mov    0x8(%rsp),%esi
shl    $0x8,%esi
or     %eax,%esi
or     0x4(%rsp),%esi
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11b1 <__detect_PLATFORM_ENV_OS_VER_DETAIL+0x81>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.utsname = type { i32 }
@.str = [22 x i8] c"TT_ENV_OS_VER_UNKNOWN\00"
@.str.1 = [9 x i8] c"%d.%d.%d\00"
@.str.2 = [5 x i8] c"0x%x\00"
define i32 @__detect_PLATFORM_ENV_OS_VER_DETAIL() {
%1 = alloca i32
%2 = alloca %struct.utsname
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i64 @uname(%struct.utsname* %2)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %28
11: ; preds = %0
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %4
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i64 @sscanf(i32 %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%15 = icmp sle i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %28
18: ; preds = %11
%19 = load i32, i32* %4
%20 = shl i32 %19, 16
%21 = load i32, i32* %5
%22 = shl i32 %21, 8
%23 = or i32 %20, %22
%24 = load i32, i32* %6
%25 = or i32 %23, %24
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %26)
store i32 0, i32* %1
br label %28
28: ; preds = %18, %16, %9
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
%struct.utsname = type { i32 }
@.str = [22 x i8] c"TT_ENV_OS_VER_UNKNOWN\00"
@.str.1 = [9 x i8] c"%d.%d.%d\00"
@.str.2 = [5 x i8] c"0x%x\00"
define i32 @__detect_PLATFORM_ENV_OS_VER_DETAIL() {
%1 = alloca %struct.utsname
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast %struct.utsname* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i64 @uname(%struct.utsname* %1)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %29
13: ; preds = %0
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%15 = load i32, i32* %14
%16 = call i64 @sscanf(i32 %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%17 = icmp slt i64 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %29
20: ; preds = %13
%21 = load i32, i32* %2
%22 = shl i32 %21, 16
%23 = load i32, i32* %3
%24 = shl i32 %23, 8
%25 = or i32 %24, %22
%26 = load i32, i32* %4
%27 = or i32 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %20, %18, %11
ret i32 0
}