#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 zz_dict {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ strcmp(char const *, char const *);
struct zz_dict *zz_dict_delete(struct zz_dict *, char const *);
int /*<<< orphan*/ zz_dict_destroy(struct zz_dict *);
struct zz_dict *zz_dict_insert(struct zz_dict *, char const *, char const **);
int zz_dict_lookup(struct zz_dict *, char const *, char const **);
void insert_twice(void) {
  struct zz_dict *dict;
  static const char str[] = "This is a string";
  const char *s1, *s2;
  dict = NULL;
  dict = zz_dict_insert(dict, str, &s1);
  dict = zz_dict_insert(dict, str, &s2);
  assert(str != s1);
  assert(strcmp(str, s1) == 0);
  assert(s1 == s2);
  assert(zz_dict_lookup(dict, str, &s2) == 1);
  assert(s1 == s2);
  dict = zz_dict_delete(dict, str);
  assert(zz_dict_lookup(dict, str, &s2) == 1);
  assert(s1 == s2);
  dict = zz_dict_delete(dict, str);
  assert(zz_dict_lookup(dict, str, &s2) == 0);
  zz_dict_destroy(dict);
}


x86 assembly (clang, -O0):
<insert_twice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe85(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <zz_dict_insert@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <zz_dict_insert@plt>
mov    %rax,-0x8(%rbp)
lea    0xe59(%rip),%rax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe07(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <zz_dict_lookup@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1080 <zz_dict_delete@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdba(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <zz_dict_lookup@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1080 <zz_dict_delete@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd6d(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <zz_dict_lookup@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1070 <zz_dict_destroy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_twice>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%r12
lea    0x8(%rsp),%rdx
xor    %edi,%edi
mov    %r12,%rsi
call   1030 <zz_dict_insert@plt>
lea    0x10(%rsp),%r14
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <zz_dict_insert@plt>
mov    %rax,%r15
xor    %edi,%edi
cmp    %r12,0x8(%rsp)
setne  %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    0x10(%rsp),%rax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <zz_dict_lookup@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    0x10(%rsp),%rax
sete   %dil
call   1060 <assert@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <zz_dict_delete@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <zz_dict_lookup@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    0x10(%rsp),%rax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <zz_dict_delete@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <zz_dict_lookup@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1070 <zz_dict_destroy@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.zz_dict = type { i32 }
@insert_twice.str = internal constant [17 x i8] c"This is a string\00"
define void @insert_twice() {
%1 = alloca %struct.zz_dict*
%2 = alloca i8*
%3 = alloca i8*
store %struct.zz_dict* null, %struct.zz_dict** %1
%4 = load %struct.zz_dict*, %struct.zz_dict** %1
%5 = call %struct.zz_dict* @zz_dict_insert(%struct.zz_dict* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %2)
store %struct.zz_dict* %5, %struct.zz_dict** %1
%6 = load %struct.zz_dict*, %struct.zz_dict** %1
%7 = call %struct.zz_dict* @zz_dict_insert(%struct.zz_dict* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %3)
store %struct.zz_dict* %7, %struct.zz_dict** %1
%8 = load i8*, i8** %2
%9 = icmp ne i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %2
%13 = call i64 @strcmp(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %2
%18 = load i8*, i8** %3
%19 = icmp eq i8* %17, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load %struct.zz_dict*, %struct.zz_dict** %1
%23 = call i32 @zz_dict_lookup(%struct.zz_dict* %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %3)
%24 = icmp eq i32 %23, 1
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i8*, i8** %2
%28 = load i8*, i8** %3
%29 = icmp eq i8* %27, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load %struct.zz_dict*, %struct.zz_dict** %1
%33 = call %struct.zz_dict* @zz_dict_delete(%struct.zz_dict* %32, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0))
store %struct.zz_dict* %33, %struct.zz_dict** %1
%34 = load %struct.zz_dict*, %struct.zz_dict** %1
%35 = call i32 @zz_dict_lookup(%struct.zz_dict* %34, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %3)
%36 = icmp eq i32 %35, 1
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i8*, i8** %2
%40 = load i8*, i8** %3
%41 = icmp eq i8* %39, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = load %struct.zz_dict*, %struct.zz_dict** %1
%45 = call %struct.zz_dict* @zz_dict_delete(%struct.zz_dict* %44, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0))
store %struct.zz_dict* %45, %struct.zz_dict** %1
%46 = load %struct.zz_dict*, %struct.zz_dict** %1
%47 = call i32 @zz_dict_lookup(%struct.zz_dict* %46, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %3)
%48 = icmp eq i32 %47, 0
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load %struct.zz_dict*, %struct.zz_dict** %1
%52 = call i32 @zz_dict_destroy(%struct.zz_dict* %51)
ret void
}

LLVM IR (-O2):
%struct.zz_dict = type { i32 }
@insert_twice.str = internal constant [17 x i8] c"This is a string\00"
define void @insert_twice() {
%1 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
%4 = bitcast i8** %2 to i8*
%5 = call %struct.zz_dict* @zz_dict_insert(%struct.zz_dict* null, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %1)
%6 = call %struct.zz_dict* @zz_dict_insert(%struct.zz_dict* %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %2)
%7 = load i8*, i8** %1
%8 = icmp ne i8* %7, getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0)
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %1
%12 = call i64 @strcmp(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %1
%17 = load i8*, i8** %2
%18 = icmp eq i8* %16, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @zz_dict_lookup(%struct.zz_dict* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %2)
%22 = icmp eq i32 %21, 1
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i8*, i8** %1
%26 = load i8*, i8** %2
%27 = icmp eq i8* %25, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call %struct.zz_dict* @zz_dict_delete(%struct.zz_dict* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0))
%31 = call i32 @zz_dict_lookup(%struct.zz_dict* %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %2)
%32 = icmp eq i32 %31, 1
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i8*, i8** %1
%36 = load i8*, i8** %2
%37 = icmp eq i8* %35, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call %struct.zz_dict* @zz_dict_delete(%struct.zz_dict* %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0))
%41 = call i32 @zz_dict_lookup(%struct.zz_dict* %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @insert_twice.str, i64 0, i64 0), i8** %2)
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = call i32 @zz_dict_destroy(%struct.zz_dict* %40)
ret void
}