#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_list {
  int dummy;
};

/* Variables and functions */
scalar_t__ strcmp(char const *, char const *);
int strlen(char const *);
void test_event(struct event_list *event, const char *path, const char *name,
                struct event_list **save, int len) {
  path += len - strlen(name);
  if (strcmp(path, name) != 0)
    return;
  *save = event;
}


x86 assembly (clang, -O0):
<test_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%ecx
sub    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     117a <test_event+0x5a>
jmp    1185 <test_event+0x65>
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_event>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <strlen@plt>
sub    %eax,%ebp
movslq %ebp,%rdi
add    %r12,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1157 <test_event+0x37>
mov    %r15,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.event_list = type { i32 }
define void @test_event(%struct.event_list* %0, i8* %1, i8* %2, %struct.event_list** %3, i32 %4) {
%6 = alloca %struct.event_list*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.event_list**
%10 = alloca i32
store %struct.event_list* %0, %struct.event_list** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store %struct.event_list** %3, %struct.event_list*** %9
store i32 %4, i32* %10
%11 = load i32, i32* %10
%12 = load i8*, i8** %8
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %11, %13
%15 = load i8*, i8** %7
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = load i8*, i8** %8
%20 = call i64 @strcmp(i8* %18, i8* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %5
br label %26
23: ; preds = %5
%24 = load %struct.event_list*, %struct.event_list** %6
%25 = load %struct.event_list**, %struct.event_list*** %9
store %struct.event_list* %24, %struct.event_list** %25
br label %26
26: ; preds = %23, %22
ret void
}

LLVM IR (-O2):
%struct.event_list = type { i32 }
define void @test_event(%struct.event_list* %0, i8* %1, i8* %2, %struct.event_list** nocapture writeonly %3, i32 %4) {
%6 = tail call i32 @strlen(i8* %2)
%7 = sub nsw i32 %4, %6
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = tail call i64 @strcmp(i8* %9, i8* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %5
store %struct.event_list* %0, %struct.event_list** %3
br label %13
13: ; preds = %5, %12
ret void
}