#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 */

/* Variables and functions */
int /*<<< orphan*/ *get_cpuinfo_revision(char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int get_rpi_revision(void) {
  char raw_revision[1024] = {'\0'};
  int len;
  char *revision;
  if (get_cpuinfo_revision(raw_revision) == NULL)
    return -1;
  len = strlen(raw_revision);
  if (len > 4)
    revision = (char *)&raw_revision + len - 4;
  else
    revision = raw_revision;
  if ((strcmp(revision, "0002") == 0) || (strcmp(revision, "0003") == 0))
    return 1;
  else if ((strcmp(revision, "0004") == 0) || (strcmp(revision, "0005") == 0) ||
           (strcmp(revision, "0006") == 0) || (strcmp(revision, "0007") == 0) ||
           (strcmp(revision, "0008") == 0) || (strcmp(revision, "0009") == 0) ||
           (strcmp(revision, "000d") == 0) || (strcmp(revision, "000e") == 0) ||
           (strcmp(revision, "000f") == 0))
    return 2;
  else if (strcmp(revision, "0011") == 0)
    return 0;
  else
    return 3;
}


x86 assembly (clang, -O0):
<get_rpi_revision>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
lea    -0x410(%rbp),%rdi
call   1060 <get_cpuinfo_revision@plt>
cmp    $0x0,%rax
jne    1180 <get_rpi_revision+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    1355 <get_rpi_revision+0x215>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x4,-0x414(%rbp)
jle    11c0 <get_rpi_revision+0x80>
lea    -0x410(%rbp),%rax
movslq -0x414(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x420(%rbp)
jmp    11ce <get_rpi_revision+0x8e>
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1208 <get_rpi_revision+0xc8>
mov    -0x420(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1214 <get_rpi_revision+0xd4>
movl   $0x1,-0x4(%rbp)
jmp    1355 <get_rpi_revision+0x215>
mov    -0x420(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xd40(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1319 <get_rpi_revision+0x1d9>
mov    -0x420(%rbp),%rdi
lea    0xd28(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1325 <get_rpi_revision+0x1e5>
movl   $0x2,-0x4(%rbp)
jmp    1355 <get_rpi_revision+0x215>
mov    -0x420(%rbp),%rdi
lea    0xd04(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    134e <get_rpi_revision+0x20e>
movl   $0x0,-0x4(%rbp)
jmp    1355 <get_rpi_revision+0x215>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rpi_revision>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbp,%rdi
call   1060 <get_cpuinfo_revision@plt>
test   %rax,%rax
je     129c <get_rpi_revision+0x15c>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
cltq
lea    -0x4(%rsp,%rax,1),%rbx
cmovl  %rbp,%rbx
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xe4c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xdfb(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xdec(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xddd(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xdce(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xdbf(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     12a1 <get_rpi_revision+0x161>
lea    0xdb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,2),%ebp
jmp    12a1 <get_rpi_revision+0x161>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0002\00"
@.str.1 = [5 x i8] c"0003\00"
@.str.2 = [5 x i8] c"0004\00"
@.str.3 = [5 x i8] c"0005\00"
@.str.4 = [5 x i8] c"0006\00"
@.str.5 = [5 x i8] c"0007\00"
@.str.6 = [5 x i8] c"0008\00"
@.str.7 = [5 x i8] c"0009\00"
@.str.8 = [5 x i8] c"000d\00"
@.str.9 = [5 x i8] c"000e\00"
@.str.10 = [5 x i8] c"000f\00"
@.str.11 = [5 x i8] c"0011\00"
define i32 @get_rpi_revision() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = bitcast [1024 x i8]* %2 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = call i32* @get_cpuinfo_revision(i8* %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %75
10: ; preds = %0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 4
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = bitcast [1024 x i8]* %2 to i8*
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -4
store i8* %20, i8** %4
br label %23
21: ; preds = %10
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
store i8* %22, i8** %4
br label %23
23: ; preds = %21, %15
%24 = load i8*, i8** %4
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27, %23
store i32 1, i32* %1
br label %75
32: ; preds = %27
%33 = load i8*, i8** %4
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %68, label %36
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %68, label %40
40: ; preds = %36
%41 = load i8*, i8** %4
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %68, label %44
44: ; preds = %40
%45 = load i8*, i8** %4
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %68, label %48
48: ; preds = %44
%49 = load i8*, i8** %4
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %68, label %52
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %68, label %56
56: ; preds = %52
%57 = load i8*, i8** %4
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %68, label %60
60: ; preds = %56
%61 = load i8*, i8** %4
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %68, label %64
64: ; preds = %60
%65 = load i8*, i8** %4
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %64, %60, %56, %52, %48, %44, %40, %36, %32
store i32 2, i32* %1
br label %75
69: ; preds = %64
%70 = load i8*, i8** %4
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %69
store i32 0, i32* %1
br label %75
74: ; preds = %69
store i32 3, i32* %1
br label %75
75: ; preds = %74, %73, %68, %31, %9
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str = [5 x i8] c"0002\00"
@.str.1 = [5 x i8] c"0003\00"
@.str.2 = [5 x i8] c"0004\00"
@.str.3 = [5 x i8] c"0005\00"
@.str.4 = [5 x i8] c"0006\00"
@.str.5 = [5 x i8] c"0007\00"
@.str.6 = [5 x i8] c"0008\00"
@.str.7 = [5 x i8] c"0009\00"
@.str.8 = [5 x i8] c"000d\00"
@.str.9 = [5 x i8] c"000e\00"
@.str.10 = [5 x i8] c"000f\00"
@.str.11 = [5 x i8] c"0011\00"
define i32 @get_rpi_revision() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i32* @get_cpuinfo_revision(i8* %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %48, label %5
5: ; preds = %0
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 4
%8 = sext i32 %6 to i64
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -4
%11 = select i1 %7, i8* %10, i8* %2
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %48, label %14
14: ; preds = %5
%15 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %48, label %17
17: ; preds = %14
%18 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %48, label %20
20: ; preds = %17
%21 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %48, label %23
23: ; preds = %20
%24 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %48, label %26
26: ; preds = %23
%27 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %48, label %29
29: ; preds = %26
%30 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %48, label %32
32: ; preds = %29
%33 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %48, label %35
35: ; preds = %32
%36 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %48, label %38
38: ; preds = %35
%39 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %48, label %41
41: ; preds = %38
%42 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
%45 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
%47 = select i1 %46, i32 0, i32 3
br label %48
48: ; preds = %44, %17, %20, %23, %26, %29, %32, %35, %38, %41, %5, %14, %0
%49 = phi i32 [ -1, %0 ], [ 1, %14 ], [ 1, %5 ], [ 2, %41 ], [ 2, %38 ], [ 2, %35 ], [ 2, %32 ], [ 2, %29 ], [ 2, %26 ], [ 2, %23 ], [ 2, %20 ], [ 2, %17 ], [ %47, %44 ]
ret i32 %49
}