#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__ malloc(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
char *si_name_cfg(char *cfg) {
  char buf[256];
  char *delim = ",\n";
  char *s, *ret;
  strncpy(buf, cfg, 256);
  strtok(buf, delim);
  strtok(NULL, delim);
  s = strtok(NULL, delim);
  if (s) {
    ret = (char *)malloc(strlen(s) + 1);
    strcpy(ret, s);
  } else {
    ret = NULL;
  }
  return ret;
}


x86 assembly (clang, -O0):
<si_name_cfg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rsi
call   1070 <strtok@plt>
mov    -0x118(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1070 <strtok@plt>
mov    -0x118(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1070 <strtok@plt>
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x120(%rbp)
je     1201 <si_name_cfg+0xb1>
mov    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
mov    -0x120(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    120c <si_name_cfg+0xbc>
movq   $0x0,-0x128(%rbp)
mov    -0x128(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<si_name_cfg>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
lea    0xe8c(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strtok@plt>
xor    %r14d,%r14d
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11bd <si_name_cfg+0x6d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c",\0A\00"
define i8* @si_name_cfg(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = call i32 @strncpy(i8* %7, i8* %8, i32 256)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i8* @strtok(i8* %10, i8* %11)
%13 = load i8*, i8** %4
%14 = call i8* @strtok(i8* null, i8* %13)
%15 = load i8*, i8** %4
%16 = call i8* @strtok(i8* null, i8* %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %28
19: ; preds = %1
%20 = load i8*, i8** %5
%21 = call i64 @strlen(i8* %20)
%22 = add nsw i64 %21, 1
%23 = call i64 @malloc(i64 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = load i8*, i8** %5
%27 = call i32 @strcpy(i8* %25, i8* %26)
br label %29
28: ; preds = %1
store i8* null, i8** %6
br label %29
29: ; preds = %28, %19
%30 = load i8*, i8** %6
ret i8* %30
}

LLVM IR (-O2):
@.str = [3 x i8] c",\0A\00"
define i8* @si_name_cfg(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @strncpy(i8* %3, i8* %0, i32 256)
%5 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = call i64 @strlen(i8* %7)
%11 = add nsw i64 %10, 1
%12 = call i64 @malloc(i64 %11)
%13 = inttoptr i64 %12 to i8*
%14 = call i32 @strcpy(i8* %13, i8* %7)
br label %15
15: ; preds = %1, %9
%16 = phi i8* [ %13, %9 ], [ null, %1 ]
ret i8* %16
}