#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int fts_instr;
};
typedef TYPE_1__ FTSENT;
typedef int /*<<< orphan*/ FTS;

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int FTS_AGAIN;
int FTS_FOLLOW;
int FTS_NOINSTR;
int FTS_SKIP;
int /*<<< orphan*/ _DIAGASSERT(int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int fts_set(FTS *sp, FTSENT *p, int instr) {
  _DIAGASSERT(sp != NULL);
  _DIAGASSERT(p != NULL);
  if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
      instr != FTS_NOINSTR && instr != FTS_SKIP) {
    errno = EINVAL;
    return (1);
  }
  p->fts_instr = instr;
  return (0);
}


x86 assembly (clang, -O0):
<fts_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <_DIAGASSERT@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <_DIAGASSERT@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11b7 <fts_set+0xa7>
mov    -0x1c(%rbp),%eax
mov    0x2e8d(%rip),%rcx
cmp    (%rcx),%eax
je     11b7 <fts_set+0xa7>
mov    -0x1c(%rbp),%eax
mov    0x2e8b(%rip),%rcx
cmp    (%rcx),%eax
je     11b7 <fts_set+0xa7>
mov    -0x1c(%rbp),%eax
mov    0x2e41(%rip),%rcx
cmp    (%rcx),%eax
je     11b7 <fts_set+0xa7>
mov    -0x1c(%rbp),%eax
mov    0x2e47(%rip),%rcx
cmp    (%rcx),%eax
je     11b7 <fts_set+0xa7>
mov    0x2e18(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1f(%rip),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11c7 <fts_set+0xb7>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_set>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
xor    %eax,%eax
test   %rdi,%rdi
setne  %al
mov    %eax,%edi
call   1030 <_DIAGASSERT@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <_DIAGASSERT@plt>
test   %ebx,%ebx
je     117f <fts_set+0x6f>
mov    0x2ea7(%rip),%rax
cmp    %ebx,(%rax)
je     117f <fts_set+0x6f>
mov    0x2eac(%rip),%rax
cmp    %ebx,(%rax)
je     117f <fts_set+0x6f>
mov    0x2e69(%rip),%rax
cmp    %ebx,(%rax)
je     117f <fts_set+0x6f>
mov    0x2e76(%rip),%rax
cmp    %ebx,(%rax)
je     117f <fts_set+0x6f>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    0x2e52(%rip),%rcx
mov    %eax,(%rcx)
mov    $0x1,%eax
jmp    1184 <fts_set+0x74>
mov    %ebx,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@FTS_AGAIN = global i32 0
@FTS_FOLLOW = global i32 0
@FTS_NOINSTR = global i32 0
@FTS_SKIP = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
define i32 @fts_set(i32* %0, %struct.TYPE_3__* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.TYPE_3__*
%7 = alloca i32
store i32* %0, i32** %5
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %6
store i32 %2, i32* %7
%8 = load i32*, i32** %5
%9 = icmp ne i32* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @_DIAGASSERT(i32 %10)
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%13 = icmp ne %struct.TYPE_3__* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @_DIAGASSERT(i32 %14)
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %3
%19 = load i32, i32* %7
%20 = load i32, i32* @FTS_AGAIN
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32, i32* %7
%24 = load i32, i32* @FTS_FOLLOW
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %36
26: ; preds = %22
%27 = load i32, i32* %7
%28 = load i32, i32* @FTS_NOINSTR
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i32, i32* %7
%32 = load i32, i32* @FTS_SKIP
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* @EINVAL
store i32 %35, i32* @errno
store i32 1, i32* %4
br label %40
36: ; preds = %30, %26, %22, %18, %3
%37 = load i32, i32* %7
%38 = load %struct.TYPE_3__*, %struct.TYPE_3__** %6
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %38, i32 0, i32 0
store i32 %37, i32* %39
store i32 0, i32* %4
br label %40
40: ; preds = %36, %34
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@FTS_AGAIN = global i32 0
@FTS_FOLLOW = global i32 0
@FTS_NOINSTR = global i32 0
@FTS_SKIP = global i32 0
@EINVAL = global i32 0
@errno = global i32 0
define i32 @fts_set(i32* readnone %0, %struct.TYPE_3__* writeonly %1, i32 %2) {
%4 = icmp ne i32* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @_DIAGASSERT(i32 %5)
%7 = icmp ne %struct.TYPE_3__* %1, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @_DIAGASSERT(i32 %8)
%10 = icmp eq i32 %2, 0
%11 = load i32, i32* @FTS_AGAIN
%12 = icmp eq i32 %11, %2
%13 = select i1 %10, i1 true, i1 %12
%14 = load i32, i32* @FTS_FOLLOW
%15 = icmp eq i32 %14, %2
%16 = select i1 %13, i1 true, i1 %15
%17 = load i32, i32* @FTS_NOINSTR
%18 = icmp eq i32 %17, %2
%19 = select i1 %16, i1 true, i1 %18
%20 = load i32, i32* @FTS_SKIP
%21 = icmp eq i32 %20, %2
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %25, label %23
23: ; preds = %3
%24 = load i32, i32* @EINVAL
store i32 %24, i32* @errno
br label %27
25: ; preds = %3
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
store i32 %2, i32* %26
br label %27
27: ; preds = %25, %23
%28 = phi i32 [ 1, %23 ], [ 0, %25 ]
ret i32 %28
}