#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*/ call_ccalc(char *, char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
bool expect(char *expr, char *opts, char *expected) {
  char result[512];
  char desired[512];
  snprintf(desired, 512, "%s\n", expected);
  if (!call_ccalc(expr, opts, result, 512))
    return false;
  bool cmp = !strcmp(result, desired);
  if (!cmp) {
    printf("Test failed: ");
    printf("%s\nExpected: %sReceived: %s", expr, desired, result);
  }
  return cmp;
}


x86 assembly (clang, -O0):
<expect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x200,%esi
lea    0xe92(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x220(%rbp),%rdx
mov    $0x200,%ecx
call   1060 <call_ccalc@plt>
cmp    $0x0,%eax
jne    11a1 <expect+0x61>
movl   $0x0,-0x4(%rbp)
jmp    120b <expect+0xcb>
lea    -0x220(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
jne    1202 <expect+0xc2>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x424(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expect>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%rcx
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xea7(%rip),%rdx
mov    %rsp,%rdi
mov    $0x200,%esi
call   1040 <snprintf@plt>
lea    0x200(%rsp),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x200,%ecx
call   1060 <call_ccalc@plt>
test   %eax,%eax
je     11c4 <expect+0x84>
lea    0x200(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11c8 <expect+0x88>
lea    0xe67(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe65(%rip),%rdi
mov    %rsp,%rdx
lea    0x200(%rsp),%rcx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11cd <expect+0x8d>
xor    %ebp,%ebp
jmp    11cd <expect+0x8d>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [14 x i8] c"Test failed: \00"
@.str.2 = [28 x i8] c"%s\0AExpected: %sReceived: %s\00"
define i32 @expect(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %7
%13 = call i32 @snprintf(i8* %11, i32 512, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%17 = call i32 @call_ccalc(i8* %14, i8* %15, i8* %16, i32 512)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %3
store i32 0, i32* %4
br label %37
20: ; preds = %3
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%23 = call i32 @strcmp(i8* %21, i8* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
store i32 %26, i32* %10
%27 = load i32, i32* %10
%28 = icmp ne i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %20
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%31 = load i8*, i8** %5
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32, i8* %33)
br label %35
35: ; preds = %29, %20
%36 = load i32, i32* %10
store i32 %36, i32* %4
br label %37
37: ; preds = %35, %19
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [14 x i8] c"Test failed: \00"
@.str.2 = [28 x i8] c"%s\0AExpected: %sReceived: %s\00"
define i32 @expect(i8* %0, i8* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 512, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = call i32 @call_ccalc(i8* %0, i8* %1, i8* %6, i32 512)
%10 = icmp eq i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = call i32 @strcmp(i8* %6, i8* %7)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %7, i8* %6)
br label %17
17: ; preds = %11, %14, %3
%18 = phi i32 [ 0, %3 ], [ 0, %14 ], [ 1, %11 ]
ret i32 %18
}