#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__ SCNormalloc(scalar_t__, char *, int);
int /*<<< orphan*/ sc_strcpy(char *, char *);
scalar_t__ sc_strlen(char *);
char *sc_strnew(char *S) {
  char *T = 0;
  if (!S)
    return 0;
  T = (char *)SCNormalloc(sc_strlen(S) + 1,
                          "/scratch/repos/new/home/jordi_armengol_estape/"
                          "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                          "astrotycoon/semo/refs/heads/master/common/sccl.c",
                          253);
  if (!T)
    return 0;
  sc_strcpy(T, S);
  return T;
}


x86 assembly (clang, -O0):
<sc_strnew>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <sc_strnew+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    11ae <sc_strnew+0x7e>
mov    -0x10(%rbp),%rdi
call   1030 <sc_strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
lea    0xe8d(%rip),%rsi
mov    $0xfd,%edx
call   1040 <SCNormalloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1199 <sc_strnew+0x69>
movq   $0x0,-0x8(%rbp)
jmp    11ae <sc_strnew+0x7e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <sc_strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_strnew>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     116b <sc_strnew+0x3b>
mov    %rdi,%r14
call   1030 <sc_strlen@plt>
lea    0x1(%rax),%rdi
lea    0xeb4(%rip),%rsi
mov    $0xfd,%edx
call   1040 <SCNormalloc@plt>
test   %rax,%rax
je     116b <sc_strnew+0x3b>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <sc_strcpy@plt>
jmp    116d <sc_strnew+0x3d>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/astrotycoon/semo/refs/heads/master/common/sccl.c\00"
define i8* @sc_strnew(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%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 %22
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @sc_strlen(i8* %9)
%11 = add nsw i64 %10, 1
%12 = call i64 @SCNormalloc(i64 %11, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 253)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %8
store i8* null, i8** %2
br label %22
17: ; preds = %8
%18 = load i8*, i8** %4
%19 = load i8*, i8** %3
%20 = call i32 @sc_strcpy(i8* %18, i8* %19)
%21 = load i8*, i8** %4
store i8* %21, i8** %2
br label %22
22: ; preds = %17, %16, %7
%23 = load i8*, i8** %2
ret i8* %23
}

LLVM IR (-O2):
@.str = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/astrotycoon/semo/refs/heads/master/common/sccl.c\00"
define i8* @sc_strnew(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = tail call i64 @sc_strlen(i8* %0)
%5 = add nsw i64 %4, 1
%6 = tail call i64 @SCNormalloc(i64 %5, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str, i64 0, i64 0), i32 253)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i64 %6, 0
br i1 %8, label %11, label %9
9: ; preds = %3
%10 = tail call i32 @sc_strcpy(i8* %7, i8* %0)
br label %11
11: ; preds = %3, %1, %9
%12 = phi i8* [ %7, %9 ], [ null, %1 ], [ null, %3 ]
ret i8* %12
}