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

/* Variables and functions */
int ih_item_len(struct item_head *);
int /*<<< orphan*/ printk(char *, ...);
void direct_print_item(struct item_head *ih, char *item) {
  int j = 0;
  printk("\"");
  while (j < ih_item_len(ih))
    printk("%c", item[j++]);
  printk("\"\n");
}


x86 assembly (clang, -O0):
<direct_print_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ih_item_len@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    118a <direct_print_item+0x6a>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
jmp    1145 <direct_print_item+0x25>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printk@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<direct_print_item>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printk@plt>
mov    %r12,%rdi
call   1040 <ih_item_len@plt>
test   %eax,%eax
jle    1182 <direct_print_item+0x62>
lea    0xeb3(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%esi
add    $0x1,%rbx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printk@plt>
mov    %r12,%rdi
call   1040 <ih_item_len@plt>
cltq
cmp    %rax,%rbx
jl     1160 <direct_print_item+0x40>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <printk@plt>

LLVM IR (-O0):
%struct.item_head = type { i32 }
@.str = [2 x i8] c"\22\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"\22\0A\00"
define void @direct_print_item(%struct.item_head* %0, i8* %1) {
%3 = alloca %struct.item_head*
%4 = alloca i8*
%5 = alloca i32
store %struct.item_head* %0, %struct.item_head** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %12, %2
%8 = load i32, i32* %5
%9 = load %struct.item_head*, %struct.item_head** %3
%10 = call i32 @ih_item_len(%struct.item_head* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %21
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %7
21: ; preds = %7
%22 = call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.item_head = type { i32 }
@.str = [2 x i8] c"\22\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [3 x i8] c"\22\0A\00"
define void @direct_print_item(%struct.item_head* %0, i8* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @ih_item_len(%struct.item_head* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %2, %6
%7 = phi i64 [ %8, %6 ], [ 0, %2 ]
%8 = add nuw nsw i64 %7, 1
%9 = getelementptr inbounds i8, i8* %1, i64 %7
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = tail call i32 @ih_item_len(%struct.item_head* %0)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %8, %14
br i1 %15, label %6, label %16
16: ; preds = %6, %2
%17 = tail call i32 (i8*, ...) @printk(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}