#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 */
struct slist_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ enough_mem(char *);
struct slist_t *slist_init(char *);
int /*<<< orphan*/ slist_push(struct slist_t *, char *);
char *strdup(char *);
struct slist_t *slist_conv_dpointer(char **dpointer) {
  int i = 0;
  struct slist_t *sl;
  char *s;
  if (dpointer[0]) {
    s = strdup(dpointer[0]);
    enough_mem(s);
    sl = slist_init(s);
  } else {
    return (struct slist_t *)0;
  }
  i = 1;
  while (dpointer[i]) {
    s = strdup(dpointer[i]);
    enough_mem(s);
    slist_push(sl, s);
    i++;
  }
  return sl;
}


x86 assembly (clang, -O0):
<slist_conv_dpointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     118c <slist_conv_dpointer+0x4c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <enough_mem@plt>
mov    -0x28(%rbp),%rdi
call   1040 <slist_init@plt>
mov    %rax,-0x20(%rbp)
jmp    1199 <slist_conv_dpointer+0x59>
movq   $0x0,-0x8(%rbp)
jmp    11f4 <slist_conv_dpointer+0xb4>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ec <slist_conv_dpointer+0xac>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <enough_mem@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <slist_push@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <slist_conv_dpointer+0x60>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slist_conv_dpointer>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     11a9 <slist_conv_dpointer+0x69>
call   1050 <strdup@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <enough_mem@plt>
mov    %r14,%rdi
call   1040 <slist_init@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     11ac <slist_conv_dpointer+0x6c>
add    $0x10,%rbx
nopl   0x0(%rax,%rax,1)
call   1050 <strdup@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1030 <enough_mem@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <slist_push@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1180 <slist_conv_dpointer+0x40>
jmp    11ac <slist_conv_dpointer+0x6c>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.slist_t = type { i32 }
define %struct.slist_t* @slist_conv_dpointer(i8** %0) {
%2 = alloca %struct.slist_t*
%3 = alloca i8**
%4 = alloca i32
%5 = alloca %struct.slist_t*
%6 = alloca i8*
store i8** %0, i8*** %3
store i32 0, i32* %4
%7 = load i8**, i8*** %3
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %20
11: ; preds = %1
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i8* @strdup(i8* %14)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = call i32 @enough_mem(i8* %16)
%18 = load i8*, i8** %6
%19 = call %struct.slist_t* @slist_init(i8* %18)
store %struct.slist_t* %19, %struct.slist_t** %5
br label %21
20: ; preds = %1
store %struct.slist_t* null, %struct.slist_t** %2
br label %45
21: ; preds = %11
store i32 1, i32* %4
br label %22
22: ; preds = %29, %21
%23 = load i8**, i8*** %3
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %43
29: ; preds = %22
%30 = load i8**, i8*** %3
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = call i8* @strdup(i8* %34)
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = call i32 @enough_mem(i8* %36)
%38 = load %struct.slist_t*, %struct.slist_t** %5
%39 = load i8*, i8** %6
%40 = call i32 @slist_push(%struct.slist_t* %38, i8* %39)
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %22
43: ; preds = %22
%44 = load %struct.slist_t*, %struct.slist_t** %5
store %struct.slist_t* %44, %struct.slist_t** %2
br label %45
45: ; preds = %43, %20
%46 = load %struct.slist_t*, %struct.slist_t** %2
ret %struct.slist_t* %46
}

LLVM IR (-O2):
%struct.slist_t = type { i32 }
define %struct.slist_t* @slist_conv_dpointer(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %21, label %4
4: ; preds = %1
%5 = tail call i8* @strdup(i8* %2)
%6 = tail call i32 @enough_mem(i8* %5)
%7 = tail call %struct.slist_t* @slist_init(i8* %5)
%8 = getelementptr inbounds i8*, i8** %0, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %4, %11
%12 = phi i64 [ %17, %11 ], [ 1, %4 ]
%13 = phi i8* [ %19, %11 ], [ %9, %4 ]
%14 = tail call i8* @strdup(i8* %13)
%15 = tail call i32 @enough_mem(i8* %14)
%16 = tail call i32 @slist_push(%struct.slist_t* %7, i8* %14)
%17 = add nuw i64 %12, 1
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %11
21: ; preds = %11, %4, %1
%22 = phi %struct.slist_t* [ null, %1 ], [ %7, %4 ], [ %7, %11 ]
ret %struct.slist_t* %22
}