#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*/ printf(char *, ...);
void print_buf(char *buf) {
  int i;
  char c;
  for (i = 0; i < 9; i++) {
    c = buf[i];
    if (c == '\0') {
      printf("\\0");
    } else {
      printf("%c", buf[i]);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    1188 <print_buf+0x78>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x0,%eax
jne    115b <print_buf+0x4b>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1175 <print_buf+0x65>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117a <print_buf+0x6a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_buf+0x13>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_buf>:
push   %rbx
mov    %rdi,%rbx
movsbl (%rdi),%edi
test   %edi,%edi
je     1132 <print_buf+0x12>
call   1030 <putchar@plt>
jmp    1140 <print_buf+0x20>
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x1(%rbx),%edi
test   %edi,%edi
je     114f <print_buf+0x2f>
call   1030 <putchar@plt>
jmp    115d <print_buf+0x3d>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x2(%rbx),%edi
test   %edi,%edi
je     116c <print_buf+0x4c>
call   1030 <putchar@plt>
jmp    117a <print_buf+0x5a>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x3(%rbx),%edi
test   %edi,%edi
je     1189 <print_buf+0x69>
call   1030 <putchar@plt>
jmp    1197 <print_buf+0x77>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x4(%rbx),%edi
test   %edi,%edi
je     11a6 <print_buf+0x86>
call   1030 <putchar@plt>
jmp    11b4 <print_buf+0x94>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x5(%rbx),%edi
test   %edi,%edi
je     11c3 <print_buf+0xa3>
call   1030 <putchar@plt>
jmp    11d1 <print_buf+0xb1>
lea    0xe36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x6(%rbx),%edi
test   %edi,%edi
je     11e0 <print_buf+0xc0>
call   1030 <putchar@plt>
jmp    11ee <print_buf+0xce>
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x7(%rbx),%edi
test   %edi,%edi
je     11fd <print_buf+0xdd>
call   1030 <putchar@plt>
jmp    120b <print_buf+0xeb>
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x8(%rbx),%edi
test   %edi,%edi
je     121a <print_buf+0xfa>
call   1030 <putchar@plt>
jmp    1228 <print_buf+0x108>
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\0\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_buf(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
br label %5
5: ; preds = %28, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 9
br i1 %7, label %8, label %31
8: ; preds = %5
%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
store i8 %13, i8* %4
%14 = load i8, i8* %4
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
19: ; preds = %8
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %19, %17
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %5
31: ; preds = %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\0\00"
define void @print_buf(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %9
6: ; preds = %1
%7 = sext i8 %2 to i32
%8 = tail call i32 @putchar(i32 %7)
br label %9
9: ; preds = %4, %6
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = sext i8 %11 to i32
%15 = tail call i32 @putchar(i32 %14)
br label %18
16: ; preds = %9
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13
%19 = getelementptr inbounds i8, i8* %0, i64 2
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = sext i8 %20 to i32
%24 = tail call i32 @putchar(i32 %23)
br label %27
25: ; preds = %18
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = getelementptr inbounds i8, i8* %0, i64 3
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = sext i8 %29 to i32
%33 = tail call i32 @putchar(i32 %32)
br label %36
34: ; preds = %27
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
%37 = getelementptr inbounds i8, i8* %0, i64 4
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36
%41 = sext i8 %38 to i32
%42 = tail call i32 @putchar(i32 %41)
br label %45
43: ; preds = %36
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
%46 = getelementptr inbounds i8, i8* %0, i64 5
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = sext i8 %47 to i32
%51 = tail call i32 @putchar(i32 %50)
br label %54
52: ; preds = %45
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = getelementptr inbounds i8, i8* %0, i64 6
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %54
%59 = sext i8 %56 to i32
%60 = tail call i32 @putchar(i32 %59)
br label %63
61: ; preds = %54
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %63
63: ; preds = %61, %58
%64 = getelementptr inbounds i8, i8* %0, i64 7
%65 = load i8, i8* %64
%66 = icmp eq i8 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %63
%68 = sext i8 %65 to i32
%69 = tail call i32 @putchar(i32 %68)
br label %72
70: ; preds = %63
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %72
72: ; preds = %70, %67
%73 = getelementptr inbounds i8, i8* %0, i64 8
%74 = load i8, i8* %73
%75 = icmp eq i8 %74, 0
br i1 %75, label %79, label %76
76: ; preds = %72
%77 = sext i8 %74 to i32
%78 = tail call i32 @putchar(i32 %77)
br label %81
79: ; preds = %72
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %81
81: ; preds = %79, %76
%82 = tail call i32 @putchar(i32 10)
ret void
}