#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 dtree_dev_t {
  int dummy;
};

/* Variables and functions */
char **dtree_dev_compat(struct dtree_dev_t *);
int /*<<< orphan*/ printf(char *, char const *, char const *);
void print_compat(struct dtree_dev_t *dev) {
  const char **compat = dtree_dev_compat(dev);
  for (size_t i = 0; compat[i] != NULL; ++i) {
    const char *sep = ", ";
    if (compat[i + 1] == NULL)
      sep = "\n";
    printf("%s%s", compat[i], sep);
  }
}


x86 assembly (clang, -O0):
<print_compat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <dtree_dev_compat@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ab <print_compat+0x8b>
lea    0xea5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpq   $0x0,0x8(%rax,%rcx,8)
jne    117e <print_compat+0x5e>
lea    0xe89(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <print_compat+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_compat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
call   1030 <dtree_dev_compat@plt>
mov    (%rax),%rsi
test   %rsi,%rsi
je     117f <print_compat+0x5f>
mov    %rax,%rbx
add    $0x8,%rbx
lea    0xec0(%rip),%r15
lea    0xeb6(%rip),%r12
lea    0xeb4(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpq   $0x0,(%rbx)
mov    %r12,%rdx
cmove  %r15,%rdx
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
jne    1160 <print_compat+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.dtree_dev_t = type { i32 }
@.str = [3 x i8] c", \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"%s%s\00"
define void @print_compat(%struct.dtree_dev_t* %0) {
%2 = alloca %struct.dtree_dev_t*
%3 = alloca i8**
%4 = alloca i64
%5 = alloca i8*
store %struct.dtree_dev_t* %0, %struct.dtree_dev_t** %2
%6 = load %struct.dtree_dev_t*, %struct.dtree_dev_t** %2
%7 = call i8** @dtree_dev_compat(%struct.dtree_dev_t* %6)
store i8** %7, i8*** %3
store i64 0, i64* %4
br label %8
8: ; preds = %29, %1
%9 = load i8**, i8*** %3
%10 = load i64, i64* %4
%11 = getelementptr inbounds i8*, i8** %9, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %32
14: ; preds = %8
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %5
%15 = load i8**, i8*** %3
%16 = load i64, i64* %4
%17 = add i64 %16, 1
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %14
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %22
22: ; preds = %21, %14
%23 = load i8**, i8*** %3
%24 = load i64, i64* %4
%25 = getelementptr inbounds i8*, i8** %23, i64 %24
%26 = load i8*, i8** %25
%27 = load i8*, i8** %5
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* %27)
br label %29
29: ; preds = %22
%30 = load i64, i64* %4
%31 = add i64 %30, 1
store i64 %31, i64* %4
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.dtree_dev_t = type { i32 }
@.str = [3 x i8] c", \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"%s%s\00"
define void @print_compat(%struct.dtree_dev_t* %0) {
%2 = tail call i8** @dtree_dev_compat(%struct.dtree_dev_t* %0)
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %6
5: ; preds = %6, %1
ret void
6: ; preds = %1, %6
%7 = phi i8* [ %15, %6 ], [ %3, %1 ]
%8 = phi i64 [ %9, %6 ], [ 0, %1 ]
%9 = add i64 %8, 1
%10 = getelementptr inbounds i8*, i8** %2, i64 %9
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
%13 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* %13)
%15 = load i8*, i8** %10
%16 = icmp eq i8* %15, null
br i1 %16, label %5, label %6
}