#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 /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(char *);
int quark_from_static_string(char const *);
int quark_from_string(char const *);
char *quark_to_string(int);
char *strdup(char const *);
int main(int argc, char **argv) {
  assert(quark_from_string(NULL) == 0);
  assert(quark_to_string(0) == NULL);
  const char *foo = "foo";
  assert(quark_from_string(foo) == 1);
  assert(quark_from_string(foo) == 1);
  assert(quark_to_string(1) != foo);
  const char *bar = "bar";
  assert(quark_from_static_string(bar) == 2);
  assert(quark_to_string(2) == bar);
  char *foo2 = strdup(foo);
  assert(quark_from_string(foo2) == 1);
  assert(quark_to_string(1) != foo2);
  free(foo2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <quark_from_string@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %edi,%edi
call   1060 <quark_to_string@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe52(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <quark_from_string@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <quark_from_string@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0x1,%edi
call   1060 <quark_to_string@plt>
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xdfe(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <quark_from_static_string@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0x2,%edi
call   1060 <quark_to_string@plt>
cmp    -0x20(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <quark_from_string@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    $0x1,%edi
call   1060 <quark_to_string@plt>
cmp    -0x28(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1040 <quark_from_string@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
call   1060 <quark_to_string@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe6c(%rip),%r14
mov    %r14,%rdi
call   1040 <quark_from_string@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
call   1040 <quark_from_string@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
mov    $0x1,%edi
call   1060 <quark_to_string@plt>
xor    %edi,%edi
cmp    %r14,%rax
setne  %dil
call   1070 <assert@plt>
lea    0xe25(%rip),%rbx
mov    %rbx,%rdi
call   1050 <quark_from_static_string@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1070 <assert@plt>
mov    $0x2,%edi
call   1060 <quark_to_string@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <quark_from_string@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
mov    $0x1,%edi
call   1060 <quark_to_string@plt>
xor    %edi,%edi
cmp    %rbx,%rax
setne  %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @quark_from_string(i8* null)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i8* @quark_to_string(i32 0)
%14 = icmp eq i8* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %6
%17 = load i8*, i8** %6
%18 = call i32 @quark_from_string(i8* %17)
%19 = icmp eq i32 %18, 1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i8*, i8** %6
%23 = call i32 @quark_from_string(i8* %22)
%24 = icmp eq i32 %23, 1
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i8* @quark_to_string(i32 1)
%28 = load i8*, i8** %6
%29 = icmp ne i8* %27, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %7
%32 = load i8*, i8** %7
%33 = call i32 @quark_from_static_string(i8* %32)
%34 = icmp eq i32 %33, 2
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i8* @quark_to_string(i32 2)
%38 = load i8*, i8** %7
%39 = icmp eq i8* %37, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i8*, i8** %6
%43 = call i8* @strdup(i8* %42)
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = call i32 @quark_from_string(i8* %44)
%46 = icmp eq i32 %45, 1
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = call i8* @quark_to_string(i32 1)
%50 = load i8*, i8** %8
%51 = icmp ne i8* %49, %50
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i8*, i8** %8
%55 = call i32 @free(i8* %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @quark_from_string(i8* null)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i8* @quark_to_string(i32 0)
%8 = icmp eq i8* %7, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @quark_from_string(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @quark_from_string(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 1
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i8* @quark_to_string(i32 1)
%20 = icmp ne i8* %19, getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0)
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i32 @quark_from_static_string(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32 %23, 2
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i8* @quark_to_string(i32 2)
%28 = icmp eq i8* %27, getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call dereferenceable_or_null(4) i8* @strdup(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @quark_from_string(i8* %31)
%33 = icmp eq i32 %32, 1
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
%36 = tail call i8* @quark_to_string(i32 1)
%37 = icmp ne i8* %36, %31
%38 = zext i1 %37 to i32
%39 = tail call i32 @assert(i32 %38)
%40 = tail call i32 @free(i8* %31)
ret i32 0
}