#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 */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
char *strchr(char *, char);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
char *clean_mime_subtype(char *subtype) {
  char *ptr;
  assert(subtype && subtype[0]);
  if (!strncasecmp(subtype, "x-", 2))
    subtype += 2;
  ptr = strchr(subtype, ';');
  if (ptr)
    *ptr = 0x00;
  return subtype;
}


x86 assembly (clang, -O0):
<clean_mime_subtype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     115c <clean_mime_subtype+0x2c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xe8c(%rip),%rsi
mov    $0x2,%edx
call   1050 <strncasecmp@plt>
cmp    $0x0,%eax
jne    1193 <clean_mime_subtype+0x63>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b7 <clean_mime_subtype+0x87>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_mime_subtype>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     1144 <clean_mime_subtype+0x14>
xor    %edi,%edi
cmpb   $0x0,(%rbx)
setne  %dil
jmp    1146 <clean_mime_subtype+0x16>
xor    %edi,%edi
call   1040 <assert@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1050 <strncasecmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rbx,%rcx,2),%rbx
mov    %rbx,%rdi
mov    $0x3b,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     117f <clean_mime_subtype+0x4f>
movb   $0x0,(%rax)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"x-\00"
define i8* @clean_mime_subtype(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %6, %1
%13 = phi i1 [ false, %1 ], [ %11, %6 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %2
%17 = call i32 @strncasecmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8* %21, i8** %2
br label %22
22: ; preds = %19, %12
%23 = load i8*, i8** %2
%24 = call i8* @strchr(i8* %23, i8 signext 59)
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = load i8*, i8** %3
store i8 0, i8* %28
br label %29
29: ; preds = %27, %22
%30 = load i8*, i8** %2
ret i8* %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"x-\00"
define i8* @clean_mime_subtype(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp ne i8 %4, 0
%6 = zext i1 %5 to i32
br label %7
7: ; preds = %3, %1
%8 = phi i32 [ 0, %1 ], [ %6, %3 ]
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @strncasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i64 2, i64 0
%13 = getelementptr i8, i8* %0, i64 %12
%14 = tail call i8* @strchr(i8* dereferenceable(1) %13, i8 signext 59)
%15 = icmp eq i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %7
store i8 0, i8* %14
br label %17
17: ; preds = %16, %7
ret i8* %13
}