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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int ic_string_append_char(struct ic_string *, char *, int);
int ic_string_destroy(struct ic_string *, int);
int ic_string_equal(struct ic_string *, struct ic_string *);
struct ic_string *ic_string_new(char *, int);
struct ic_string *ic_string_new_empty();
void equality(void) {
  struct ic_string *str1 = 0;
  struct ic_string *str2 = 0;
  str1 = ic_string_new("Hello world", 11);
  assert(str1);
  str2 = ic_string_new_empty();
  assert(str2);
  assert(1 == ic_string_append_char(str2, "Hello world", 11));
  assert(1 == ic_string_equal(str1, str2));
  assert(1 == ic_string_append_char(str2, ".", 1));
  assert(0 == ic_string_equal(str1, str2));
  assert(1 == ic_string_destroy(str1, 1));
  assert(1 == ic_string_destroy(str2, 1));
}


x86 assembly (clang, -O0):
<equality>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe81(%rip),%rdi
mov    $0xb,%esi
call   1080 <ic_string_new@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1070 <ic_string_new_empty@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
mov    $0xb,%edx
call   1040 <ic_string_append_char@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <ic_string_equal@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xe05(%rip),%rsi
mov    $0x1,%edx
call   1040 <ic_string_append_char@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <ic_string_equal@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <ic_string_destroy@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <ic_string_destroy@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<equality>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%r15
mov    %r15,%rdi
mov    $0xb,%esi
call   1080 <ic_string_new@plt>
mov    %rax,%r14
mov    %r14d,%edi
call   1060 <assert@plt>
xor    %eax,%eax
call   1070 <ic_string_new_empty@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xb,%edx
call   1040 <ic_string_append_char@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <ic_string_equal@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe39(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1040 <ic_string_append_char@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <ic_string_equal@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <ic_string_destroy@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <ic_string_destroy@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <assert@plt>

LLVM IR (-O0):
%struct.ic_string = type { i32 }
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [2 x i8] c".\00"
define void @equality() {
%1 = alloca %struct.ic_string*
%2 = alloca %struct.ic_string*
store %struct.ic_string* null, %struct.ic_string** %1
store %struct.ic_string* null, %struct.ic_string** %2
%3 = call %struct.ic_string* @ic_string_new(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
store %struct.ic_string* %3, %struct.ic_string** %1
%4 = load %struct.ic_string*, %struct.ic_string** %1
%5 = ptrtoint %struct.ic_string* %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = call %struct.ic_string* (...) @ic_string_new_empty()
store %struct.ic_string* %7, %struct.ic_string** %2
%8 = load %struct.ic_string*, %struct.ic_string** %2
%9 = ptrtoint %struct.ic_string* %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load %struct.ic_string*, %struct.ic_string** %2
%12 = call i32 @ic_string_append_char(%struct.ic_string* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%13 = icmp eq i32 1, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load %struct.ic_string*, %struct.ic_string** %1
%17 = load %struct.ic_string*, %struct.ic_string** %2
%18 = call i32 @ic_string_equal(%struct.ic_string* %16, %struct.ic_string* %17)
%19 = icmp eq i32 1, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load %struct.ic_string*, %struct.ic_string** %2
%23 = call i32 @ic_string_append_char(%struct.ic_string* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%24 = icmp eq i32 1, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load %struct.ic_string*, %struct.ic_string** %1
%28 = load %struct.ic_string*, %struct.ic_string** %2
%29 = call i32 @ic_string_equal(%struct.ic_string* %27, %struct.ic_string* %28)
%30 = icmp eq i32 0, %29
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load %struct.ic_string*, %struct.ic_string** %1
%34 = call i32 @ic_string_destroy(%struct.ic_string* %33, i32 1)
%35 = icmp eq i32 1, %34
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load %struct.ic_string*, %struct.ic_string** %2
%39 = call i32 @ic_string_destroy(%struct.ic_string* %38, i32 1)
%40 = icmp eq i32 1, %39
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
ret void
}

LLVM IR (-O2):
%struct.ic_string = type { i32 }
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [2 x i8] c".\00"
define void @equality() {
%1 = tail call %struct.ic_string* @ic_string_new(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%2 = ptrtoint %struct.ic_string* %1 to i64
%3 = trunc i64 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call %struct.ic_string* (...) @ic_string_new_empty()
%6 = ptrtoint %struct.ic_string* %5 to i64
%7 = trunc i64 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @ic_string_append_char(%struct.ic_string* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%10 = icmp eq i32 %9, 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @ic_string_equal(%struct.ic_string* %1, %struct.ic_string* %5)
%14 = icmp eq i32 %13, 1
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i32 @ic_string_append_char(%struct.ic_string* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @ic_string_equal(%struct.ic_string* %1, %struct.ic_string* %5)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i32 @ic_string_destroy(%struct.ic_string* %1, i32 1)
%26 = icmp eq i32 %25, 1
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i32 @ic_string_destroy(%struct.ic_string* %5, i32 1)
%30 = icmp eq i32 %29, 1
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
ret void
}