#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 consecKprimes(int, struct list *);
int /*<<< orphan*/ free(char *);
char *list2String(struct list *);
int /*<<< orphan*/ printf(char *, int, int);
void dotest(int k, struct list *l, int expr) {
  int act = consecKprimes(k, l);
  char *s = list2String(l);
  if (act != expr)
    printf("Expected %d, got %d\n", expr, act);
  assert(act == expr);
  free(s);
  s = NULL;
}


x86 assembly (clang, -O0):
<dotest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <consecKprimes@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <list2String@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     119c <dotest+0x4c>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotest>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%rbx
call   1070 <consecKprimes@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <list2String@plt>
mov    %rax,%r14
cmp    %r15d,%ebp
je     1185 <dotest+0x35>
lea    0xe85(%rip),%rdi
mov    %r15d,%esi
mov    %ebp,%edx
call   1040 <printf@plt>
xor    %edi,%edi
cmp    %r15d,%ebp
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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