#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 rpio_get_rpi_revision(void) {
  char raw_revision[1024];
  int len;
  char *revision;
  if (!get_cpuinfo_revision(raw_revision))
    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):
<rpio_get_rpi_revision>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    -0x410(%rbp),%rdi
call   1050 <get_cpuinfo_revision@plt>
cmp    $0x0,%eax
jne    115c <rpio_get_rpi_revision+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1331 <rpio_get_rpi_revision+0x201>
lea    -0x410(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x4,-0x414(%rbp)
jle    119c <rpio_get_rpi_revision+0x6c>
lea    -0x410(%rbp),%rax
movslq -0x414(%rbp),%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x420(%rbp)
jmp    11aa <rpio_get_rpi_revision+0x7a>
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11e4 <rpio_get_rpi_revision+0xb4>
mov    -0x420(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <rpio_get_rpi_revision+0xc0>
movl   $0x1,-0x4(%rbp)
jmp    1331 <rpio_get_rpi_revision+0x201>
mov    -0x420(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xd94(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xd7c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xd64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     12f5 <rpio_get_rpi_revision+0x1c5>
mov    -0x420(%rbp),%rdi
lea    0xd4c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1301 <rpio_get_rpi_revision+0x1d1>
movl   $0x2,-0x4(%rbp)
jmp    1331 <rpio_get_rpi_revision+0x201>
mov    -0x420(%rbp),%rdi
lea    0xd28(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    132a <rpio_get_rpi_revision+0x1fa>
movl   $0x0,-0x4(%rbp)
jmp    1331 <rpio_get_rpi_revision+0x201>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpio_get_rpi_revision>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1050 <get_cpuinfo_revision@plt>
test   %eax,%eax
je     127c <rpio_get_rpi_revision+0x14c>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
cltq
lea    -0x4(%rsp,%rax,1),%rbx
cmovl  %rbp,%rbx
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x2,%ebp
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe1b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xe0c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xdfd(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xdee(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xddf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <rpio_get_rpi_revision+0x151>
lea    0xdd0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,2),%ebp
jmp    1281 <rpio_get_rpi_revision+0x151>
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 @rpio_get_rpi_revision() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = call i32 @get_cpuinfo_revision(i8* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 -1, i32* %1
br label %74
9: ; preds = %0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 4
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 -4
store i8* %19, i8** %4
br label %22
20: ; preds = %9
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
store i8* %21, i8** %4
br label %22
22: ; preds = %20, %14
%23 = load i8*, i8** %4
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8*, i8** %4
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26, %22
store i32 1, i32* %1
br label %74
31: ; preds = %26
%32 = load i8*, i8** %4
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %67, label %35
35: ; preds = %31
%36 = load i8*, i8** %4
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %67, label %39
39: ; preds = %35
%40 = load i8*, i8** %4
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %67, label %43
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %67, label %47
47: ; preds = %43
%48 = load i8*, i8** %4
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %67, label %51
51: ; preds = %47
%52 = load i8*, i8** %4
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %67, label %55
55: ; preds = %51
%56 = load i8*, i8** %4
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %67, label %59
59: ; preds = %55
%60 = load i8*, i8** %4
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = load i8*, i8** %4
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %63, %59, %55, %51, %47, %43, %39, %35, %31
store i32 2, i32* %1
br label %74
68: ; preds = %63
%69 = load i8*, i8** %4
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %68
store i32 0, i32* %1
br label %74
73: ; preds = %68
store i32 3, i32* %1
br label %74
74: ; preds = %73, %72, %67, %30, %8
%75 = load i32, i32* %1
ret i32 %75
}

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 @rpio_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, 0
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
}