#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 */
struct event_config {
  int dummy;
};
struct event_base {
  int dummy;
};
typedef enum event_method_feature {
  ____Placeholder_event_method_feature
} event_method_feature;

/* Variables and functions */
int EV_FEATURE_ET;
int EV_FEATURE_FDS;
int EV_FEATURE_O1;
int event_base_get_features(struct event_base *);
char *event_base_get_method(struct event_base *);
struct event_base *event_base_new_with_config(struct event_config *);
struct event_config *event_config_new();
char **event_get_supported_methods();
char *event_get_version();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(int argc, const char *argv[]) {
  int i;
  const char **methods = event_get_supported_methods();
  printf("Starting Libevent %s.  Available methods are:\n",
         event_get_version());
  for (i = 0; methods[i] != NULL; ++i) {
    printf("    %s\n", methods[i]);
  }
  struct event_base *base;
  struct event_config *cfg;
  enum event_method_feature f;
  cfg = event_config_new();
  base = event_base_new_with_config(cfg);
  if (!base) {
    puts("Couldn't get an event_base!");
  } else {
    printf("Using Libevent with backend method %s.",
           event_base_get_method(base));
    f = event_base_get_features(base);
    if ((f & EV_FEATURE_ET))
      printf("  Edge-triggered events are supported.");
    if ((f & EV_FEATURE_O1))
      printf("  O(1) event notification is supported.");
    if ((f & EV_FEATURE_FDS))
      printf("  All FD types are supported.");
    puts("");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <event_get_supported_methods@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10a0 <event_get_version@plt>
mov    %rax,%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11fb <main+0x7b>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c0 <main+0x40>
mov    $0x0,%al
call   1030 <event_config_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <event_base_new_with_config@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    122f <main+0xaf>
lea    0xe12(%rip),%rdi
call   1050 <puts@plt>
jmp    12ca <main+0x14a>
mov    -0x28(%rbp),%rdi
call   1080 <event_base_get_method@plt>
mov    %rax,%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <event_base_get_features@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2d79(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1278 <main+0xf8>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%eax
mov    0x2d46(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     129b <main+0x11b>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%eax
mov    0x2d43(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12be <main+0x13e>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd69(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   10a0 <event_get_supported_methods@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10b0 <event_get_version@plt>
lea    0xe54(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%rsi
test   %rsi,%rsi
je     11e6 <main+0x56>
add    $0x8,%rbx
lea    0xe66(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    11d0 <main+0x40>
xor    %eax,%eax
call   1030 <event_config_new@plt>
mov    %rax,%rdi
call   1080 <event_base_new_with_config@plt>
test   %rax,%rax
je     1277 <main+0xe7>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <event_base_get_method@plt>
lea    0xe47(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1050 <event_base_get_features@plt>
mov    %eax,%ebx
mov    0x2db1(%rip),%rax
test   %ebx,(%rax)
je     1239 <main+0xa9>
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d88(%rip),%rax
test   %ebx,(%rax)
je     1252 <main+0xc2>
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d8f(%rip),%rax
test   %ebx,(%rax)
je     126b <main+0xdb>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1283 <main+0xf3>
lea    0xdb9(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.event_base = type { i32 }
%struct.event_config = type { i32 }
@.str = [47 x i8] c"Starting Libevent %s. Available methods are:\0A\00"
@.str.1 = [8 x i8] c" %s\0A\00"
@.str.2 = [28 x i8] c"Couldn't get an event_base!\00"
@.str.3 = [39 x i8] c"Using Libevent with backend method %s.\00"
@EV_FEATURE_ET = global i32 0
@.str.4 = [39 x i8] c" Edge-triggered events are supported.\00"
@EV_FEATURE_O1 = global i32 0
@.str.5 = [40 x i8] c" O(1) event notification is supported.\00"
@EV_FEATURE_FDS = global i32 0
@.str.6 = [30 x i8] c" All FD types are supported.\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8**
%8 = alloca %struct.event_base*
%9 = alloca %struct.event_config*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i8** (...) @event_get_supported_methods()
store i8** %11, i8*** %7
%12 = call i8* (...) @event_get_version()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %6
br label %14
14: ; preds = %28, %2
%15 = load i8**, i8*** %7
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %31
21: ; preds = %14
%22 = load i8**, i8*** %7
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %14
31: ; preds = %14
%32 = call %struct.event_config* (...) @event_config_new()
store %struct.event_config* %32, %struct.event_config** %9
%33 = load %struct.event_config*, %struct.event_config** %9
%34 = call %struct.event_base* @event_base_new_with_config(%struct.event_config* %33)
store %struct.event_base* %34, %struct.event_base** %8
%35 = load %struct.event_base*, %struct.event_base** %8
%36 = icmp ne %struct.event_base* %35, null
br i1 %36, label %39, label %37
37: ; preds = %31
%38 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %67
39: ; preds = %31
%40 = load %struct.event_base*, %struct.event_base** %8
%41 = call i8* @event_base_get_method(%struct.event_base* %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = load %struct.event_base*, %struct.event_base** %8
%44 = call i32 @event_base_get_features(%struct.event_base* %43)
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = load i32, i32* @EV_FEATURE_ET
%47 = and i32 %45, %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %39
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %49, %39
%52 = load i32, i32* %10
%53 = load i32, i32* @EV_FEATURE_O1
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %58
58: ; preds = %56, %51
%59 = load i32, i32* %10
%60 = load i32, i32* @EV_FEATURE_FDS
%61 = and i32 %59, %60
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %65
65: ; preds = %63, %58
%66 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %67
67: ; preds = %65, %37
ret i32 0
}

LLVM IR (-O2):
%struct.event_config = type { i32 }
%struct.event_base = type { i32 }
@.str = [47 x i8] c"Starting Libevent %s. Available methods are:\0A\00"
@.str.1 = [8 x i8] c" %s\0A\00"
@.str.2 = [28 x i8] c"Couldn't get an event_base!\00"
@.str.3 = [39 x i8] c"Using Libevent with backend method %s.\00"
@EV_FEATURE_ET = global i32 0
@.str.4 = [39 x i8] c" Edge-triggered events are supported.\00"
@EV_FEATURE_O1 = global i32 0
@.str.5 = [40 x i8] c" O(1) event notification is supported.\00"
@EV_FEATURE_FDS = global i32 0
@.str.6 = [30 x i8] c" All FD types are supported.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i8** (...) @event_get_supported_methods()
%4 = tail call i8* (...) @event_get_version()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %12, %8 ], [ 0, %2 ]
%10 = phi i8* [ %14, %8 ], [ %6, %2 ]
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = add nuw i64 %9, 1
%13 = getelementptr inbounds i8*, i8** %3, i64 %12
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %8, %2
%17 = tail call %struct.event_config* (...) @event_config_new()
%18 = tail call %struct.event_base* @event_base_new_with_config(%struct.event_config* %17)
%19 = icmp eq %struct.event_base* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %45
22: ; preds = %16
%23 = tail call i8* @event_base_get_method(%struct.event_base* %18)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = tail call i32 @event_base_get_features(%struct.event_base* %18)
%26 = load i32, i32* @EV_FEATURE_ET
%27 = and i32 %26, %25
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %22
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %22
%32 = load i32, i32* @EV_FEATURE_O1
%33 = and i32 %32, %25
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = load i32, i32* @EV_FEATURE_FDS
%39 = and i32 %38, %25
%40 = icmp eq i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = tail call i32 @putchar(i32 10)
br label %45
45: ; preds = %43, %20
ret i32 0
}