#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 */
typedef int mode_t;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int expect_msk(int expected, mode_t ret) {
  printf("\tMSK Expected %s, Got 0x%x(0%o) "
         "(Will always return expected))\n",
         expected == 0 ? "SUCCESS" : "FAILURE", ret, ret);
  fflush(NULL);
  if (expected == -1) {
    printf("\tFailed Phase 2: You may not expect failure on a mode_t.\n");
    fflush(NULL);
  }
  return 0;
}


x86 assembly (clang, -O0):
<expect_msk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
lea    0xf10(%rip),%rsi
lea    0xf01(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    1184 <expect_msk+0x64>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expect_msk>:
push   %rbx
mov    %esi,%ecx
mov    %edi,%ebx
test   %edi,%edi
lea    0xf02(%rip),%rax
lea    0xf03(%rip),%rsi
cmove  %rax,%rsi
lea    0xeb0(%rip),%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <fflush@plt>
cmp    $0xffffffff,%ebx
jne    1178 <expect_msk+0x48>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <fflush@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [64 x i8] c"\09MSK Expected %s, Got 0x%x(0%o) (Will always return expected))\0A\00"
@.str.1 = [8 x i8] c"SUCCESS\00"
@.str.2 = [8 x i8] c"FAILURE\00"
@.str.3 = [58 x i8] c"\09Failed Phase 2: You may not expect failure on a mode_t.\0A\00"
define i32 @expect_msk(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%9 = load i32, i32* %4
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9, i32 %10)
%12 = call i32 @fflush(i32* null)
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @fflush(i32* null)
br label %18
18: ; preds = %15, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [64 x i8] c"\09MSK Expected %s, Got 0x%x(0%o) (Will always return expected))\0A\00"
@.str.1 = [8 x i8] c"SUCCESS\00"
@.str.2 = [8 x i8] c"FAILURE\00"
@str = [57 x i8] c"\09Failed Phase 2: You may not expect failure on a mode_t.\00"
define i32 @expect_msk(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
%4 = select i1 %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %1, i32 %1)
%6 = tail call i32 @fflush(i32* null)
%7 = icmp eq i32 %0, -1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @fflush(i32* null)
br label %11
11: ; preds = %8, %2
ret i32 0
}