#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 efGet(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ getpid();
int parseId(char *);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, long, int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ stderr;
void getEventFlag(char *id) {
  int semId, state;
  semId = parseId(id);
  if (semId == -1) {
    fprintf(stderr, "Invalid event flag identifier: %s\n", id);
    return;
  }
  state = efGet(semId);
  if (state == -1)
    pexit("efGet");
  printf("[%ld][%s] %d: %s\n", (long)getpid(), currTime(), semId,
         state == (0) ? "set" : "clear");
}


x86 assembly (clang, -O0):
<getEventFlag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <parseId@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11b0 <getEventFlag+0x40>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1210 <getEventFlag+0xa0>
mov    -0xc(%rbp),%edi
call   1080 <efGet@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    11d1 <getEventFlag+0x61>
lea    0xe57(%rip),%rdi
call   1090 <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    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%edi
lea    0xe49(%rip),%r8
lea    0xe3e(%rip),%rax
cmp    $0x0,%edi
cmove  %rax,%r8
lea    0xe1e(%rip),%rdi
call   1060 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEventFlag>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
call   1030 <parseId@plt>
cmp    $0xffffffff,%eax
je     11d9 <getEventFlag+0x69>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <efGet@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    119d <getEventFlag+0x2d>
lea    0xe8b(%rip),%rdi
call   1090 <pexit@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <currTime@plt>
test   %ebp,%ebp
lea    0xe84(%rip),%rcx
lea    0xe81(%rip),%r8
cmove  %rcx,%r8
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    %ebx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
mov    %rbp,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Invalid event flag identifier: %s\0A\00"
@.str.1 = [6 x i8] c"efGet\00"
@.str.2 = [18 x i8] c"[%ld][%s] %d: %s\0A\00"
@.str.3 = [4 x i8] c"set\00"
@.str.4 = [6 x i8] c"clear\00"
define void @getEventFlag(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @parseId(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %2
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %29
13: ; preds = %1
%14 = load i32, i32* %3
%15 = call i32 @efGet(i32 %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
%21 = call i64 (...) @getpid()
%22 = call i32 (...) @currTime()
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 %21, i32 %22, i32 %23, i8* %27)
br label %29
29: ; preds = %20, %9
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Invalid event flag identifier: %s\0A\00"
@.str.1 = [6 x i8] c"efGet\00"
@.str.2 = [18 x i8] c"[%ld][%s] %d: %s\0A\00"
@.str.3 = [4 x i8] c"set\00"
@.str.4 = [6 x i8] c"clear\00"
define void @getEventFlag(i8* %0) {
%2 = tail call i32 @parseId(i8* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %18
7: ; preds = %1
%8 = tail call i32 @efGet(i32 %2)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @pexit(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = tail call i64 (...) @getpid()
%14 = tail call i32 (...) @currTime()
%15 = icmp eq i32 %8, 0
%16 = select i1 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 %13, i32 %14, i32 %2, i8* %16)
br label %18
18: ; preds = %12, %4
ret void
}