#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 */
unsigned int MAKE_VERSION(unsigned int, unsigned int, unsigned int);
unsigned int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ strtok(int /*<<< orphan*/ *, char *);
scalar_t__ uname(struct utsname *);
unsigned int linux_version_code(void) {
  struct utsname my_utsname;
  unsigned int p, q, r;
  if (uname(&my_utsname))
    return 0;
  p = atoi(strtok(my_utsname.release, "."));
  q = atoi(strtok(NULL, "."));
  r = atoi(strtok(NULL, "."));
  return MAKE_VERSION(p, q, r);
}


x86 assembly (clang, -O0):
<linux_version_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
call   1030 <uname@plt>
cmp    $0x0,%rax
je     1167 <linux_version_code+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <linux_version_code+0x86>
mov    -0x10(%rbp),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe74(%rip),%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5a(%rip),%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <MAKE_VERSION@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linux_version_code>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
test   %rax,%rax
je     1162 <linux_version_code+0x22>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%rsp),%rdi
lea    0xe92(%rip),%r14
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %eax,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <MAKE_VERSION@plt>

LLVM IR (-O0):
%struct.utsname = type { i32* }
@.str = [2 x i8] c".\00"
define i32 @linux_version_code() {
%1 = alloca i32
%2 = alloca %struct.utsname
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i64 @uname(%struct.utsname* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 0, i32* %1
br label %22
9: ; preds = %0
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%11 = load i32*, i32** %10
%12 = call i32 @strtok(i32* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @atoi(i32 %12)
store i32 %13, i32* %3
%14 = call i32 @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @atoi(i32 %14)
store i32 %15, i32* %4
%16 = call i32 @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @atoi(i32 %16)
store i32 %17, i32* %5
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = call i32 @MAKE_VERSION(i32 %18, i32 %19, i32 %20)
store i32 %21, i32* %1
br label %22
22: ; preds = %9, %8
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
%struct.utsname = type { i32* }
@.str = [2 x i8] c".\00"
define i32 @linux_version_code() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i64 @uname(%struct.utsname* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %0
%6 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%7 = load i32*, i32** %6
%8 = tail call i32 @strtok(i32* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @atoi(i32 %8)
%10 = tail call i32 @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @atoi(i32 %10)
%12 = tail call i32 @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @atoi(i32 %12)
%14 = tail call i32 @MAKE_VERSION(i32 %9, i32 %11, i32 %13)
br label %15
15: ; preds = %0, %5
%16 = phi i32 [ %14, %5 ], [ 0, %0 ]
ret i32 %16
}