#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 *_talloc_memdup(void const *, char const *, scalar_t__, char *);
scalar_t__ strlen(char const *);
int /*<<< orphan*/ talloc_set_name_const(char *, char *);
char *talloc_strdup(const void *t, const char *p) {
  char *ret;
  if (!p) {
    return NULL;
  }
  ret = _talloc_memdup(
      t, p, strlen(p) + 1,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/ZHAW-INES/rioxo-uClinux-dist/refs/heads/"
      "master/openswan/testing/kunit/libkern/talloc.c"
      ":"
      "843");
  if (ret) {
    talloc_set_name_const(ret, ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<talloc_strdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1158 <talloc_strdup+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11b0 <talloc_strdup+0x80>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
lea    0xe79(%rip),%rcx
call   1040 <_talloc_memdup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a8 <talloc_strdup+0x78>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <talloc_set_name_const@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<talloc_strdup>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1172 <talloc_strdup+0x42>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
lea    0xeae(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <_talloc_memdup@plt>
test   %rax,%rax
je     1172 <talloc_strdup+0x42>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rax,%rsi
call   1050 <talloc_set_name_const@plt>
jmp    1174 <talloc_strdup+0x44>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ZHAW-INES/rioxo-uClinux-dist/refs/heads/master/openswan/testing/kunit/libkern/talloc.c:843\00"
define i8* @talloc_strdup(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i8* null, i8** %3
br label %25
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = load i8*, i8** %5
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %14, 1
%16 = call i8* @_talloc_memdup(i8* %11, i8* %12, i64 %15, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %10
%20 = load i8*, i8** %6
%21 = load i8*, i8** %6
%22 = call i32 @talloc_set_name_const(i8* %20, i8* %21)
br label %23
23: ; preds = %19, %10
%24 = load i8*, i8** %6
store i8* %24, i8** %3
br label %25
25: ; preds = %23, %9
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [181 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ZHAW-INES/rioxo-uClinux-dist/refs/heads/master/openswan/testing/kunit/libkern/talloc.c:843\00"
define i8* @talloc_strdup(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = tail call i64 @strlen(i8* %1)
%6 = add nsw i64 %5, 1
%7 = tail call i8* @_talloc_memdup(i8* %0, i8* %1, i64 %6, i8* getelementptr inbounds ([181 x i8], [181 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @talloc_set_name_const(i8* %7, i8* %7)
br label %11
11: ; preds = %4, %9, %2
%12 = phi i8* [ null, %2 ], [ %7, %9 ], [ null, %4 ]
ret i8* %12
}