#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*/ strlen(char *);
int /*<<< orphan*/ strncmp(char const *, char *, int /*<<< orphan*/);
int check_simple_cast(const char *cast, int *bits, int *is_signed) {
  if (!strncmp(cast, "(s8)", strlen("(s8)")) ||
      !strncmp(cast, "(u8)", strlen("(u8)")))
    *bits = 8;
  else if (!strncmp(cast, "(s16)", strlen("(s16)")) ||
           !strncmp(cast, "(u16)", strlen("(u16)")))
    *bits = 16;
  else if (!strncmp(cast, "(s32)", strlen("(s32)")) ||
           !strncmp(cast, "(u32)", strlen("(u32)")))
    *bits = 32;
  else if (!strncmp(cast, "(s64)", strlen("(s64)")) ||
           !strncmp(cast, "(u64)", strlen("(u64)")))
    *bits = 64;
  else
    return -1;
  *is_signed = cast[1] == 's' ? 1 : 0;
  return 0;
}


x86 assembly (clang, -O0):
<check_simple_cast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    0xebd(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
lea    0xeab(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     1192 <check_simple_cast+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xe93(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%edx
lea    0xe81(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11a1 <check_simple_cast+0x81>
mov    -0x18(%rbp),%rax
movl   $0x8,(%rax)
jmp    1303 <check_simple_cast+0x1e3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe5a(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xe48(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     11ff <check_simple_cast+0xdf>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xe31(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%edx
lea    0xe1f(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    120e <check_simple_cast+0xee>
mov    -0x18(%rbp),%rax
movl   $0x10,(%rax)
jmp    12fe <check_simple_cast+0x1de>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xdf9(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
lea    0xde7(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     126c <check_simple_cast+0x14c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xdd0(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%edx
lea    0xdbe(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    127b <check_simple_cast+0x15b>
mov    -0x18(%rbp),%rax
movl   $0x20,(%rax)
jmp    12f9 <check_simple_cast+0x1d9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xd98(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%edx
lea    0xd86(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
je     12d9 <check_simple_cast+0x1b9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xd6f(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%edx
lea    0xd5d(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12e8 <check_simple_cast+0x1c8>
mov    -0x18(%rbp),%rax
movl   $0x40,(%rax)
jmp    12f4 <check_simple_cast+0x1d4>
movl   $0xffffffff,-0x4(%rbp)
jmp    1325 <check_simple_cast+0x205>
jmp    12f9 <check_simple_cast+0x1d9>
jmp    12fe <check_simple_cast+0x1de>
jmp    1303 <check_simple_cast+0x1e3>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edx
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    $0x73,%edx
cmove  %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_simple_cast>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0x8,%ebp
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xea4(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xe85(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0x10,%ebp
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xe62(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xe44(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0x20,%ebp
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xe25(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xe0b(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    $0x40,%ebp
test   %eax,%eax
je     125c <check_simple_cast+0x13c>
lea    0xdec(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    126f <check_simple_cast+0x14f>
mov    %ebp,(%r15)
xor    %eax,%eax
cmpb   $0x73,0x1(%r12)
sete   %al
mov    %eax,(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"(s8)\00"
@.str.1 = [5 x i8] c"(u8)\00"
@.str.2 = [6 x i8] c"(s16)\00"
@.str.3 = [6 x i8] c"(u16)\00"
@.str.4 = [6 x i8] c"(s32)\00"
@.str.5 = [6 x i8] c"(u32)\00"
@.str.6 = [6 x i8] c"(s64)\00"
@.str.7 = [6 x i8] c"(u64)\00"
define i32 @check_simple_cast(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12, %3
%18 = load i32*, i32** %6
store i32 8, i32* %18
br label %59
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @strncmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %24, %19
%30 = load i32*, i32** %6
store i32 16, i32* %30
br label %58
31: ; preds = %24
%32 = load i8*, i8** %5
%33 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @strncmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i8*, i8** %5
%38 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%39 = call i32 @strncmp(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %36, %31
%42 = load i32*, i32** %6
store i32 32, i32* %42
br label %57
43: ; preds = %36
%44 = load i8*, i8** %5
%45 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%46 = call i32 @strncmp(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i8*, i8** %5
%50 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32 @strncmp(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %48, %43
%54 = load i32*, i32** %6
store i32 64, i32* %54
br label %56
55: ; preds = %48
store i32 -1, i32* %4
br label %68
56: ; preds = %53
br label %57
57: ; preds = %56, %41
br label %58
58: ; preds = %57, %29
br label %59
59: ; preds = %58, %17
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 115
%65 = zext i1 %64 to i64
%66 = select i1 %64, i32 1, i32 0
%67 = load i32*, i32** %7
store i32 %66, i32* %67
store i32 0, i32* %4
br label %68
68: ; preds = %59, %55
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
@.str = [5 x i8] c"(s8)\00"
@.str.1 = [5 x i8] c"(u8)\00"
@.str.2 = [6 x i8] c"(s16)\00"
@.str.3 = [6 x i8] c"(u16)\00"
@.str.4 = [6 x i8] c"(s32)\00"
@.str.5 = [6 x i8] c"(u32)\00"
@.str.6 = [6 x i8] c"(s64)\00"
@.str.7 = [6 x i8] c"(u64)\00"
define i32 @check_simple_cast(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %35, label %7
7: ; preds = %3
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %7
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %11
%16 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %35, label %19
19: ; preds = %15
%20 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = icmp eq i32 %21, 0
br i1 %22, label %35, label %23
23: ; preds = %19
%24 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%25 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %35, label %27
27: ; preds = %23
%28 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%29 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%33 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %27, %31, %19, %23, %11, %15, %3, %7
%36 = phi i32 [ 8, %7 ], [ 8, %3 ], [ 16, %15 ], [ 16, %11 ], [ 32, %23 ], [ 32, %19 ], [ 64, %31 ], [ 64, %27 ]
store i32 %36, i32* %1
%37 = getelementptr inbounds i8, i8* %0, i64 1
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 115
%40 = zext i1 %39 to i32
store i32 %40, i32* %2
br label %41
41: ; preds = %31, %35
%42 = phi i32 [ 0, %35 ], [ -1, %31 ]
ret i32 %42
}