#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 */
typedef int /*<<< orphan*/ nosave_regs;

/* Variables and functions */
scalar_t__ strcmp(char const *, char const *);
int is_x86_reg_saved(const char *reg) {
  static const char *nosave_regs[] = {"eax", "edx", "ecx"};
  int nosave = 0;
  int r;
  for (r = 0; r < (sizeof(nosave_regs) / sizeof(nosave_regs[0])); r++)
    if (strcmp(reg, nosave_regs[r]) == 0)
      nosave = 1;
  return !nosave;
}


x86 assembly (clang, -O0):
<is_x86_reg_saved>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
cmp    $0x3,%rax
jae    1174 <is_x86_reg_saved+0x64>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rcx
lea    0x2ee9(%rip),%rax
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1161 <is_x86_reg_saved+0x51>
movl   $0x1,-0xc(%rbp)
jmp    1166 <is_x86_reg_saved+0x56>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <is_x86_reg_saved+0x1a>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_x86_reg_saved>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xee2(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
setne  %bpl
lea    0xed3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
setne  %r14b
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
setne  %al
and    %r14b,%al
and    %bpl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@is_x86_reg_saved.nosave_regs = internal global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0)]
@.str = [4 x i8] c"eax\00"
@.str.1 = [4 x i8] c"edx\00"
@.str.2 = [4 x i8] c"ecx\00"
define i32 @is_x86_reg_saved(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 3
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* @is_x86_reg_saved.nosave_regs, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %10, i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %9
store i32 1, i32* %3
br label %18
18: ; preds = %17, %9
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %5
22: ; preds = %5
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
@.str = [4 x i8] c"eax\00"
@.str.1 = [4 x i8] c"edx\00"
@.str.2 = [4 x i8] c"ecx\00"
define i32 @is_x86_reg_saved(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
%8 = select i1 %7, i1 %5, i1 false
%9 = select i1 %8, i1 %3, i1 false
%10 = zext i1 %9 to i32
ret i32 %10
}