#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 dirent {
  int /*<<< orphan*/ d_name;
};

/* Variables and functions */
int EINVAL;
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int expect_a_b(const struct dirent *de, void *data __attribute__((unused))) {
  if (!strcmp(de->d_name, "a"))
    return 0;
  if (!strcmp(de->d_name, "b"))
    return 0;
  return -EINVAL;
}


x86 assembly (clang, -O0):
<expect_a_b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1147 <expect_a_b+0x37>
movl   $0x0,-0x4(%rbp)
jmp    117c <expect_a_b+0x6c>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    0xeae(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116e <expect_a_b+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    117c <expect_a_b+0x6c>
xor    %eax,%eax
mov    0x2e69(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expect_a_b>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%edi
lea    0xee1(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1147 <expect_a_b+0x37>
mov    (%rbx),%edi
lea    0xecf(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1147 <expect_a_b+0x37>
mov    0x2e9d(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32 }
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@EINVAL = global i32 0
define i32 @expect_a_b(%struct.dirent* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.dirent*
%5 = alloca i8*
store %struct.dirent* %0, %struct.dirent** %4
store i8* %1, i8** %5
%6 = load %struct.dirent*, %struct.dirent** %4
%7 = getelementptr inbounds %struct.dirent, %struct.dirent* %6, i32 0, i32 0
%8 = load i32, i32* %7
%9 = call i32 @strcmp(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 0, i32* %3
br label %22
12: ; preds = %2
%13 = load %struct.dirent*, %struct.dirent** %4
%14 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @strcmp(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %12
store i32 0, i32* %3
br label %22
19: ; preds = %12
%20 = load i32, i32* @EINVAL
%21 = sub nsw i32 0, %20
store i32 %21, i32* %3
br label %22
22: ; preds = %19, %18, %11
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
@.str = [2 x i8] c"a\00"
@.str.1 = [2 x i8] c"b\00"
@EINVAL = global i32 0
define i32 @expect_a_b(%struct.dirent* nocapture %0, i8* nocapture readnone %1) {
%3 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = tail call i32 @strcmp(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = load i32, i32* %3
%9 = tail call i32 @strcmp(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i32, i32* @EINVAL
%13 = sub nsw i32 0, %12
br label %14
14: ; preds = %7, %2, %11
%15 = phi i32 [ %13, %11 ], [ 0, %2 ], [ 0, %7 ]
ret i32 %15
}