#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 gid_t;

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


x86 assembly (clang, -O0):
<expect_gid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
lea    0xf09(%rip),%rsi
lea    0xefa(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rsi
mov    -0x8(%rbp),%edx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <fflush@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    1181 <expect_gid+0x61>
lea    0xed8(%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_gid>:
push   %rbx
mov    %esi,%edx
mov    %edi,%ebx
test   %edi,%edi
lea    0xefb(%rip),%rax
lea    0xefc(%rip),%rsi
cmove  %rax,%rsi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <fflush@plt>
cmp    $0xffffffff,%ebx
jne    1176 <expect_gid+0x46>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <fflush@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"\09GID Expected %s, Got %u (Will always return expected))\0A\00"
@.str.1 = [8 x i8] c"SUCCESS\00"
@.str.2 = [8 x i8] c"FAILURE\00"
@.str.3 = [57 x i8] c"\09Failed Phase 2: You may not expect failure on a gid_t.\0A\00"
define i32 @expect_gid(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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
%11 = call i32 @fflush(i32* null)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @fflush(i32* null)
br label %17
17: ; preds = %14, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"\09GID Expected %s, Got %u (Will always return expected))\0A\00"
@.str.1 = [8 x i8] c"SUCCESS\00"
@.str.2 = [8 x i8] c"FAILURE\00"
@str = [56 x i8] c"\09Failed Phase 2: You may not expect failure on a gid_t.\00"
define i32 @expect_gid(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 ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i8* %4, 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 ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @fflush(i32* null)
br label %11
11: ; preds = %8, %2
ret i32 0
}