#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 *Mem_alloc(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strlen(char const *);
char *Buf_create(const char *x) {
  if (!x)
    return NULL;
  char *buf = Mem_alloc(
      (strlen(x)),
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/QubeX2/mangolib/refs/heads/master/src/buf.c",
      93);
  strcpy(buf, x);
  return buf;
}


x86 assembly (clang, -O0):
<Buf_create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <Buf_create+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1189 <Buf_create+0x59>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
lea    0xe9a(%rip),%rsi
mov    $0x5d,%edx
call   1050 <Mem_alloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%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):
<Buf_create>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1164 <Buf_create+0x34>
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0xeb8(%rip),%rsi
mov    %eax,%edi
mov    $0x5d,%edx
call   1050 <Mem_alloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    1167 <Buf_create+0x37>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/QubeX2/mangolib/refs/heads/master/src/buf.c\00"
define i8* @Buf_create(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* null, i8** %2
br label %16
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = call i8* @Mem_alloc(i32 %10, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32 93)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i8*, i8** %4
store i8* %15, i8** %2
br label %16
16: ; preds = %8, %7
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@.str = [134 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/QubeX2/mangolib/refs/heads/master/src/buf.c\00"
define i8* @Buf_create(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %7, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i8* @Mem_alloc(i32 %4, i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str, i64 0, i64 0), i32 93)
%6 = tail call i32 @strcpy(i8* %5, i8* %0)
br label %7
7: ; preds = %1, %3
%8 = phi i8* [ %5, %3 ], [ null, %1 ]
ret i8* %8
}