#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 {
  char *release;
};

/* Variables and functions */
int atoi(char *);
unsigned int mylinux(int, int, int);
char *strchr(char *, char);
int /*<<< orphan*/ uname(struct utsname *);
unsigned int mylinuxver() {
  static int maj = -1, rev = 0, min = 0;
  if (maj == -1) {
    struct utsname u;
    char *pch;
    uname(&u);
    maj = atoi(u.release);
    pch = strchr(u.release, '.');
    if (pch) {
      rev = atoi(pch + 1);
      pch = strchr(pch + 1, '.');
      if (pch) {
        min = atoi(pch + 1);
      }
    }
  }
  return mylinux(maj, rev, min);
}


x86 assembly (clang, -O0):
<mylinuxver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0xffffffff,0x2ef1(%rip)
jne    11db <mylinuxver+0x9b>
lea    -0x8(%rbp),%rdi
call   1040 <uname@plt>
mov    -0x8(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,0x2ed3(%rip)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d6 <mylinuxver+0x96>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,0x2eab(%rip)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d1 <mylinuxver+0x91>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,0x2e7b(%rip)
jmp    11d6 <mylinuxver+0x96>
jmp    11db <mylinuxver+0x9b>
mov    0x2e5f(%rip),%edi
mov    0x2e61(%rip),%esi
mov    0x2e5f(%rip),%edx
call   1050 <mylinux@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mylinuxver>:
push   %r14
push   %rbx
push   %rax
mov    0x2ef6(%rip),%ebx
cmp    $0xffffffff,%ebx
jne    11b6 <mylinuxver+0x76>
mov    %rsp,%rdi
call   1040 <uname@plt>
mov    (%rsp),%r14
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    %eax,0x2ed5(%rip)
mov    %r14,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11b6 <mylinuxver+0x76>
mov    %rax,%r14
add    $0x1,%r14
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %eax,0x2eb6(%rip)
mov    %r14,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11b6 <mylinuxver+0x76>
add    $0x1,%rax
mov    %rax,%rdi
call   1060 <atoi@plt>
mov    %eax,0x2e96(%rip)
mov    0x2e8c(%rip),%esi
mov    0x2e8a(%rip),%edx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <mylinux@plt>

LLVM IR (-O0):
%struct.utsname = type { i8* }
@mylinuxver.maj = internal global i32 -1
@mylinuxver.rev = internal global i32 0
@mylinuxver.min = internal global i32 0
define i32 @mylinuxver() {
%1 = alloca %struct.utsname
%2 = alloca i8*
%3 = load i32, i32* @mylinuxver.maj
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %30
5: ; preds = %0
%6 = call i32 @uname(%struct.utsname* %1)
%7 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%8 = load i8*, i8** %7
%9 = call i32 @atoi(i8* %8)
store i32 %9, i32* @mylinuxver.maj
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%11 = load i8*, i8** %10
%12 = call i8* @strchr(i8* %11, i8 signext 46)
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %29
15: ; preds = %5
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* @mylinuxver.rev
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i8* @strchr(i8* %20, i8 signext 46)
store i8* %21, i8** %2
%22 = load i8*, i8** %2
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %28
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* @mylinuxver.min
br label %28
28: ; preds = %24, %15
br label %29
29: ; preds = %28, %5
br label %30
30: ; preds = %29, %0
%31 = load i32, i32* @mylinuxver.maj
%32 = load i32, i32* @mylinuxver.rev
%33 = load i32, i32* @mylinuxver.min
%34 = call i32 @mylinux(i32 %31, i32 %32, i32 %33)
ret i32 %34
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
@mylinuxver.maj = internal unnamed_addr global i32 -1
@mylinuxver.rev = internal unnamed_addr global i32 0
@mylinuxver.min = internal unnamed_addr global i32 0
define i32 @mylinuxver() {
%1 = alloca %struct.utsname
%2 = load i32, i32* @mylinuxver.maj
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %21
4: ; preds = %0
%5 = bitcast %struct.utsname* %1 to i8*
%6 = call i32 @uname(%struct.utsname* %1)
%7 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
store i32 %9, i32* @mylinuxver.maj
%10 = tail call i8* @strchr(i8* dereferenceable(1) %8, i8 signext 46)
%11 = icmp eq i8* %10, null
br i1 %11, label %20, label %12
12: ; preds = %4
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* @mylinuxver.rev
%15 = tail call i8* @strchr(i8* %13, i8 signext 46)
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = getelementptr inbounds i8, i8* %15, i64 1
%19 = tail call i32 @atoi(i8* %18)
store i32 %19, i32* @mylinuxver.min
br label %20
20: ; preds = %12, %17, %4
br label %21
21: ; preds = %20, %0
%22 = phi i32 [ %9, %20 ], [ %2, %0 ]
%23 = load i32, i32* @mylinuxver.rev
%24 = load i32, i32* @mylinuxver.min
%25 = tail call i32 @mylinux(i32 %22, i32 %23, i32 %24)
ret i32 %25
}