#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, min;
  if (maj == -1) {
    struct utsname u;
    char *pch;
    uname(&u);
    maj = atoi(u.release);
    pch = strchr(u.release, '.');
    rev = atoi(pch + 1);
    pch = strchr(pch + 1, '.');
    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    11bb <mylinuxver+0x7b>
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)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,0x2eb6(%rip)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
mov    %eax,0x2e91(%rip)
mov    0x2e7f(%rip),%edi
mov    0x2e81(%rip),%esi
mov    0x2e7f(%rip),%edx
call   1050 <mylinux@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mylinuxver>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2ef2(%rip),%ebx
cmp    $0xffffffff,%ebx
je     1161 <mylinuxver+0x21>
mov    0x2eef(%rip),%ebp
mov    0x2eed(%rip),%edx
jmp    11bf <mylinuxver+0x7f>
lea    0x8(%rsp),%rdi
call   1040 <uname@plt>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    %eax,0x2ec0(%rip)
mov    %rbp,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%r14
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %eax,0x2ea7(%rip)
mov    %r14,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%edx
mov    %eax,0x2e8d(%rip)
mov    %ebx,%edi
mov    %ebp,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 %22
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 = getelementptr inbounds i8, i8* %13, i64 1
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* @mylinuxver.rev
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i8* @strchr(i8* %17, i8 signext 46)
store i8* %18, i8** %2
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* @mylinuxver.min
br label %22
22: ; preds = %5, %0
%23 = load i32, i32* @mylinuxver.maj
%24 = load i32, i32* @mylinuxver.rev
%25 = load i32, i32* @mylinuxver.min
%26 = call i32 @mylinux(i32 %23, i32 %24, i32 %25)
ret i32 %26
}

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 %7, label %4
4: ; preds = %0
%5 = load i32, i32* @mylinuxver.rev
%6 = load i32, i32* @mylinuxver.min
br label %19
7: ; preds = %0
%8 = bitcast %struct.utsname* %1 to i8*
%9 = call i32 @uname(%struct.utsname* %1)
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
store i32 %12, i32* @mylinuxver.maj
%13 = tail call i8* @strchr(i8* dereferenceable(1) %11, i8 signext 46)
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = tail call i32 @atoi(i8* %14)
store i32 %15, i32* @mylinuxver.rev
%16 = tail call i8* @strchr(i8* %14, i8 signext 46)
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = tail call i32 @atoi(i8* %17)
store i32 %18, i32* @mylinuxver.min
br label %19
19: ; preds = %4, %7
%20 = phi i32 [ %18, %7 ], [ %6, %4 ]
%21 = phi i32 [ %15, %7 ], [ %5, %4 ]
%22 = phi i32 [ %12, %7 ], [ %2, %4 ]
%23 = tail call i32 @mylinux(i32 %22, i32 %21, i32 %20)
ret i32 %23
}