#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 mycli();
int /*<<< orphan*/ mysti(int);
int /*<<< orphan*/ panic(char *);
void insque(void *entry, void *pred) {
  if (entry == pred)
    panic("same\n");
  if (entry == *(long *)pred)
    panic("same\n");
  if (entry == *(long *)(((long)pred) + 8))
    panic("same\n");
  int flag = mycli();
  *(void **)entry = *(void **)pred;
  *(void **)(entry + 8) = pred;
  *(void **)((*(void **)pred) + 8) = entry;
  *(void **)pred = entry;
  mysti(flag);
}


x86 assembly (clang, -O0):
<insque>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    115a <insque+0x2a>
lea    0xeab(%rip),%rdi
call   1030 <panic@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
cmp    %rcx,%rax
jne    117a <insque+0x4a>
lea    0xe8b(%rip),%rdi
call   1030 <panic@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%rcx
cmp    %rcx,%rax
jne    119b <insque+0x6b>
lea    0xe6a(%rip),%rdi
call   1030 <panic@plt>
mov    $0x0,%al
call   1050 <mycli@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%edi
call   1040 <mysti@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insque>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    %rsi,%rdi
je     1173 <insque+0x43>
cmp    %rbx,(%r14)
je     1184 <insque+0x54>
cmp    %rbx,0x8(%r14)
je     1196 <insque+0x66>
xor    %eax,%eax
call   1050 <mycli@plt>
mov    (%r14),%rcx
mov    %rcx,(%rbx)
mov    %r14,0x8(%rbx)
mov    (%r14),%rcx
mov    %rbx,0x8(%rcx)
mov    %rbx,(%r14)
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mysti@plt>
lea    0xe86(%rip),%rdi
call   1030 <panic@plt>
cmp    %rbx,(%r14)
jne    1144 <insque+0x14>
lea    0xe75(%rip),%rdi
call   1030 <panic@plt>
cmp    %rbx,0x8(%r14)
jne    114a <insque+0x1a>
lea    0xe63(%rip),%rdi
call   1030 <panic@plt>
jmp    114a <insque+0x1a>

LLVM IR (-O0):
@.str = [6 x i8] c"same\0A\00"
define void @insque(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = icmp eq i8* %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @panic(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = bitcast i8* %13 to i64*
%15 = load i64, i64* %14
%16 = inttoptr i64 %15 to i8*
%17 = icmp eq i8* %12, %16
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = call i32 @panic(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %11
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = ptrtoint i8* %22 to i64
%24 = add nsw i64 %23, 8
%25 = inttoptr i64 %24 to i64*
%26 = load i64, i64* %25
%27 = inttoptr i64 %26 to i8*
%28 = icmp eq i8* %21, %27
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 @panic(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %20
%32 = call i32 (...) @mycli()
store i32 %32, i32* %5
%33 = load i8*, i8** %4
%34 = bitcast i8* %33 to i8**
%35 = load i8*, i8** %34
%36 = load i8*, i8** %3
%37 = bitcast i8* %36 to i8**
store i8* %35, i8** %37
%38 = load i8*, i8** %4
%39 = load i8*, i8** %3
%40 = getelementptr i8, i8* %39, i64 8
%41 = bitcast i8* %40 to i8**
store i8* %38, i8** %41
%42 = load i8*, i8** %3
%43 = load i8*, i8** %4
%44 = bitcast i8* %43 to i8**
%45 = load i8*, i8** %44
%46 = getelementptr i8, i8* %45, i64 8
%47 = bitcast i8* %46 to i8**
store i8* %42, i8** %47
%48 = load i8*, i8** %3
%49 = load i8*, i8** %4
%50 = bitcast i8* %49 to i8**
store i8* %48, i8** %50
%51 = load i32, i32* %5
%52 = call i32 @mysti(i32 %51)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"same\0A\00"
define void @insque(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, %1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @panic(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = bitcast i8* %1 to i64*
%8 = load i64, i64* %7
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i8* %9, %0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @panic(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = ptrtoint i8* %1 to i64
%15 = add nsw i64 %14, 8
%16 = inttoptr i64 %15 to i64*
%17 = load i64, i64* %16
%18 = inttoptr i64 %17 to i8*
%19 = icmp eq i8* %18, %0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = tail call i32 @panic(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %13
%23 = tail call i32 (...) @mycli()
%24 = bitcast i8* %1 to i8**
%25 = load i8*, i8** %24
%26 = bitcast i8* %0 to i8**
store i8* %25, i8** %26
%27 = getelementptr i8, i8* %0, i64 8
%28 = bitcast i8* %27 to i8**
store i8* %1, i8** %28
%29 = load i8*, i8** %24
%30 = getelementptr i8, i8* %29, i64 8
%31 = bitcast i8* %30 to i8**
store i8* %0, i8** %31
store i8* %0, i8** %24
%32 = tail call i32 @mysti(i32 %23)
ret void
}