#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 FNM_NOESCAPE;
int FNM_PATHNAME;
int FNM_PERIOD;
char *stpcpy(char *, char *);
char *flag_output(int flags) {
  static char buf[100];
  int first = 1;
  char *cp = buf;
  if (flags & FNM_PATHNAME) {
    cp = stpcpy(cp, "FNM_PATHNAME");
    first = 0;
  }
  if (flags & FNM_NOESCAPE) {
    if (!first)
      *cp++ = '|';
    cp = stpcpy(cp, "FNM_NOESCAPE");
    first = 0;
  }
  if (flags & FNM_PERIOD) {
    if (!first)
      *cp++ = '|';
    cp = stpcpy(cp, "FNM_PERIOD");
    first = 0;
  }
  if (cp == buf)
    *cp++ = '0';
  *cp = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<flag_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0x2f17(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e91(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     115d <flag_output+0x4d>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e91(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a9 <flag_output+0x99>
cmpl   $0x0,-0x8(%rbp)
jne    118e <flag_output+0x7e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x7c,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e25(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11f5 <flag_output+0xe5>
cmpl   $0x0,-0x8(%rbp)
jne    11da <flag_output+0xca>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x7c,(%rax)
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0x2e44(%rip),%rax
cmp    %rax,-0x10(%rbp)
jne    1218 <flag_output+0x108>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x30,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e1a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flag_output>:
mov    0x2ec1(%rip),%rax
test   %edi,(%rax)
je     1148 <flag_output+0x48>
movabs $0x454d414e485441,%rax
mov    %rax,0x2f19(%rip)
movabs $0x485441505f4d4e46,%rax
41 54 48
mov    %rax,0x2f03(%rip)
mov    0x2ec4(%rip),%rax
test   %edi,(%rax)
je     117f <flag_output+0x7f>
movb   $0x7c,0x2efd(%rip)
lea    0x2ef7(%rip),%rcx
jmp    115e <flag_output+0x5e>
mov    0x2ea9(%rip),%rax
test   %edi,(%rax)
je     11d8 <flag_output+0xd8>
lea    0x2ed2(%rip),%rcx
lea    0xc(%rcx),%rax
movabs $0x4550414353454f,%rdx
mov    %rdx,0x5(%rcx)
movabs $0x53454f4e5f4d4e46,%rdx
4f 45 53
mov    %rdx,(%rcx)
jmp    1186 <flag_output+0x86>
lea    0x2eb6(%rip),%rax
mov    0x2e4b(%rip),%rcx
test   %edi,(%rcx)
je     11b3 <flag_output+0xb3>
movb   $0x7c,(%rax)
add    $0x1,%rax
mov    %rax,%rcx
lea    0xa(%rcx),%rax
movabs $0x495245505f4d4e46,%rdx
45 52 49
mov    %rdx,(%rcx)
movl   $0x444f49,0x7(%rcx)
lea    0x2e76(%rip),%rcx
cmp    %rcx,%rax
jne    11cd <flag_output+0xcd>
movb   $0x30,0x2e6a(%rip)
lea    0x2e64(%rip),%rax
movb   $0x0,(%rax)
lea    0x2e59(%rip),%rax
ret
mov    0x2df9(%rip),%rax
test   %edi,(%rax)
je     11bf <flag_output+0xbf>
lea    0x2e46(%rip),%rcx
jmp    119b <flag_output+0x9b>

LLVM IR (-O0):
@flag_output.buf = internal global [100 x i8] zeroinitializer
@FNM_PATHNAME = global i32 0
@.str = [13 x i8] c"FNM_PATHNAME\00"
@FNM_NOESCAPE = global i32 0
@.str.1 = [13 x i8] c"FNM_NOESCAPE\00"
@FNM_PERIOD = global i32 0
@.str.2 = [11 x i8] c"FNM_PERIOD\00"
define i8* @flag_output(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 1, i32* %3
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0), i8** %4
%5 = load i32, i32* %2
%6 = load i32, i32* @FNM_PATHNAME
%7 = and i32 %5, %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %4
%11 = call i8* @stpcpy(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %4
store i32 0, i32* %3
br label %12
12: ; preds = %9, %1
%13 = load i32, i32* %2
%14 = load i32, i32* @FNM_NOESCAPE
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
store i8 124, i8* %21
br label %23
23: ; preds = %20, %17
%24 = load i8*, i8** %4
%25 = call i8* @stpcpy(i8* %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i8* %25, i8** %4
store i32 0, i32* %3
br label %26
26: ; preds = %23, %12
%27 = load i32, i32* %2
%28 = load i32, i32* @FNM_PERIOD
%29 = and i32 %27, %28
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %26
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
store i8 124, i8* %35
br label %37
37: ; preds = %34, %31
%38 = load i8*, i8** %4
%39 = call i8* @stpcpy(i8* %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i8* %39, i8** %4
store i32 0, i32* %3
br label %40
40: ; preds = %37, %26
%41 = load i8*, i8** %4
%42 = icmp eq i8* %41, getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0)
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %4
store i8 48, i8* %44
br label %46
46: ; preds = %43, %40
%47 = load i8*, i8** %4
store i8 0, i8* %47
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@flag_output.buf = internal global [100 x i8] zeroinitializer
@FNM_PATHNAME = global i32 0
@.str = [13 x i8] c"FNM_PATHNAME\00"
@FNM_NOESCAPE = global i32 0
@.str.1 = [13 x i8] c"FNM_NOESCAPE\00"
@FNM_PERIOD = global i32 0
@.str.2 = [11 x i8] c"FNM_PERIOD\00"
define i8* @flag_output(i32 %0) {
%2 = load i32, i32* @FNM_PATHNAME
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i32, i32* @FNM_NOESCAPE
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %14
9: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(13) getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0), i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13, i1 false)
%10 = load i32, i32* @FNM_NOESCAPE
%11 = and i32 %10, %0
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
store i8 124, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 12)
br label %14
14: ; preds = %5, %13
%15 = phi i8* [ getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 13), %13 ], [ getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0), %5 ]
%16 = getelementptr i8, i8* %15, i64 12
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(13) %15, i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 13, i1 false)
br label %17
17: ; preds = %9, %14
%18 = phi i8* [ %16, %14 ], [ getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 12), %9 ]
%19 = load i32, i32* @FNM_PERIOD
%20 = and i32 %19, %0
%21 = icmp eq i32 %20, 0
br i1 %21, label %31, label %26
22: ; preds = %5
%23 = load i32, i32* @FNM_PERIOD
%24 = and i32 %23, %0
%25 = icmp eq i32 %24, 0
br i1 %25, label %34, label %28
26: ; preds = %17
%27 = getelementptr inbounds i8, i8* %18, i64 1
store i8 124, i8* %18
br label %28
28: ; preds = %22, %26
%29 = phi i8* [ %27, %26 ], [ getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0), %22 ]
%30 = getelementptr i8, i8* %29, i64 10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(11) %29, i8* align 1 dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 11, i1 false)
br label %31
31: ; preds = %28, %17
%32 = phi i8* [ %30, %28 ], [ %18, %17 ]
%33 = icmp eq i8* %32, getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0)
br i1 %33, label %34, label %35
34: ; preds = %22, %31
store i8 48, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0)
br label %35
35: ; preds = %34, %31
%36 = phi i8* [ getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 1), %34 ], [ %32, %31 ]
store i8 0, i8* %36
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @flag_output.buf, i64 0, i64 0)
}