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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(char *);
struct list *kPrimes(int, int, int);
char *list2String(struct list *);
int /*<<< orphan*/ listFree(struct list *);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void dotest(int k, int start, int end, char *expr) {
  struct list *act = kPrimes(k, start, end);
  char *sact = list2String(act);
  if (strcmp(sact, expr) != 0)
    printf("kPrimes. Error. Expected \n%s\n but got \n%s\n", expr, sact);
  assert(strcmp(sact, expr) == 0);
  listFree(act);
  act = NULL;
  free(sact);
  sact = NULL;
}


x86 assembly (clang, -O0):
<dotest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1090 <kPrimes@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <list2String@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11cf <dotest+0x5f>
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1070 <listFree@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotest>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
call   1090 <kPrimes@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1080 <list2String@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ad <dotest+0x3d>
lea    0xe5e(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1070 <listFree@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
%struct.list = type { i32 }
@.str = [43 x i8] c"kPrimes. Error. Expected \0A%s\0A but got \0A%s\0A\00"
define void @dotest(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca %struct.list*
%10 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call %struct.list* @kPrimes(i32 %11, i32 %12, i32 %13)
store %struct.list* %14, %struct.list** %9
%15 = load %struct.list*, %struct.list** %9
%16 = call i8* @list2String(%struct.list* %15)
store i8* %16, i8** %10
%17 = load i8*, i8** %10
%18 = load i8*, i8** %8
%19 = call i64 @strcmp(i8* %17, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %4
%22 = load i8*, i8** %8
%23 = load i8*, i8** %10
%24 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %23)
br label %25
25: ; preds = %21, %4
%26 = load i8*, i8** %10
%27 = load i8*, i8** %8
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp eq i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load %struct.list*, %struct.list** %9
%33 = call i32 @listFree(%struct.list* %32)
store %struct.list* null, %struct.list** %9
%34 = load i8*, i8** %10
%35 = call i32 @free(i8* %34)
store i8* null, i8** %10
ret void
}

LLVM IR (-O2):
%struct.list = type { i32 }
@.str = [43 x i8] c"kPrimes. Error. Expected \0A%s\0A but got \0A%s\0A\00"
define void @dotest(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = tail call %struct.list* @kPrimes(i32 %0, i32 %1, i32 %2)
%6 = tail call i8* @list2String(%struct.list* %5)
%7 = tail call i64 @strcmp(i8* %6, i8* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %6)
br label %11
11: ; preds = %9, %4
%12 = tail call i64 @strcmp(i8* %6, i8* %3)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @listFree(%struct.list* %5)
%17 = tail call i32 @free(i8* %6)
ret void
}