#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*/ sprintf(char *, char *, char *);
int decode_ad9520_id(unsigned char id, char *idbuf) {
  int retval = 0;
  switch (id) {
  case 0x20:
    sprintf(idbuf, "%s", "AD9520-0\n");
    break;
  case 0x60:
    sprintf(idbuf, "%s", "AD9520-1\n");
    break;
  case 0xA0:
    sprintf(idbuf, "%s", "AD9520-2\n");
    break;
  case 0x61:
    sprintf(idbuf, "%s", "AD9520-3\n");
    break;
  case 0xE1:
    sprintf(idbuf, "%s", "AD9520-4\n");
    break;
  case 0xE0:
    sprintf(idbuf, "%s", "AD9520-5\n");
    break;
  default:
    sprintf(idbuf, "%s", "unknown\n");
    retval = -1;
  }
  return retval;
}


x86 assembly (clang, -O0):
<decode_ad9520_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movzbl -0x1(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x20,%eax
je     1199 <decode_ad9520_id+0x89>
jmp    113e <decode_ad9520_id+0x2e>
mov    -0x18(%rbp),%eax
sub    $0x60,%eax
je     11b5 <decode_ad9520_id+0xa5>
jmp    114f <decode_ad9520_id+0x3f>
mov    -0x18(%rbp),%eax
sub    $0x61,%eax
je     11ed <decode_ad9520_id+0xdd>
jmp    1160 <decode_ad9520_id+0x50>
mov    -0x18(%rbp),%eax
sub    $0xa0,%eax
je     11d1 <decode_ad9520_id+0xc1>
jmp    1173 <decode_ad9520_id+0x63>
mov    -0x18(%rbp),%eax
sub    $0xe0,%eax
je     1225 <decode_ad9520_id+0x115>
jmp    1186 <decode_ad9520_id+0x76>
mov    -0x18(%rbp),%eax
sub    $0xe1,%eax
je     1209 <decode_ad9520_id+0xf9>
jmp    1241 <decode_ad9520_id+0x131>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
lea    0xe58(%rip),%rdx
call   1030 <sprintf@plt>
jmp    125f <decode_ad9520_id+0x14f>
mov    -0x10(%rbp),%rdi
lea    0xe40(%rip),%rsi
lea    0xe46(%rip),%rdx
call   1030 <sprintf@plt>
jmp    125f <decode_ad9520_id+0x14f>
mov    -0x10(%rbp),%rdi
lea    0xe24(%rip),%rsi
lea    0xe34(%rip),%rdx
call   1030 <sprintf@plt>
jmp    125f <decode_ad9520_id+0x14f>
mov    -0x10(%rbp),%rdi
lea    0xe08(%rip),%rsi
lea    0xe22(%rip),%rdx
call   1030 <sprintf@plt>
jmp    125f <decode_ad9520_id+0x14f>
mov    -0x10(%rbp),%rdi
lea    0xdec(%rip),%rsi
lea    0xe10(%rip),%rdx
call   1030 <sprintf@plt>
jmp    125f <decode_ad9520_id+0x14f>
mov    -0x10(%rbp),%rdi
lea    0xdd0(%rip),%rsi
lea    0xdfe(%rip),%rdx
call   1030 <sprintf@plt>
jmp    125f <decode_ad9520_id+0x14f>
mov    -0x10(%rbp),%rdi
lea    0xdb4(%rip),%rsi
lea    0xdec(%rip),%rdx
call   1030 <sprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_ad9520_id>:
cmp    $0x1f,%dil
jg     1124 <decode_ad9520_id+0x24>
cmp    $0xa0,%dil
je     1142 <decode_ad9520_id+0x42>
cmp    $0xe0,%dil
je     114e <decode_ad9520_id+0x4e>
cmp    $0xe1,%dil
jne    117c <decode_ad9520_id+0x7c>
movabs $0x342d303235394441,%rax
30 2d 34
jmp    1170 <decode_ad9520_id+0x70>
cmp    $0x61,%dil
je     115a <decode_ad9520_id+0x5a>
cmp    $0x60,%dil
je     1166 <decode_ad9520_id+0x66>
cmp    $0x20,%dil
jne    117c <decode_ad9520_id+0x7c>
movabs $0x302d303235394441,%rax
30 2d 30
jmp    1170 <decode_ad9520_id+0x70>
movabs $0x322d303235394441,%rax
30 2d 32
jmp    1170 <decode_ad9520_id+0x70>
movabs $0x352d303235394441,%rax
30 2d 35
jmp    1170 <decode_ad9520_id+0x70>
movabs $0x332d303235394441,%rax
30 2d 33
jmp    1170 <decode_ad9520_id+0x70>
movabs $0x312d303235394441,%rax
30 2d 31
mov    %rax,(%rsi)
movw   $0xa,0x8(%rsi)
xor    %eax,%eax
ret
movabs $0xa6e776f6e6b6e75,%rax
77 6e 0a
mov    %rax,(%rsi)
movb   $0x0,0x8(%rsi)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"AD9520-0\0A\00"
@.str.2 = [10 x i8] c"AD9520-1\0A\00"
@.str.3 = [10 x i8] c"AD9520-2\0A\00"
@.str.4 = [10 x i8] c"AD9520-3\0A\00"
@.str.5 = [10 x i8] c"AD9520-4\0A\00"
@.str.6 = [10 x i8] c"AD9520-5\0A\00"
@.str.7 = [9 x i8] c"unknown\0A\00"
define i32 @decode_ad9520_id(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
store i8 %0, i8* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8, i8* %3
%7 = zext i8 %6 to i32
switch i32 %7, label %26 [
i32 32, label %8
i32 96, label %11
i32 160, label %14
i32 97, label %17
i32 225, label %20
i32 224, label %23
]
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %29
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %29
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %29
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %29
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %29
23: ; preds = %2
%24 = load i8*, i8** %4
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %29
26: ; preds = %2
%27 = load i8*, i8** %4
%28 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %5
br label %29
29: ; preds = %26, %23, %20, %17, %14, %11, %8
%30 = load i32, i32* %5
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"AD9520-0\0A\00"
@.str.2 = [10 x i8] c"AD9520-1\0A\00"
@.str.3 = [10 x i8] c"AD9520-2\0A\00"
@.str.4 = [10 x i8] c"AD9520-3\0A\00"
@.str.5 = [10 x i8] c"AD9520-4\0A\00"
@.str.6 = [10 x i8] c"AD9520-5\0A\00"
@.str.7 = [9 x i8] c"unknown\0A\00"
define i32 @decode_ad9520_id(i8 zeroext %0, i8* nocapture writeonly %1) {
switch i8 %0, label %9 [
i8 32, label %3
i8 96, label %4
i8 -96, label %5
i8 97, label %6
i8 -31, label %7
i8 -32, label %8
]
3: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 10, i1 false)
br label %10
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i64 10, i1 false)
br label %10
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 10, i1 false)
br label %10
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 10, i1 false)
br label %10
7: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64 10, i1 false)
br label %10
8: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(10) %1, i8* align 1 dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 10, i1 false)
br label %10
9: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(9) %1, i8* align 1 dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i64 9, i1 false)
br label %10
10: ; preds = %9, %8, %7, %6, %5, %4, %3
%11 = phi i32 [ -1, %9 ], [ 0, %8 ], [ 0, %7 ], [ 0, %6 ], [ 0, %5 ], [ 0, %4 ], [ 0, %3 ]
ret i32 %11
}