#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*/ sprintf(char *, 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)
    sprintf(newstr, "%s/%s", in_cttype, in_ctsubtype);
  else
    sprintf(newstr, "%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   1040 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1186 <ct_aux_rebuild_contenttype+0x56>
movq   $0x0,-0x8(%rbp)
jmp    11cd <ct_aux_rebuild_contenttype+0x9d>
cmpl   $0x0,-0x2c(%rbp)
je     11af <ct_aux_rebuild_contenttype+0x7f>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11c5 <ct_aux_rebuild_contenttype+0x95>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@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   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    (%r12,%rax,1),%edi
add    $0x2,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a3 <ct_aux_rebuild_contenttype+0x63>
test   %r12d,%r12d
je     1198 <ct_aux_rebuild_contenttype+0x58>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
jmp    11a3 <ct_aux_rebuild_contenttype+0x63>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 %34
20: ; preds = %2
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %25, i8* %26)
br label %32
28: ; preds = %20
%29 = load i8*, i8** %7
%30 = load i8*, i8** %4
%31 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %23
%33 = load i8*, i8** %7
store i8* %33, i8** %3
br label %34
34: ; preds = %32, %19
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%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*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) 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 i8* @strcpy(i8* %7, i8* dereferenceable(1) %0)
br label %15
15: ; preds = %11, %13, %2
ret i8* %7
}