#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 */
unsigned int atoi(char const *);
int /*<<< orphan*/ error_msg_and_die(char *, char *);
int /*<<< orphan*/ perror_msg_and_die(char *);
scalar_t__ uname(struct utsname *);
unsigned get_os_release(void) {
  unsigned rel;
  const char *p;
  struct utsname u;
  if (uname(&u) < 0)
    perror_msg_and_die("uname");
  rel = 0;
  p = u.release;
  for (;;) {
    if (!(*p >= '0' && *p <= '9'))
      error_msg_and_die("Bad OS release string: '%s'", u.release);
    rel = (rel << 8) | atoi(p);
    if (rel >= (((1) << 16) + ((0) << 8) + (0)))
      break;
    while (*p >= '0' && *p <= '9')
      p++;
    if (*p != '.') {
      if (rel >= (((0) << 16) + ((1) << 8) + (0))) {
        rel <<= 8;
        break;
      }
      error_msg_and_die("Bad OS release string: '%s'", u.release);
    }
    p++;
  }
  return rel;
}


x86 assembly (clang, -O0):
<get_os_release>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x18(%rbp),%rdi
call   1030 <uname@plt>
cmp    $0x0,%rax
jge    1167 <get_os_release+0x27>
lea    0xe9e(%rip),%rdi
call   1050 <perror_msg_and_die@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1196 <get_os_release+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    11a6 <get_os_release+0x66>
mov    -0x18(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1040 <error_msg_and_die@plt>
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x10000,-0x4(%rbp)
jb     11d4 <get_os_release+0x94>
jmp    126b <get_os_release+0x12b>
jmp    11d9 <get_os_release+0x99>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x1d(%rbp)
jl     11fe <get_os_release+0xbe>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    120e <get_os_release+0xce>
jmp    121f <get_os_release+0xdf>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11d9 <get_os_release+0x99>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     125a <get_os_release+0x11a>
cmpl   $0x100,-0x4(%rbp)
jb     124a <get_os_release+0x10a>
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    126b <get_os_release+0x12b>
mov    -0x18(%rbp),%rsi
lea    0xdb1(%rip),%rdi
call   1040 <error_msg_and_die@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1176 <get_os_release+0x36>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_os_release>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
test   %rax,%rax
jns    1167 <get_os_release+0x27>
lea    0xe9e(%rip),%rdi
call   1050 <perror_msg_and_die@plt>
xor    %ebp,%ebp
mov    0x8(%rsp),%r14
lea    0xe91(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%al
add    $0xd0,%al
cmp    $0xa,%al
jb     1193 <get_os_release+0x53>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <error_msg_and_die@plt>
mov    %ebp,%r12d
shl    $0x8,%r12d
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
or     %r12d,%ebp
cmp    $0xffff,%ebp
ja     11db <get_os_release+0x9b>
nop
movzbl (%rbx),%eax
lea    -0x30(%rax),%ecx
add    $0x1,%rbx
cmp    $0xa,%cl
jb     11b0 <get_os_release+0x70>
cmp    $0x2e,%al
je     1180 <get_os_release+0x40>
cmp    $0x100,%ebp
jae    11d8 <get_os_release+0x98>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <error_msg_and_die@plt>
jmp    1180 <get_os_release+0x40>
shl    $0x8,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.utsname = type { i8* }
@.str = [6 x i8] c"uname\00"
@.str.1 = [28 x i8] c"Bad OS release string: '%s'\00"
define i32 @get_os_release() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.utsname
%4 = call i64 @uname(%struct.utsname* %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror_msg_and_die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
store i32 0, i32* %1
%9 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%10 = load i8*, i8** %9
store i8* %10, i8** %2
br label %11
11: ; preds = %65, %8
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp sge i32 %14, 48
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp sle i32 %19, 57
br i1 %20, label %25, label %21
21: ; preds = %16, %11
%22 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 @error_msg_and_die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %21, %16
%26 = load i32, i32* %1
%27 = shl i32 %26, 8
%28 = load i8*, i8** %2
%29 = call i32 @atoi(i8* %28)
%30 = or i32 %27, %29
store i32 %30, i32* %1
%31 = load i32, i32* %1
%32 = icmp uge i32 %31, 65536
br i1 %32, label %33, label %34
33: ; preds = %25
br label %68
34: ; preds = %25
br label %35
35: ; preds = %47, %34
%36 = load i8*, i8** %2
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp sge i32 %38, 48
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i8*, i8** %2
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp sle i32 %43, 57
br label %45
45: ; preds = %40, %35
%46 = phi i1 [ false, %35 ], [ %44, %40 ]
br i1 %46, label %47, label %50
47: ; preds = %45
%48 = load i8*, i8** %2
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %2
br label %35
50: ; preds = %45
%51 = load i8*, i8** %2
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 46
br i1 %54, label %55, label %65
55: ; preds = %50
%56 = load i32, i32* %1
%57 = icmp uge i32 %56, 256
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* %1
%60 = shl i32 %59, 8
store i32 %60, i32* %1
br label %68
61: ; preds = %55
%62 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%63 = load i8*, i8** %62
%64 = call i32 @error_msg_and_die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %61, %50
%66 = load i8*, i8** %2
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %2
br label %11
68: ; preds = %58, %33
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
@.str = [6 x i8] c"uname\00"
@.str.1 = [28 x i8] c"Bad OS release string: '%s'\00"
define i32 @get_os_release() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i64 @uname(%struct.utsname* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror_msg_and_die(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%9 = load i8*, i8** %8
br label %10
10: ; preds = %37, %7
%11 = phi i32 [ 0, %7 ], [ %21, %37 ]
%12 = phi i8* [ %9, %7 ], [ %28, %37 ]
%13 = load i8, i8* %12
%14 = add i8 %13, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %18, label %16
16: ; preds = %10
%17 = tail call i32 @error_msg_and_die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %18
18: ; preds = %10, %16
%19 = shl i32 %11, 8
%20 = tail call i32 @atoi(i8* %12)
%21 = or i32 %20, %19
%22 = icmp ugt i32 %21, 65535
br i1 %22, label %38, label %23
23: ; preds = %18, %23
%24 = phi i8* [ %28, %23 ], [ %12, %18 ]
%25 = load i8, i8* %24
%26 = add i8 %25, -48
%27 = icmp ult i8 %26, 10
%28 = getelementptr inbounds i8, i8* %24, i64 1
br i1 %27, label %23, label %29
29: ; preds = %23
%30 = icmp eq i8 %25, 46
br i1 %30, label %37, label %31
31: ; preds = %29
%32 = icmp ugt i32 %21, 255
br i1 %32, label %33, label %35
33: ; preds = %31
%34 = shl i32 %21, 8
br label %38
35: ; preds = %31
%36 = tail call i32 @error_msg_and_die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %37
37: ; preds = %35, %29
br label %10
38: ; preds = %18, %33
%39 = phi i32 [ %34, %33 ], [ %21, %18 ]
ret i32 %39
}