#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;
};
typedef int q;
typedef int p;

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ strtok(int /*<<< orphan*/ *, char *);
scalar_t__ uname(struct utsname *);
int linux_version_code(void) {
  struct utsname my_utsname;
  int p, q, r;
  if (uname(&my_utsname) == 0) {
    p = atoi(strtok(my_utsname.release, "."));
    q = atoi(strtok(NULL, "."));
    r = atoi(strtok(NULL, "."));
    return (65536 * (p) + 256 * (q) + (r));
  }
  return 0;
}


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
jne    11b2 <linux_version_code+0x82>
mov    -0x10(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe90(%rip),%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe76(%rip),%rsi
call   1040 <strtok@plt>
mov    %eax,%edi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x10,%eax
mov    -0x18(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b9 <linux_version_code+0x89>
movl   $0x0,-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>
xor    %ebx,%ebx
test   %rax,%rax
jne    1194 <linux_version_code+0x64>
mov    0x8(%rsp),%rdi
lea    0xeab(%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>
shl    $0x10,%ebp
shl    $0x8,%ebx
add    %ebp,%ebx
add    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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 eq i64 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %0
%9 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%10 = load i32*, i32** %9
%11 = call i32 @strtok(i32* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @atoi(i32 %11)
store i32 %12, i32* %3
%13 = call i32 @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @atoi(i32 %13)
store i32 %14, i32* %4
%15 = call i32 @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @atoi(i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %3
%18 = mul nsw i32 65536, %17
%19 = load i32, i32* %4
%20 = mul nsw i32 256, %19
%21 = add nsw i32 %18, %20
%22 = load i32, i32* %5
%23 = add nsw i32 %21, %22
store i32 %23, i32* %1
br label %25
24: ; preds = %0
store i32 0, i32* %1
br label %25
25: ; preds = %24, %8
%26 = load i32, i32* %1
ret i32 %26
}

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 %18
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 = shl nsw i32 %9, 16
%15 = shl nsw i32 %11, 8
%16 = add nsw i32 %15, %14
%17 = add nsw i32 %16, %13
br label %18
18: ; preds = %0, %5
%19 = phi i32 [ %17, %5 ], [ 0, %0 ]
ret i32 %19
}