#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 */
int /*<<< orphan*/ debug_putc(char const);
void debug_puts(const char *string) {
  if (string == 0)
    debug_puts("(null)");
  else
    for (int i = 0; string[i] != 0; ++i)
      debug_putc(string[i]);
}


x86 assembly (clang, -O0):
<debug_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1148 <debug_puts+0x28>
lea    0xec2(%rip),%rdi
call   1030 <debug_puts@plt>
jmp    1188 <debug_puts+0x68>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1183 <debug_puts+0x63>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <debug_putc@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <debug_puts+0x2f>
jmp    1188 <debug_puts+0x68>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_puts>:
push   %rbx
test   %rdi,%rdi
je     1145 <debug_puts+0x35>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1143 <debug_puts+0x33>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%edi
call   1030 <debug_putc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <debug_puts+0x20>
pop    %rbx
ret
mov    $0x28,%edi
call   1030 <debug_putc@plt>
mov    $0x6e,%edi
call   1030 <debug_putc@plt>
mov    $0x75,%edi
call   1030 <debug_putc@plt>
mov    $0x6c,%edi
call   1030 <debug_putc@plt>
mov    $0x6c,%edi
call   1030 <debug_putc@plt>
mov    $0x29,%edi
pop    %rbx
jmp    1030 <debug_putc@plt>

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

LLVM IR (-O2):
define void @debug_puts(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %10
3: ; preds = %1
%4 = tail call i32 @debug_putc(i8 signext 40)
%5 = tail call i32 @debug_putc(i8 signext 110)
%6 = tail call i32 @debug_putc(i8 signext 117)
%7 = tail call i32 @debug_putc(i8 signext 108)
%8 = tail call i32 @debug_putc(i8 signext 108)
%9 = tail call i32 @debug_putc(i8 signext 41)
br label %21
10: ; preds = %1
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %10, %13
%14 = phi i64 [ %17, %13 ], [ 0, %10 ]
%15 = phi i8 [ %19, %13 ], [ %11, %10 ]
%16 = tail call i32 @debug_putc(i8 signext %15)
%17 = add nuw i64 %14, 1
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %13
21: ; preds = %13, %3, %10
ret void
}