#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 */
char *strchr(char const *, char);
scalar_t__ strncmp(char const *, char const *, int);
int /*<<< orphan*/ xdg_mime_init();
int xdg_mime_media_type_equal(const char *mime_a, const char *mime_b) {
  char *sep;
  xdg_mime_init();
  sep = strchr(mime_a, '/');
  if (sep && strncmp(mime_a, mime_b, sep - mime_a + 1) == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<xdg_mime_media_type_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1040 <xdg_mime_init@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1198 <xdg_mime_media_type_equal+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1198 <xdg_mime_media_type_equal+0x68>
movl   $0x1,-0x4(%rbp)
jmp    119f <xdg_mime_media_type_equal+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xdg_mime_media_type_equal>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <xdg_mime_init@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1171 <xdg_mime_media_type_equal+0x41>
sub    %ebx,%eax
add    $0x1,%eax
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1171 <xdg_mime_media_type_equal+0x41>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @xdg_mime_media_type_equal(i8* %0, i8* %1) {
%3 = tail call i32 (...) @xdg_mime_init()
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = ptrtoint i8* %4 to i64
%8 = ptrtoint i8* %0 to i64
%9 = sub i64 %7, %8
%10 = trunc i64 %9 to i32
%11 = add i32 %10, 1
%12 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %6, %2
br label %15
15: ; preds = %6, %14
%16 = phi i32 [ 0, %14 ], [ 1, %6 ]
ret i32 %16
}