#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 */
unsigned char *strstr(unsigned char *, char *);
unsigned int camsys_gpio_group_pin(unsigned char *io_name) {
  unsigned char *pin_char;
  unsigned char pin;
  if (strstr(io_name, "PA")) {
    pin_char = strstr(io_name, "PA");
    pin_char += 2;
    pin = *pin_char - 0x30;
  } else if (strstr(io_name, "PB")) {
    pin_char = strstr(io_name, "PB");
    pin_char += 2;
    pin = *pin_char - 0x30;
    pin += 8;
  } else if (strstr(io_name, "PC")) {
    pin_char = strstr(io_name, "PC");
    pin_char += 2;
    pin = *pin_char - 0x30;
    pin += 16;
  } else if (strstr(io_name, "PD")) {
    pin_char = strstr(io_name, "PD");
    pin_char += 2;
    pin = *pin_char - 0x30;
    pin += 24;
  }
  return pin;
}


x86 assembly (clang, -O0):
<camsys_gpio_group_pin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1168 <camsys_gpio_group_pin+0x58>
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sub    $0x30,%eax
mov    %al,-0x11(%rbp)
jmp    1274 <camsys_gpio_group_pin+0x164>
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11be <camsys_gpio_group_pin+0xae>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sub    $0x30,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
add    $0x8,%eax
mov    %al,-0x11(%rbp)
jmp    126f <camsys_gpio_group_pin+0x15f>
mov    -0x8(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1214 <camsys_gpio_group_pin+0x104>
mov    -0x8(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sub    $0x30,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
add    $0x10,%eax
mov    %al,-0x11(%rbp)
jmp    126a <camsys_gpio_group_pin+0x15a>
mov    -0x8(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1265 <camsys_gpio_group_pin+0x155>
mov    -0x8(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sub    $0x30,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
add    $0x18,%eax
mov    %al,-0x11(%rbp)
jmp    126a <camsys_gpio_group_pin+0x15a>
jmp    126f <camsys_gpio_group_pin+0x15f>
jmp    1274 <camsys_gpio_group_pin+0x164>
movzbl -0x11(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<camsys_gpio_group_pin>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strstr@plt>
test   %rax,%rax
je     112e <camsys_gpio_group_pin+0x1e>
movzbl 0x2(%rax),%eax
add    $0xffffffd0,%eax
jmp    1193 <camsys_gpio_group_pin+0x83>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     114f <camsys_gpio_group_pin+0x3f>
mov    0x2(%rax),%al
add    $0xd0,%al
movzbl %al,%eax
add    $0x8,%eax
jmp    1193 <camsys_gpio_group_pin+0x83>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1170 <camsys_gpio_group_pin+0x60>
mov    0x2(%rax),%al
add    $0xd0,%al
movzbl %al,%eax
add    $0x10,%eax
jmp    1193 <camsys_gpio_group_pin+0x83>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     1191 <camsys_gpio_group_pin+0x81>
mov    0x2(%rax),%al
add    $0xd0,%al
movzbl %al,%eax
add    $0x18,%eax
jmp    1193 <camsys_gpio_group_pin+0x83>
xor    %eax,%eax
movzbl %al,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"PA\00"
@.str.1 = [3 x i8] c"PB\00"
@.str.2 = [3 x i8] c"PC\00"
@.str.3 = [3 x i8] c"PD\00"
define i32 @camsys_gpio_group_pin(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strstr(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i8* @strstr(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 2
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = sub nsw i32 %15, 48
%17 = trunc i32 %16 to i8
store i8 %17, i8* %4
br label %75
18: ; preds = %1
%19 = load i8*, i8** %2
%20 = call i8* @strstr(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i8*, i8** %2
%24 = call i8* @strstr(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 2
store i8* %26, i8** %3
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = sub nsw i32 %29, 48
%31 = trunc i32 %30 to i8
store i8 %31, i8* %4
%32 = load i8, i8* %4
%33 = zext i8 %32 to i32
%34 = add nsw i32 %33, 8
%35 = trunc i32 %34 to i8
store i8 %35, i8* %4
br label %74
36: ; preds = %18
%37 = load i8*, i8** %2
%38 = call i8* @strstr(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %54
40: ; preds = %36
%41 = load i8*, i8** %2
%42 = call i8* @strstr(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %42, i8** %3
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i64 2
store i8* %44, i8** %3
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = sub nsw i32 %47, 48
%49 = trunc i32 %48 to i8
store i8 %49, i8* %4
%50 = load i8, i8* %4
%51 = zext i8 %50 to i32
%52 = add nsw i32 %51, 16
%53 = trunc i32 %52 to i8
store i8 %53, i8* %4
br label %73
54: ; preds = %36
%55 = load i8*, i8** %2
%56 = call i8* @strstr(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %72
58: ; preds = %54
%59 = load i8*, i8** %2
%60 = call i8* @strstr(i8* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i8* %60, i8** %3
%61 = load i8*, i8** %3
%62 = getelementptr inbounds i8, i8* %61, i64 2
store i8* %62, i8** %3
%63 = load i8*, i8** %3
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = sub nsw i32 %65, 48
%67 = trunc i32 %66 to i8
store i8 %67, i8* %4
%68 = load i8, i8* %4
%69 = zext i8 %68 to i32
%70 = add nsw i32 %69, 24
%71 = trunc i32 %70 to i8
store i8 %71, i8* %4
br label %72
72: ; preds = %58, %54
br label %73
73: ; preds = %72, %40
br label %74
74: ; preds = %73, %22
br label %75
75: ; preds = %74, %8
%76 = load i8, i8* %4
%77 = zext i8 %76 to i32
ret i32 %77
}

LLVM IR (-O2):
@.str = [3 x i8] c"PA\00"
@.str.1 = [3 x i8] c"PB\00"
@.str.2 = [3 x i8] c"PC\00"
@.str.3 = [3 x i8] c"PD\00"
define i32 @camsys_gpio_group_pin(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 2
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = add nsw i32 %7, -48
br label %36
9: ; preds = %1
%10 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 2
%14 = load i8, i8* %13
%15 = add i8 %14, -48
%16 = zext i8 %15 to i32
%17 = add nuw nsw i32 %16, 8
br label %36
18: ; preds = %9
%19 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %19, i64 2
%23 = load i8, i8* %22
%24 = add i8 %23, -48
%25 = zext i8 %24 to i32
%26 = add nuw nsw i32 %25, 16
br label %36
27: ; preds = %18
%28 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %28, i64 2
%32 = load i8, i8* %31
%33 = add i8 %32, -48
%34 = zext i8 %33 to i32
%35 = add nuw nsw i32 %34, 24
br label %36
36: ; preds = %12, %27, %30, %21, %4
%37 = phi i32 [ %8, %4 ], [ %17, %12 ], [ %26, %21 ], [ %35, %30 ], [ 0, %27 ]
%38 = and i32 %37, 255
ret i32 %38
}