#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*/ currTime();
int efCreate(int);
int /*<<< orphan*/ fatal(char *);
scalar_t__ getpid();
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, long, int /*<<< orphan*/, int);
scalar_t__ strncmp(char *, char *, int);
void createEventFlag(char *state) {
  if (strncmp(state, "set", 4) && strncmp(state, "clear", 6))
    fatal("Invalid state requested. Accepted values: 'set' or 'clear'");
  int s = !strncmp(state, "set", 4) ? (0) : (1), id = efCreate(s);
  if (id == -1)
    pexit("efCreate");
  printf("[%ld][%s] %d\n", (long)getpid(), currTime(), id);
}


x86 assembly (clang, -O0):
<createEventFlag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11c6 <createEventFlag+0x56>
mov    -0x8(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11c6 <createEventFlag+0x56>
lea    0xe49(%rip),%rdi
call   1090 <fatal@plt>
mov    -0x8(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
setne  %dl
xor    $0xff,%dl
mov    $0x1,%eax
xor    %ecx,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <efCreate@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1216 <createEventFlag+0xa6>
lea    0xe34(%rip),%rdi
call   1080 <pexit@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <currTime@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
mov    -0x10(%rbp),%ecx
lea    0xe16(%rip),%rdi
call   1060 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createEventFlag>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe83(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b1 <createEventFlag+0x41>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b1 <createEventFlag+0x41>
lea    0xe5e(%rip),%rdi
call   1090 <fatal@plt>
lea    0xe48(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <efCreate@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    11e6 <createEventFlag+0x76>
lea    0xe64(%rip),%rdi
call   1080 <pexit@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <currTime@plt>
lea    0xe50(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"set\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [59 x i8] c"Invalid state requested. Accepted values: 'set' or 'clear'\00"
@.str.3 = [9 x i8] c"efCreate\00"
@.str.4 = [14 x i8] c"[%ld][%s] %d\0A\00"
define void @createEventFlag(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @fatal(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %8, %1
%15 = load i8*, i8** %2
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%17 = icmp ne i64 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 0, i32 1
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 @efCreate(i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %14
%26 = call i32 @pexit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %14
%28 = call i64 (...) @getpid()
%29 = call i32 (...) @currTime()
%30 = load i32, i32* %4
%31 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 %28, i32 %29, i32 %30)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"set\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [59 x i8] c"Invalid state requested. Accepted values: 'set' or 'clear'\00"
@.str.3 = [9 x i8] c"efCreate\00"
@.str.4 = [14 x i8] c"[%ld][%s] %d\0A\00"
define void @createEventFlag(i8* %0) {
%2 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%3 = icmp eq i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @fatal(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %4, %1
%10 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @efCreate(i32 %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @pexit(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
%18 = tail call i64 (...) @getpid()
%19 = tail call i32 (...) @currTime()
%20 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 %18, i32 %19, i32 %13)
ret void
}