#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__ calloc(int, int);
char *strchr(char const *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *ct_extract_ctsubtype(const char *ct_contenttype) {
  char *local_subtype;
  char *subtype_slash;
  if ((subtype_slash = strchr(ct_contenttype, '/')) == NULL) {
    if ((local_subtype = (char *)calloc(1, sizeof(char))) == NULL)
      return (NULL);
    *local_subtype = '\0';
  } else {
    if ((local_subtype = (char *)calloc((strlen(subtype_slash + 1) + 1),
                                        sizeof(char))) == NULL)
      return (NULL);
    strcpy(local_subtype, subtype_slash + 1);
  }
  return (local_subtype);
}


x86 assembly (clang, -O0):
<ct_extract_ctsubtype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119b <ct_extract_ctsubtype+0x5b>
mov    $0x1,%esi
mov    %esi,%edi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    118f <ct_extract_ctsubtype+0x4f>
movq   $0x0,-0x8(%rbp)
jmp    11eb <ct_extract_ctsubtype+0xab>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11e3 <ct_extract_ctsubtype+0xa3>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d2 <ct_extract_ctsubtype+0x92>
movq   $0x0,-0x8(%rbp)
jmp    11eb <ct_extract_ctsubtype+0xab>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ct_extract_ctsubtype>:
push   %r14
push   %rbx
push   %rax
mov    $0x2f,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1184 <ct_extract_ctsubtype+0x44>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     11a0 <ct_extract_ctsubtype+0x60>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    11a3 <ct_extract_ctsubtype+0x63>
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     11a0 <ct_extract_ctsubtype+0x60>
mov    %rax,%r14
movb   $0x0,(%rax)
jmp    11a3 <ct_extract_ctsubtype+0x63>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @ct_extract_ctsubtype(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strchr(i8* %6, i8 signext 47)
store i8* %7, i8** %5
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = call i64 @calloc(i32 1, i32 1)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %9
store i8* null, i8** %2
br label %32
14: ; preds = %9
%15 = load i8*, i8** %4
store i8 0, i8* %15
br label %30
16: ; preds = %1
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = call i64 @calloc(i32 %20, i32 1)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %4
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %16
store i8* null, i8** %2
br label %32
25: ; preds = %16
%26 = load i8*, i8** %4
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i32 @strcpy(i8* %26, i8* %28)
br label %30
30: ; preds = %25, %14
%31 = load i8*, i8** %4
store i8* %31, i8** %2
br label %32
32: ; preds = %30, %24, %13
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
define i8* @ct_extract_ctsubtype(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i64 @calloc(i32 1, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %18, label %8
8: ; preds = %4
store i8 0, i8* %6
br label %18
9: ; preds = %1
%10 = getelementptr inbounds i8, i8* %2, i64 1
%11 = tail call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 1
%13 = tail call i64 @calloc(i32 %12, i32 1)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = tail call i32 @strcpy(i8* %14, i8* %10)
br label %18
18: ; preds = %8, %16, %9, %4
%19 = phi i8* [ null, %4 ], [ null, %9 ], [ %6, %8 ], [ %14, %16 ]
ret i8* %19
}