#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 strlen(char *);
int t_read_sem(char *param) {
  if (param[0] != '*')
    return 1;
  if (strlen(param) < 2)
    return 1;
  switch (param[1]) {
  case 'l':
  case 'n':
  case 'a':
    break;
  default:
    return 1;
    break;
  }
  param[2] = '\0';
  return 0;
}


x86 assembly (clang, -O0):
<t_read_sem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     1138 <t_read_sem+0x28>
movl   $0x1,-0x4(%rbp)
jmp    11b1 <t_read_sem+0xa1>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jge    1156 <t_read_sem+0x46>
movl   $0x1,-0x4(%rbp)
jmp    11b1 <t_read_sem+0xa1>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x61,%eax
je     1191 <t_read_sem+0x81>
jmp    116f <t_read_sem+0x5f>
mov    -0x14(%rbp),%eax
sub    $0x6c,%eax
je     1191 <t_read_sem+0x81>
jmp    1180 <t_read_sem+0x70>
mov    -0x14(%rbp),%eax
sub    $0x6e,%eax
jne    1196 <t_read_sem+0x86>
jmp    1191 <t_read_sem+0x81>
jmp    11a2 <t_read_sem+0x92>
movl   $0x1,-0x4(%rbp)
jmp    11b1 <t_read_sem+0xa1>
mov    -0x10(%rbp),%rax
movb   $0x0,0x2(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_read_sem>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
cmpb   $0x2a,(%rdi)
jne    1146 <t_read_sem+0x36>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1146 <t_read_sem+0x36>
movsbl 0x1(%rbx),%eax
add    $0xffffff9f,%eax
cmp    $0xd,%eax
ja     1146 <t_read_sem+0x36>
mov    $0x2801,%ecx
bt     %eax,%ecx
jae    1146 <t_read_sem+0x36>
movb   $0x0,0x2(%rbx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @t_read_sem(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 42
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %25
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %2
br label %25
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %21 [
i32 108, label %20
i32 110, label %20
i32 97, label %20
]
20: ; preds = %15, %15, %15
br label %22
21: ; preds = %15
store i32 1, i32* %2
br label %25
22: ; preds = %20
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
store i8 0, i8* %24
store i32 0, i32* %2
br label %25
25: ; preds = %22, %21, %14, %9
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @t_read_sem(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 42
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp slt i32 %5, 2
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %13 [
i32 108, label %11
i32 110, label %11
i32 97, label %11
]
11: ; preds = %7, %7, %7
%12 = getelementptr inbounds i8, i8* %0, i64 2
store i8 0, i8* %12
br label %13
13: ; preds = %7, %4, %1, %11
%14 = phi i32 [ 0, %11 ], [ 1, %1 ], [ 1, %4 ], [ 1, %7 ]
ret i32 %14
}