#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(scalar_t__, int);
char *strcat(char *, char *);
scalar_t__ strlen(char *);
char *open_4th(char *Source) {
  char *p;
  if ((p = (char *)calloc(strlen(Source) + 7 + 2, sizeof(char))) == NULL)
    return (NULL);
  else
    return (strcat(strcat(strcat(p, "[NEEDS "), Source), "]"));
}


x86 assembly (clang, -O0):
<open_4th>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x7,%rdi
add    $0x2,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1175 <open_4th+0x45>
movq   $0x0,-0x8(%rbp)
jmp    11a4 <open_4th+0x74>
mov    -0x18(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcat@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    %rax,%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcat@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_4th>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
lea    0x9(%rax),%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1183 <open_4th+0x53>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <strlen@plt>
movabs $0x20534445454e5b,%rcx
mov    %rcx,(%rbx,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0x5d,(%rbx,%rax,1)
jmp    1185 <open_4th+0x55>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"[NEEDS \00"
@.str.1 = [2 x i8] c"]\00"
define i8* @open_4th(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
%7 = add nsw i64 %6, 7
%8 = add nsw i64 %7, 2
%9 = call i64 @calloc(i64 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i8* null, i8** %2
br label %19
13: ; preds = %1
%14 = load i8*, i8** %4
%15 = call i8* @strcat(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %3
%17 = call i8* @strcat(i8* %15, i8* %16)
%18 = call i8* @strcat(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %2
br label %19
19: ; preds = %13, %12
%20 = load i8*, i8** %2
ret i8* %20
}

LLVM IR (-O2):
define i8* @open_4th(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 9
%4 = tail call i64 @calloc(i64 %3, i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = inttoptr i64 %4 to i8*
%8 = tail call i64 @strlen(i8* %7)
%9 = getelementptr i8, i8* %7, i64 %8
%10 = bitcast i8* %9 to i64*
store i64 9098751939792475, i64* %10
%11 = tail call i8* @strcat(i8* %7, i8* dereferenceable(1) %0)
%12 = tail call i64 @strlen(i8* %7)
%13 = getelementptr i8, i8* %7, i64 %12
%14 = bitcast i8* %13 to i16*
store i16 93, i16* %14
br label %15
15: ; preds = %1, %6
%16 = phi i8* [ %7, %6 ], [ null, %1 ]
ret i8* %16
}