#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*/ printf(char *, char *, int, char *, int, int);
int check(int problem, int answer, int result) {
  char *text = "INCORRECT";
  char *color = "\x1B[31m";
  int ret = 1;
  if (answer == result) {
    text = "CORRECT";
    color = "\x1B[32m";
    ret = 0;
  }
  printf("%sProblem %i %s - Expected: %i; Got %i\n", color, problem, text,
         answer, result);
  return ret;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    0xed8(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xed7(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1167 <check+0x57>
lea    0xeb1(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbx
mov    %edx,%r9d
mov    %esi,%r8d
mov    %edi,%edx
xor    %ebx,%ebx
cmp    %r9d,%esi
setne  %bl
lea    0xeda(%rip),%rax
lea    0xed1(%rip),%rcx
cmove  %rax,%rcx
lea    0xed6(%rip),%rax
lea    0xec9(%rip),%rsi
cmove  %rax,%rsi
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"INCORRECT\00"
@.str.1 = [6 x i8] c"\1B[31m\00"
@.str.2 = [8 x i8] c"CORRECT\00"
@.str.3 = [6 x i8] c"\1B[32m\00"
@.str.4 = [40 x i8] c"%sProblem %i %s - Expected: %i; Got %i\0A\00"
define i32 @check(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i32 1, i32* %9
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %8
store i32 0, i32* %9
br label %14
14: ; preds = %13, %3
%15 = load i8*, i8** %8
%16 = load i32, i32* %4
%17 = load i8*, i8** %7
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %15, i32 %16, i8* %17, i32 %18, i32 %19)
%21 = load i32, i32* %9
ret i32 %21
}

LLVM IR (-O2):
@.str = [10 x i8] c"INCORRECT\00"
@.str.1 = [6 x i8] c"\1B[31m\00"
@.str.2 = [8 x i8] c"CORRECT\00"
@.str.3 = [6 x i8] c"\1B[32m\00"
@.str.4 = [40 x i8] c"%sProblem %i %s - Expected: %i; Got %i\0A\00"
define i32 @check(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, %2
%5 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0)
%6 = select i1 %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%7 = xor i1 %4, true
%8 = zext i1 %7 to i32
%9 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %6, i32 %0, i8* %5, i32 %1, i32 %2)
ret i32 %8
}