#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 */
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, scalar_t__);
int equal(char *option, char *user_arg) {
  if (option == NULL || user_arg == NULL) {
    return 0;
  }
  if (strlen(option) != strlen(user_arg)) {
    return 0;
  }
  return strncmp(option, user_arg, strlen(user_arg)) == 0;
}


x86 assembly (clang, -O0):
<equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1146 <equal+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1152 <equal+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11bc <equal+0x9c>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1184 <equal+0x64>
movl   $0x0,-0x4(%rbp)
jmp    11bc <equal+0x9c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<equal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rdi,%rdi
je     1167 <equal+0x47>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1167 <equal+0x47>
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %rax,%r15
jne    1167 <equal+0x47>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <strncmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @equal(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i32 0, i32* %3
br label %27
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* %13)
%15 = load i8*, i8** %5
%16 = call i64 @strlen(i8* %15)
%17 = icmp ne i64 %14, %16
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %3
br label %27
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = call i64 @strlen(i8* %22)
%24 = call i64 @strncmp(i8* %20, i8* %21, i64 %23)
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
store i32 %26, i32* %3
br label %27
27: ; preds = %19, %18, %11
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @equal(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = tail call i64 @strncmp(i8* %0, i8* %1, i64 %7)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %6, %2, %10
%15 = phi i32 [ %13, %10 ], [ 0, %2 ], [ 0, %6 ]
ret i32 %15
}