#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 */
struct imap {
  int dummy;
};

/* Variables and functions */
struct imap *nxt(struct imap *, int);
scalar_t__ opeq(struct imap *, char const *, int /*<<< orphan*/,
                int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sethli(struct imap *, int, int);
int chkcmpjmp(struct imap *ci, const char *op2, int hli) {
  if (opeq(ci, "cmp", 0, 0, 0) || opeq(ci, "or", 0, 0, 0) ||
      opeq(ci, "test", 0, 0, 0)) {
    if (opeq(nxt(ci, 1), op2, 0, 0, 0)) {
      sethli(ci, hli, 1);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<chkcmpjmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <opeq@plt>
cmp    $0x0,%rax
jne    11ac <chkcmpjmp+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <opeq@plt>
cmp    $0x0,%rax
jne    11ac <chkcmpjmp+0x7c>
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <opeq@plt>
cmp    $0x0,%rax
je     11fb <chkcmpjmp+0xcb>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1050 <nxt@plt>
mov    %rax,%rdi
mov    -0x18(%rbp),%rsi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1030 <opeq@plt>
cmp    $0x0,%rax
je     11f6 <chkcmpjmp+0xc6>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x1,%edx
call   1040 <sethli@plt>
movl   $0x1,-0x4(%rbp)
jmp    1202 <chkcmpjmp+0xd2>
jmp    11fb <chkcmpjmp+0xcb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chkcmpjmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeb9(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <opeq@plt>
test   %rax,%rax
jne    1190 <chkcmpjmp+0x60>
lea    0xea5(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <opeq@plt>
test   %rax,%rax
jne    1190 <chkcmpjmp+0x60>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <opeq@plt>
test   %rax,%rax
je     11ce <chkcmpjmp+0x9e>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <nxt@plt>
mov    %rax,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <opeq@plt>
mov    $0x0,%ebp
test   %rax,%rax
je     11ce <chkcmpjmp+0x9e>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
call   1040 <sethli@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.imap = type { i32 }
@.str = [4 x i8] c"cmp\00"
@.str.1 = [3 x i8] c"or\00"
@.str.2 = [5 x i8] c"test\00"
define i32 @chkcmpjmp(%struct.imap* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.imap*
%6 = alloca i8*
%7 = alloca i32
store %struct.imap* %0, %struct.imap** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load %struct.imap*, %struct.imap** %5
%9 = call i64 @opeq(%struct.imap* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 0)
%10 = icmp ne i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %3
%12 = load %struct.imap*, %struct.imap** %5
%13 = call i64 @opeq(%struct.imap* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 0)
%14 = icmp ne i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load %struct.imap*, %struct.imap** %5
%17 = call i64 @opeq(%struct.imap* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 0)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %15, %11, %3
%20 = load %struct.imap*, %struct.imap** %5
%21 = call %struct.imap* @nxt(%struct.imap* %20, i32 1)
%22 = load i8*, i8** %6
%23 = call i64 @opeq(%struct.imap* %21, i8* %22, i32 0, i32 0, i32 0)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load %struct.imap*, %struct.imap** %5
%27 = load i32, i32* %7
%28 = call i32 @sethli(%struct.imap* %26, i32 %27, i32 1)
store i32 1, i32* %4
br label %31
29: ; preds = %19
br label %30
30: ; preds = %29, %15
store i32 0, i32* %4
br label %31
31: ; preds = %30, %25
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
%struct.imap = type { i32 }
@.str = [4 x i8] c"cmp\00"
@.str.1 = [3 x i8] c"or\00"
@.str.2 = [5 x i8] c"test\00"
define i32 @chkcmpjmp(%struct.imap* %0, i8* %1, i32 %2) {
%4 = tail call i64 @opeq(%struct.imap* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i64 @opeq(%struct.imap* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i64 @opeq(%struct.imap* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 0, i32 0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9, %6, %3
%13 = tail call %struct.imap* @nxt(%struct.imap* %0, i32 1)
%14 = tail call i64 @opeq(%struct.imap* %13, i8* %1, i32 0, i32 0, i32 0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = tail call i32 @sethli(%struct.imap* %0, i32 %2, i32 1)
br label %18
18: ; preds = %9, %12, %16
%19 = phi i32 [ 1, %16 ], [ 0, %12 ], [ 0, %9 ]
ret i32 %19
}