#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 *calloc(int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
int strlen(char const *);
char *ct_aux_rebuild_contenttype(const char *in_cttype,
                                 const char *in_ctsubtype) {
  int buflen;
  char *newstr;
  int in_ctsubtype_len;
  in_ctsubtype_len = strlen(in_ctsubtype);
  buflen = strlen(in_cttype) + in_ctsubtype_len + 2;
  if ((newstr = calloc(buflen, sizeof(char))) == NULL)
    return (NULL);
  if (in_ctsubtype_len != 0)
    snprintf(newstr, buflen, "%s/%s", in_cttype, in_ctsubtype);
  else
    snprintf(newstr, buflen, "%s", in_cttype);
  return (newstr);
}


x86 assembly (clang, -O0):
<ct_aux_rebuild_contenttype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1186 <ct_aux_rebuild_contenttype+0x56>
movq   $0x0,-0x8(%rbp)
jmp    11d3 <ct_aux_rebuild_contenttype+0xa3>
cmpl   $0x0,-0x2c(%rbp)
je     11b2 <ct_aux_rebuild_contenttype+0x82>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xe5a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    11cb <ct_aux_rebuild_contenttype+0x9b>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rcx
lea    0xe3f(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ct_aux_rebuild_contenttype>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    (%rax,%rbp,1),%r12d
add    $0x2,%r12d
mov    %r12d,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a4 <ct_aux_rebuild_contenttype+0x74>
test   %ebp,%ebp
je     118d <ct_aux_rebuild_contenttype+0x5d>
lea    0xe88(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    11a4 <ct_aux_rebuild_contenttype+0x74>
lea    0xe6f(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @ct_aux_rebuild_contenttype(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %8
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = load i32, i32* %8
%14 = add nsw i32 %12, %13
%15 = add nsw i32 %14, 2
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = call i8* @calloc(i32 %16, i32 1)
store i8* %17, i8** %7
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %2
store i8* null, i8** %3
br label %36
20: ; preds = %2
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = load i32, i32* %6
%26 = load i8*, i8** %4
%27 = load i8*, i8** %5
%28 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %24, i32 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
br label %34
29: ; preds = %20
%30 = load i8*, i8** %7
%31 = load i32, i32* %6
%32 = load i8*, i8** %4
%33 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %30, i32 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %29, %23
%35 = load i8*, i8** %7
store i8* %35, i8** %3
br label %36
36: ; preds = %34, %19
%37 = load i8*, i8** %3
ret i8* %37
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [3 x i8] c"%s\00"
define i8* @ct_aux_rebuild_contenttype(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strlen(i8* %0)
%5 = add i32 %3, 2
%6 = add i32 %5, %4
%7 = tail call i8* @calloc(i32 %6, i32 1)
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = icmp eq i32 %3, 0
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %15
13: ; preds = %9
%14 = tail call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %11, %13, %2
ret i8* %7
}