#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*/ un;
struct utsname {
  char *release;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct utsname *, int /*<<< orphan*/, int);
int strtol(char *, char **, int);
int /*<<< orphan*/ uname(struct utsname *);
unsigned int get_sys_version(int *major, int *minor, int *minor2) {
  struct utsname un;
  int m1;
  int m2;
  int m3;
  char *p;
  memset(&un, 0, sizeof(un));
  m1 = m2 = m3 = 0;
  uname(&un);
  m1 = strtol(un.release, &p, 10);
  if (*p == '.') {
    p++;
    m2 = strtol(p, &p, 10);
    if (*p == '.') {
      p++;
      m3 = strtol(p, &p, 10);
    }
  }
  if (major)
    *major = m1;
  if (minor)
    *minor = m2;
  if (minor2)
    *minor2 = m3;
  return ((m1 << 16) | (m2 << 8) | (m3));
}


x86 assembly (clang, -O0):
<get_sys_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <uname@plt>
mov    -0x20(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11ee <get_sys_version+0xbe>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11e9 <get_sys_version+0xb9>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x2c(%rbp)
jmp    11ee <get_sys_version+0xbe>
cmpq   $0x0,-0x8(%rbp)
je     1202 <get_sys_version+0xd2>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1216 <get_sys_version+0xe6>
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     122a <get_sys_version+0xfa>
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
shl    $0x10,%eax
mov    -0x28(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sys_version>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x10(%rsp),%rbx
xor    %r13d,%r13d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1030 <uname@plt>
mov    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
cmpb   $0x2e,(%rdi)
jne    11c7 <get_sys_version+0x97>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
cmpb   $0x2e,(%rdi)
jne    11c9 <get_sys_version+0x99>
add    $0x1,%rdi
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%r13d
jmp    11c9 <get_sys_version+0x99>
xor    %ebp,%ebp
test   %r12,%r12
je     11d2 <get_sys_version+0xa2>
mov    %ebx,(%r12)
test   %r15,%r15
je     11da <get_sys_version+0xaa>
mov    %ebp,(%r15)
test   %r14,%r14
je     11e2 <get_sys_version+0xb2>
mov    %r13d,(%r14)
shl    $0x10,%ebx
shl    $0x8,%ebp
or     %ebx,%ebp
or     %r13d,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utsname = type { i8* }
define i32 @get_sys_version(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca %struct.utsname
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%12 = call i32 @memset(%struct.utsname* %7, i32 0, i32 8)
store i32 0, i32* %10
store i32 0, i32* %9
store i32 0, i32* %8
%13 = call i32 @uname(%struct.utsname* %7)
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %7, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = call i32 @strtol(i8* %15, i8** %11, i32 10)
store i32 %16, i32* %8
%17 = load i8*, i8** %11
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 46
br i1 %20, label %21, label %36
21: ; preds = %3
%22 = load i8*, i8** %11
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %11
%24 = load i8*, i8** %11
%25 = call i32 @strtol(i8* %24, i8** %11, i32 10)
store i32 %25, i32* %9
%26 = load i8*, i8** %11
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 46
br i1 %29, label %30, label %35
30: ; preds = %21
%31 = load i8*, i8** %11
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %11
%33 = load i8*, i8** %11
%34 = call i32 @strtol(i8* %33, i8** %11, i32 10)
store i32 %34, i32* %10
br label %35
35: ; preds = %30, %21
br label %36
36: ; preds = %35, %3
%37 = load i32*, i32** %4
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load i32, i32* %8
%41 = load i32*, i32** %4
store i32 %40, i32* %41
br label %42
42: ; preds = %39, %36
%43 = load i32*, i32** %5
%44 = icmp ne i32* %43, null
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %9
%47 = load i32*, i32** %5
store i32 %46, i32* %47
br label %48
48: ; preds = %45, %42
%49 = load i32*, i32** %6
%50 = icmp ne i32* %49, null
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* %10
%53 = load i32*, i32** %6
store i32 %52, i32* %53
br label %54
54: ; preds = %51, %48
%55 = load i32, i32* %8
%56 = shl i32 %55, 16
%57 = load i32, i32* %9
%58 = shl i32 %57, 8
%59 = or i32 %56, %58
%60 = load i32, i32* %10
%61 = or i32 %59, %60
ret i32 %61
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
define i32 @get_sys_version(i32* writeonly %0, i32* writeonly %1, i32* writeonly %2) {
%4 = alloca %struct.utsname
%5 = alloca i8*
%6 = bitcast %struct.utsname* %4 to i8*
%7 = bitcast i8** %5 to i8*
%8 = call i32 @memset(%struct.utsname* %4, i32 0, i32 8)
%9 = call i32 @uname(%struct.utsname* %4)
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = call i32 @strtol(i8* %11, i8** %5, i32 10)
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 46
br i1 %15, label %16, label %25
16: ; preds = %3
%17 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %17, i8** %5
%18 = call i32 @strtol(i8* %17, i8** %5, i32 10)
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 46
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %23, i8** %5
%24 = call i32 @strtol(i8* %23, i8** %5, i32 10)
br label %25
25: ; preds = %16, %22, %3
%26 = phi i32 [ %18, %22 ], [ %18, %16 ], [ 0, %3 ]
%27 = phi i32 [ %24, %22 ], [ 0, %16 ], [ 0, %3 ]
%28 = icmp eq i32* %0, null
br i1 %28, label %30, label %29
29: ; preds = %25
store i32 %12, i32* %0
br label %30
30: ; preds = %29, %25
%31 = icmp eq i32* %1, null
br i1 %31, label %33, label %32
32: ; preds = %30
store i32 %26, i32* %1
br label %33
33: ; preds = %32, %30
%34 = icmp eq i32* %2, null
br i1 %34, label %36, label %35
35: ; preds = %33
store i32 %27, i32* %2
br label %36
36: ; preds = %35, %33
%37 = shl i32 %12, 16
%38 = shl i32 %26, 8
%39 = or i32 %38, %37
%40 = or i32 %39, %27
ret i32 %40
}